Compare commits
3 Commits
94302003d8
...
b5b320f4a7
| Author | SHA1 | Date | |
|---|---|---|---|
| b5b320f4a7 | |||
| f87eb297ba | |||
| 24d8ea3210 |
|
|
@ -45,6 +45,7 @@ usage = 0
|
|||
render_target_update_mode = 3
|
||||
|
||||
[node name="Lobby" parent="ViewportContainer/Viewport" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
|
||||
[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 = $"%Viewport"
|
||||
onready var lobby = $ViewportContainer/Viewport/Lobby
|
||||
|
||||
|
||||
var game_size :Vector2
|
||||
onready var window_scale :float
|
||||
|
|
@ -26,6 +28,12 @@ func _ready():
|
|||
window_scale = (OS.window_size / game_size).x
|
||||
assert(starting_level != null, "Main: starting level 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.
|
||||
#func _process(delta):
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ func _state_process_physics_idle():
|
|||
#parent_request_state_change.call_func('attack_sword')
|
||||
attack_secondary()
|
||||
|
||||
if $"../LadderDetector".is_colliding() and _wants_climb == true:
|
||||
if $"%LadderDetector".is_colliding() and _wants_climb == true:
|
||||
request_state_change.call_func('climb')
|
||||
|
||||
func attack_primary():
|
||||
|
|
@ -246,7 +246,7 @@ func _state_process_physics_enter_right():
|
|||
move_actor_as_desired(parent.transform.x.x)
|
||||
|
||||
func _state_process_physics_land():
|
||||
$"../LedgeDetector".set_enabled(true)
|
||||
$"%LedgeDetector".set_enabled(true)
|
||||
if current_state.animation_finished == true:
|
||||
request_state_change.call_func('idle')
|
||||
|
||||
|
|
@ -275,10 +275,10 @@ func _state_process_physics_hurt():
|
|||
func _state_process_physics_fall():
|
||||
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!")
|
||||
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')
|
||||
|
||||
if parent.is_on_floor():
|
||||
|
|
@ -317,10 +317,10 @@ func _state_process_physics_move():
|
|||
move_actor_as_desired()
|
||||
|
||||
func get_climb_shape_location() -> Vector2:
|
||||
if $"../LadderDetector".is_colliding():
|
||||
var point: Vector2 = $"../LadderDetector".get_collision_point()
|
||||
var shape_id = $"../LadderDetector".get_collider_shape()
|
||||
var object = $"../LadderDetector".get_collider()
|
||||
if $"%LadderDetector".is_colliding():
|
||||
var point: Vector2 = $"%LadderDetector".get_collision_point()
|
||||
var shape_id = $"%LadderDetector".get_collider_shape()
|
||||
var object = $"%LadderDetector".get_collider()
|
||||
|
||||
# This appears to get the shapes location!
|
||||
var area = Physics2DServer.area_get_transform(object)
|
||||
|
|
@ -360,7 +360,7 @@ func _state_process_physics_climb():
|
|||
func _state_process_physics_ledge_grab():
|
||||
if debug_component:
|
||||
UiManager.debug_text = (str(velocity))
|
||||
$"../LedgeDetector".set_enabled(false)
|
||||
$"%LedgeDetector".set_enabled(false)
|
||||
|
||||
if _wants_jump:
|
||||
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 stamina_component = $"%Stamina_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
|
||||
else:
|
||||
## puppets cannot get hurt, only network master.
|
||||
$Hurtbox_Component.hurtbox_entered_function = ''
|
||||
hurtbox_component.hurtbox_entered_function = ''
|
||||
|
||||
# Set initial player position in world.
|
||||
global_position = LevelInfo.player_start_position
|
||||
|
|
@ -67,12 +69,6 @@ func _process(delta):
|
|||
player_data.player_position = global_position.round()
|
||||
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:
|
||||
"idle":
|
||||
if Input.is_action_just_released("switch_primary_item_" + str(player_number)):
|
||||
|
|
@ -84,12 +80,19 @@ func _process(delta):
|
|||
if _selected_item:
|
||||
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):
|
||||
$Hurtbox_Component.set_hurtbox(false)
|
||||
hurtbox_component.set_hurtbox(false)
|
||||
health_component.take_damage(damage)
|
||||
if $Health_Component.health > 0:
|
||||
if health_component.health > 0:
|
||||
movement_state_machine.change_to_known_state('hurt')
|
||||
#PlayerInfo.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:
|
||||
return
|
||||
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:
|
||||
print("You see! a THING...", the_thing.name)
|
||||
if the_thing is HealthPickup:
|
||||
|
|
@ -121,6 +125,7 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
|||
the_thing.trigger_interaction()
|
||||
return true
|
||||
|
||||
|
||||
func enough_stamina_for(_state_name :String) -> bool:
|
||||
if state_stamina_cost.has(_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
|
||||
|
||||
|
||||
|
||||
##DONE: We need to find a way to 'use' the item.
|
||||
func use_primary_item() -> String:
|
||||
if player_inventory.primary_selection != null: # Have to make sure we even have a second
|
||||
|
|
|
|||
|
|
@ -110,18 +110,21 @@ __meta__ = {
|
|||
script = ExtResource( 6 )
|
||||
|
||||
[node name="LedgeDetector" type="RayCast2D" parent="." index="3"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color( 0, 1, 0, 1 )
|
||||
position = Vector2( 8, -10 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 1.36422e-12, -1 )
|
||||
|
||||
[node name="WallDetector" type="RayCast2D" parent="." index="4"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color( 0, 1, 0, 1 )
|
||||
position = Vector2( 6, -16 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 4, 4 )
|
||||
|
||||
[node name="LadderDetector" type="RayCast2D" parent="." index="5"]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color( 0, 1, 0, 1 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 1.36422e-12, 20 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user