add rival to stage
This commit is contained in:
parent
e81d347313
commit
8f3edcebb1
29 changed files with 438 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
enum UnitType {
|
||||
PLAYER,
|
||||
NPC,
|
||||
RIVAL,
|
||||
}
|
||||
|
||||
enum ActionType {
|
||||
|
@ -76,6 +77,10 @@ const UNIT_TYPE_ACTIONS = {
|
|||
UnitType.NPC: [
|
||||
ActionType.MOVE,
|
||||
],
|
||||
UnitType.RIVAL: [
|
||||
ActionType.JUMP,
|
||||
ActionType.MOVE,
|
||||
],
|
||||
}
|
||||
|
||||
const UNIT_TYPE_CURRENT_ACTIONS = {
|
||||
|
@ -88,6 +93,10 @@ const UNIT_TYPE_CURRENT_ACTIONS = {
|
|||
UnitType.NPC: [
|
||||
UnitCurrentAction.IDLE,
|
||||
],
|
||||
UnitType.RIVAL: [
|
||||
UnitCurrentAction.IDLE,
|
||||
UnitCurrentAction.JUMPING,
|
||||
],
|
||||
}
|
||||
|
||||
# default conditions
|
||||
|
@ -103,6 +112,11 @@ const UNIT_TYPE_CONDITIONS = {
|
|||
UnitCondition.IS_ON_GROUND: false,
|
||||
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
|
||||
},
|
||||
UnitType.RIVAL: {
|
||||
UnitCondition.CURRENT_ACTION: UnitCurrentAction.IDLE,
|
||||
UnitCondition.IS_ON_GROUND: false,
|
||||
UnitCondition.MOVING_STATUS: UnitMovingStatus.IDLE,
|
||||
},
|
||||
}
|
||||
|
||||
# in seconds
|
||||
|
@ -111,6 +125,9 @@ const CURRENT_ACTION_TIMERS = {
|
|||
UnitCurrentAction.JUMPING: 0.4,
|
||||
UnitCurrentAction.RECOILING: 0.67,
|
||||
},
|
||||
UnitType.NPC: {
|
||||
UnitCurrentAction.JUMPING: 0.4,
|
||||
},
|
||||
}
|
||||
|
||||
const UNIT_CONDITION_TIMERS = {
|
||||
|
@ -119,6 +136,7 @@ const UNIT_CONDITION_TIMERS = {
|
|||
UnitCondition.IS_INVINCIBLE: [2.5, true, false],
|
||||
},
|
||||
UnitType.NPC: {},
|
||||
UnitType.RIVAL: {},
|
||||
}
|
||||
|
||||
# Position relative to player's origin, list of directions to check for collision
|
||||
|
@ -140,6 +158,15 @@ const ENV_COLLIDERS = {
|
|||
[Vector2(.25, 1.25), [Direction.RIGHT]],
|
||||
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
|
||||
],
|
||||
UnitType.RIVAL: [
|
||||
[Vector2(0, 1.5), [Direction.LEFT, Direction.UP, Direction.RIGHT]],
|
||||
[Vector2(-.25, .25), [Direction.LEFT]],
|
||||
[Vector2(.25, .25), [Direction.RIGHT]],
|
||||
[Vector2(-.25, 1.25), [Direction.LEFT]],
|
||||
[Vector2(.25, 1.25), [Direction.RIGHT]],
|
||||
# contact with ground is at (0, 0)
|
||||
[Vector2(0, 0), [Direction.LEFT, Direction.DOWN, Direction.RIGHT]],
|
||||
],
|
||||
}
|
||||
|
||||
const INPUT_MAP = {
|
||||
|
@ -191,15 +218,22 @@ const UNIT_SPRITES = {
|
|||
SpriteClass.WALK: [true, ["Walk"]],
|
||||
SpriteClass.JUMP: [false, ["Jump2"]],
|
||||
},
|
||||
UnitType.RIVAL: {
|
||||
SpriteClass.IDLE: [false, ["Idle"]],
|
||||
SpriteClass.WALK: [false, ["Move0", "Move-1", "Move-2", "Move+1", "Move+2"]],
|
||||
SpriteClass.JUMP: [false, ["Move0"]],
|
||||
},
|
||||
}
|
||||
|
||||
const UNIT_TYPE_MOVE_SPEEDS = {
|
||||
UnitType.PLAYER: 5,
|
||||
UnitType.NPC: 3,
|
||||
UnitType.RIVAL: 5,
|
||||
}
|
||||
|
||||
const UNIT_TYPE_JUMP_SPEEDS = {
|
||||
UnitType.PLAYER: 4.5,
|
||||
UnitType.RIVAL: 4.5,
|
||||
}
|
||||
|
||||
const SCALE_FACTOR = 1
|
||||
|
|
|
@ -60,6 +60,9 @@ func _ready():
|
|||
player_cam = player.get_node("Camera2D")
|
||||
player_cam.make_current()
|
||||
|
||||
units.append(get_node("Rival"))
|
||||
get_node("Rival").init_unit_w_scene(self)
|
||||
|
||||
stage_env = load("res://Scripts/StageEnvironment.gd").new(self)
|
||||
player.get_node("Camera2D").make_current()
|
||||
for spawning_key in spawning:
|
||||
|
|
|
@ -80,6 +80,8 @@ func get_condition(condition_num : int, default):
|
|||
return default
|
||||
|
||||
func is_current_action_timer_done(current_action : int):
|
||||
if Constants.CURRENT_ACTION_TIMERS[unit_type].keys().find(current_action) == -1:
|
||||
print(Constants.UnitType.keys()[unit_type] + " " + Constants.UnitCurrentAction.keys()[current_action])
|
||||
assert(current_action in Constants.CURRENT_ACTION_TIMERS[unit_type].keys())
|
||||
return current_action_time_elapsed >= Constants.CURRENT_ACTION_TIMERS[unit_type][current_action]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue