Compare commits
No commits in common. "b5b320f4a7324475d3d47a72676fcd4e018ebe47" and "94302003d82a4bbf97384832680cd29341ae9006" have entirely different histories.
b5b320f4a7
...
94302003d8
|
|
@ -45,7 +45,6 @@ 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,8 +14,6 @@ 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
|
||||||
|
|
@ -28,12 +26,6 @@ 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,8 +6,6 @@ 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,7 +46,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
|
||||||
|
|
@ -69,6 +67,12 @@ func _process(delta):
|
||||||
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":
|
||||||
if Input.is_action_just_released("switch_primary_item_" + str(player_number)):
|
if Input.is_action_just_released("switch_primary_item_" + str(player_number)):
|
||||||
|
|
@ -80,19 +84,12 @@ func _process(delta):
|
||||||
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
|
||||||
|
|
@ -100,9 +97,8 @@ 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:
|
||||||
|
|
@ -125,7 +121,6 @@ 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]:
|
||||||
|
|
@ -135,6 +130,8 @@ 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,21 +110,18 @@ __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