Compare commits
3 Commits
94302003d8
...
b5b320f4a7
| Author | SHA1 | Date | |
|---|---|---|---|
| b5b320f4a7 | |||
| f87eb297ba | |||
| 24d8ea3210 |
|
|
@ -45,6 +45,7 @@ usage = 0
|
||||||
render_target_update_mode = 3
|
render_target_update_mode = 3
|
||||||
|
|
||||||
[node name="Lobby" parent="ViewportContainer/Viewport" instance=ExtResource( 9 )]
|
[node name="Lobby" parent="ViewportContainer/Viewport" instance=ExtResource( 9 )]
|
||||||
|
visible = false
|
||||||
|
|
||||||
[node name="SceneTransition" parent="ViewportContainer/Viewport" instance=ExtResource( 4 )]
|
[node name="SceneTransition" parent="ViewportContainer/Viewport" instance=ExtResource( 4 )]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ export var start_screen: PackedScene
|
||||||
|
|
||||||
onready var viewport_container = $ViewportContainer
|
onready var viewport_container = $ViewportContainer
|
||||||
onready var viewport = $"%Viewport"
|
onready var viewport = $"%Viewport"
|
||||||
|
onready var lobby = $ViewportContainer/Viewport/Lobby
|
||||||
|
|
||||||
|
|
||||||
var game_size :Vector2
|
var game_size :Vector2
|
||||||
onready var window_scale :float
|
onready var window_scale :float
|
||||||
|
|
@ -26,6 +28,12 @@ func _ready():
|
||||||
window_scale = (OS.window_size / game_size).x
|
window_scale = (OS.window_size / game_size).x
|
||||||
assert(starting_level != null, "Main: starting level not specified.")
|
assert(starting_level != null, "Main: starting level not specified.")
|
||||||
assert(player_hud != null, "Main: player HUD not specified.")
|
assert(player_hud != null, "Main: player HUD not specified.")
|
||||||
|
assert(is_instance_valid(lobby), "Main: No lobby scene found.")
|
||||||
|
|
||||||
|
##TODO: Once a start screen is there, go there instead of lobby UI.
|
||||||
|
# Or shift this over to UIManager singleton
|
||||||
|
if is_instance_valid(start_screen) == false:
|
||||||
|
lobby.visible = true
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ func _state_process_physics_idle():
|
||||||
#parent_request_state_change.call_func('attack_sword')
|
#parent_request_state_change.call_func('attack_sword')
|
||||||
attack_secondary()
|
attack_secondary()
|
||||||
|
|
||||||
if $"../LadderDetector".is_colliding() and _wants_climb == true:
|
if $"%LadderDetector".is_colliding() and _wants_climb == true:
|
||||||
request_state_change.call_func('climb')
|
request_state_change.call_func('climb')
|
||||||
|
|
||||||
func attack_primary():
|
func attack_primary():
|
||||||
|
|
@ -246,7 +246,7 @@ func _state_process_physics_enter_right():
|
||||||
move_actor_as_desired(parent.transform.x.x)
|
move_actor_as_desired(parent.transform.x.x)
|
||||||
|
|
||||||
func _state_process_physics_land():
|
func _state_process_physics_land():
|
||||||
$"../LedgeDetector".set_enabled(true)
|
$"%LedgeDetector".set_enabled(true)
|
||||||
if current_state.animation_finished == true:
|
if current_state.animation_finished == true:
|
||||||
request_state_change.call_func('idle')
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
|
@ -275,10 +275,10 @@ func _state_process_physics_hurt():
|
||||||
func _state_process_physics_fall():
|
func _state_process_physics_fall():
|
||||||
flip_sprite_to_movement_direction()
|
flip_sprite_to_movement_direction()
|
||||||
|
|
||||||
if $"../LedgeDetector".is_colliding() and !$"../WallDetector".is_colliding():
|
if $"%LedgeDetector".is_colliding() and !$"%WallDetector".is_colliding():
|
||||||
#print("it touched me!")
|
#print("it touched me!")
|
||||||
if debug_component:
|
if debug_component:
|
||||||
UiManager.debug_text = (str($"../LedgeDetector".get_collision_point()))
|
UiManager.debug_text = (str($"%LedgeDetector".get_collision_point()))
|
||||||
request_state_change.call_func('ledge_grab')
|
request_state_change.call_func('ledge_grab')
|
||||||
|
|
||||||
if parent.is_on_floor():
|
if parent.is_on_floor():
|
||||||
|
|
@ -317,10 +317,10 @@ func _state_process_physics_move():
|
||||||
move_actor_as_desired()
|
move_actor_as_desired()
|
||||||
|
|
||||||
func get_climb_shape_location() -> Vector2:
|
func get_climb_shape_location() -> Vector2:
|
||||||
if $"../LadderDetector".is_colliding():
|
if $"%LadderDetector".is_colliding():
|
||||||
var point: Vector2 = $"../LadderDetector".get_collision_point()
|
var point: Vector2 = $"%LadderDetector".get_collision_point()
|
||||||
var shape_id = $"../LadderDetector".get_collider_shape()
|
var shape_id = $"%LadderDetector".get_collider_shape()
|
||||||
var object = $"../LadderDetector".get_collider()
|
var object = $"%LadderDetector".get_collider()
|
||||||
|
|
||||||
# This appears to get the shapes location!
|
# This appears to get the shapes location!
|
||||||
var area = Physics2DServer.area_get_transform(object)
|
var area = Physics2DServer.area_get_transform(object)
|
||||||
|
|
@ -360,7 +360,7 @@ func _state_process_physics_climb():
|
||||||
func _state_process_physics_ledge_grab():
|
func _state_process_physics_ledge_grab():
|
||||||
if debug_component:
|
if debug_component:
|
||||||
UiManager.debug_text = (str(velocity))
|
UiManager.debug_text = (str(velocity))
|
||||||
$"../LedgeDetector".set_enabled(false)
|
$"%LedgeDetector".set_enabled(false)
|
||||||
|
|
||||||
if _wants_jump:
|
if _wants_jump:
|
||||||
request_state_change.call_func('ledge_climb')
|
request_state_change.call_func('ledge_climb')
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ export var player_number: int = 1
|
||||||
onready var player_inventory :InventoryManager = InventoryManager.new()
|
onready var player_inventory :InventoryManager = InventoryManager.new()
|
||||||
onready var stamina_component = $"%Stamina_Component"
|
onready var stamina_component = $"%Stamina_Component"
|
||||||
onready var health_component = $"%Health_Component"
|
onready var health_component = $"%Health_Component"
|
||||||
|
onready var hitbox_component = $Hitbox_Component
|
||||||
|
onready var hurtbox_component = $Hurtbox_Component
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,7 +48,7 @@ func _ready():
|
||||||
player_data.player_stamina = stamina_component.stamina
|
player_data.player_stamina = stamina_component.stamina
|
||||||
else:
|
else:
|
||||||
## puppets cannot get hurt, only network master.
|
## puppets cannot get hurt, only network master.
|
||||||
$Hurtbox_Component.hurtbox_entered_function = ''
|
hurtbox_component.hurtbox_entered_function = ''
|
||||||
|
|
||||||
# Set initial player position in world.
|
# Set initial player position in world.
|
||||||
global_position = LevelInfo.player_start_position
|
global_position = LevelInfo.player_start_position
|
||||||
|
|
@ -66,12 +68,6 @@ func _process(delta):
|
||||||
## Update position and stamina in player data
|
## Update position and stamina in player data
|
||||||
player_data.player_position = global_position.round()
|
player_data.player_position = global_position.round()
|
||||||
player_data.player_stamina = stamina_component.stamina
|
player_data.player_stamina = stamina_component.stamina
|
||||||
|
|
||||||
##TODO: well I'm not sure I like this but making a whole state receiver is silly
|
|
||||||
if state_damage_amount.has(movement_state_machine.current_state.name):
|
|
||||||
$Hitbox_Component.damage_amount = state_damage_amount[movement_state_machine.current_state.name]
|
|
||||||
else:
|
|
||||||
$Hitbox_Component.damage_amount = 10
|
|
||||||
|
|
||||||
match movement_state_machine.current_state.name:
|
match movement_state_machine.current_state.name:
|
||||||
"idle":
|
"idle":
|
||||||
|
|
@ -83,13 +79,20 @@ func _process(delta):
|
||||||
var _selected_item = player_inventory.switch_secondary()
|
var _selected_item = player_inventory.switch_secondary()
|
||||||
if _selected_item:
|
if _selected_item:
|
||||||
print("Switched Secondary item to: ", _selected_item.name)
|
print("Switched Secondary item to: ", _selected_item.name)
|
||||||
|
|
||||||
|
# Adjust hitbox damage to current states or default
|
||||||
|
##TODO: well I'm not sure I like this but making a whole state receiver is silly
|
||||||
|
if state_damage_amount.has(movement_state_machine.current_state.name):
|
||||||
|
hitbox_component.damage_amount = state_damage_amount[movement_state_machine.current_state.name]
|
||||||
|
else:
|
||||||
|
hitbox_component.damage_amount = 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func hit_Receiver(damage):
|
func hit_Receiver(damage):
|
||||||
$Hurtbox_Component.set_hurtbox(false)
|
hurtbox_component.set_hurtbox(false)
|
||||||
health_component.take_damage(damage)
|
health_component.take_damage(damage)
|
||||||
if $Health_Component.health > 0:
|
if health_component.health > 0:
|
||||||
movement_state_machine.change_to_known_state('hurt')
|
movement_state_machine.change_to_known_state('hurt')
|
||||||
#PlayerInfo.player_health = health_component.health
|
#PlayerInfo.player_health = health_component.health
|
||||||
player_data.player_health = health_component.health
|
player_data.player_health = health_component.health
|
||||||
|
|
@ -97,8 +100,9 @@ func hit_Receiver(damage):
|
||||||
if health_component.health <= 0:
|
if health_component.health <= 0:
|
||||||
return
|
return
|
||||||
yield( get_tree().create_timer(2 + movement_state_machine.get_state_reference('hurt').timeout_seconds), "timeout")
|
yield( get_tree().create_timer(2 + movement_state_machine.get_state_reference('hurt').timeout_seconds), "timeout")
|
||||||
$Hurtbox_Component.set_hurtbox(true)
|
hurtbox_component.set_hurtbox(true)
|
||||||
|
|
||||||
|
## Interactable Receiver callback function. Anything touched goes here.
|
||||||
func touch_the_thing(the_thing: Interactable) -> bool:
|
func touch_the_thing(the_thing: Interactable) -> bool:
|
||||||
print("You see! a THING...", the_thing.name)
|
print("You see! a THING...", the_thing.name)
|
||||||
if the_thing is HealthPickup:
|
if the_thing is HealthPickup:
|
||||||
|
|
@ -121,6 +125,7 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
||||||
the_thing.trigger_interaction()
|
the_thing.trigger_interaction()
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
func enough_stamina_for(_state_name :String) -> bool:
|
func enough_stamina_for(_state_name :String) -> bool:
|
||||||
if state_stamina_cost.has(_state_name):
|
if state_stamina_cost.has(_state_name):
|
||||||
if stamina_component.stamina >= state_stamina_cost[_state_name]:
|
if stamina_component.stamina >= state_stamina_cost[_state_name]:
|
||||||
|
|
@ -130,8 +135,6 @@ func enough_stamina_for(_state_name :String) -> bool:
|
||||||
## Return true by default because we don't have a cost for this move
|
## Return true by default because we don't have a cost for this move
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##DONE: We need to find a way to 'use' the item.
|
##DONE: We need to find a way to 'use' the item.
|
||||||
func use_primary_item() -> String:
|
func use_primary_item() -> String:
|
||||||
if player_inventory.primary_selection != null: # Have to make sure we even have a second
|
if player_inventory.primary_selection != null: # Have to make sure we even have a second
|
||||||
|
|
|
||||||
|
|
@ -110,18 +110,21 @@ __meta__ = {
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="LedgeDetector" type="RayCast2D" parent="." index="3"]
|
[node name="LedgeDetector" type="RayCast2D" parent="." index="3"]
|
||||||
|
unique_name_in_owner = true
|
||||||
modulate = Color( 0, 1, 0, 1 )
|
modulate = Color( 0, 1, 0, 1 )
|
||||||
position = Vector2( 8, -10 )
|
position = Vector2( 8, -10 )
|
||||||
enabled = true
|
enabled = true
|
||||||
cast_to = Vector2( 1.36422e-12, -1 )
|
cast_to = Vector2( 1.36422e-12, -1 )
|
||||||
|
|
||||||
[node name="WallDetector" type="RayCast2D" parent="." index="4"]
|
[node name="WallDetector" type="RayCast2D" parent="." index="4"]
|
||||||
|
unique_name_in_owner = true
|
||||||
modulate = Color( 0, 1, 0, 1 )
|
modulate = Color( 0, 1, 0, 1 )
|
||||||
position = Vector2( 6, -16 )
|
position = Vector2( 6, -16 )
|
||||||
enabled = true
|
enabled = true
|
||||||
cast_to = Vector2( 4, 4 )
|
cast_to = Vector2( 4, 4 )
|
||||||
|
|
||||||
[node name="LadderDetector" type="RayCast2D" parent="." index="5"]
|
[node name="LadderDetector" type="RayCast2D" parent="." index="5"]
|
||||||
|
unique_name_in_owner = true
|
||||||
modulate = Color( 0, 1, 0, 1 )
|
modulate = Color( 0, 1, 0, 1 )
|
||||||
enabled = true
|
enabled = true
|
||||||
cast_to = Vector2( 1.36422e-12, 20 )
|
cast_to = Vector2( 1.36422e-12, 20 )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user