I can get hurt again.
This commit is contained in:
parent
acff2fe105
commit
dfdc2d059f
|
|
@ -169,6 +169,23 @@ func _state_process_physics_land():
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
move_actor_as_desired()
|
move_actor_as_desired()
|
||||||
|
|
||||||
|
func _state_process_physics_hurt():
|
||||||
|
if current_state.state_timeout.time_left == 0:
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
# if !parent.is_on_floor():
|
||||||
|
# #return fall_state
|
||||||
|
# request_state_change.call_func('fall')
|
||||||
|
velocity.y += current_state.gravity * physics_delta
|
||||||
|
#parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1))
|
||||||
|
velocity.x = parent.transform.x.x * -1 * current_state.horizontal_speed
|
||||||
|
# if (parent.direction.x > 0):
|
||||||
|
# parent.velocity.x = 1 * move_speed
|
||||||
|
# else:
|
||||||
|
# parent.velocity.x = -1 * move_speed
|
||||||
|
velocity = parent.move_and_slide(velocity, Vector2(0, -1))
|
||||||
|
|
||||||
|
|
||||||
func _state_process_physics_fall():
|
func _state_process_physics_fall():
|
||||||
flip_sprite_to_movement_direction()
|
flip_sprite_to_movement_direction()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,19 @@ extends Actor
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
PlayerInfo.player_health = $Health_Component.health
|
||||||
|
|
||||||
|
|
||||||
# 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):
|
||||||
# pass
|
# pass
|
||||||
|
func hit_Receiver(damage):
|
||||||
|
$Hurtbox_Component.set_hurtbox(false)
|
||||||
|
$Health_Component.take_damage(damage)
|
||||||
|
if $Health_Component.health > 0:
|
||||||
|
movement_state_machine.change_to_known_state('hurt')
|
||||||
|
PlayerInfo.player_health = $Health_Component.health
|
||||||
|
if PlayerInfo.player_health <= 0:
|
||||||
|
return
|
||||||
|
yield( get_tree().create_timer(2 + movement_state_machine.get_state_reference('hurt').timeout_seconds), "timeout")
|
||||||
|
$Hurtbox_Component.set_hurtbox(true)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=17 format=2]
|
[gd_scene load_steps=22 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
||||||
|
|
@ -15,17 +15,37 @@
|
||||||
[ext_resource path="res://src/actors/players/playerE/states/roll.tres" type="Resource" id=13]
|
[ext_resource path="res://src/actors/players/playerE/states/roll.tres" type="Resource" id=13]
|
||||||
[ext_resource path="res://src/actors/players/playerE/states/crouch.tres" type="Resource" id=14]
|
[ext_resource path="res://src/actors/players/playerE/states/crouch.tres" type="Resource" id=14]
|
||||||
[ext_resource path="res://src/actors/players/playerE/states/crouch_move.tres" type="Resource" id=15]
|
[ext_resource path="res://src/actors/players/playerE/states/crouch_move.tres" type="Resource" id=15]
|
||||||
|
[ext_resource path="res://lib/components/Hurtbox_Component.tscn" type="PackedScene" id=16]
|
||||||
|
[ext_resource path="res://lib/components/Health_Component.tscn" type="PackedScene" id=17]
|
||||||
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=18]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=3]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
resource_name = "hurt"
|
||||||
|
script = ExtResource( 18 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 2.0
|
||||||
|
name = "hurt"
|
||||||
|
horizontal_speed = 20.0
|
||||||
|
horizontal_acceleration = 0.0
|
||||||
|
horizontal_speed_offset = 0.0
|
||||||
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "hurt" ]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 7, 14 )
|
extents = Vector2( 7, 14 )
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
|
extents = Vector2( 9, 15 )
|
||||||
|
|
||||||
[node name="PlayerE" instance=ExtResource( 1 )]
|
[node name="PlayerE" instance=ExtResource( 1 )]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
actor_type = "Player"
|
actor_type = "Player"
|
||||||
|
|
||||||
[node name="Movement_StateMachine" parent="." index="0"]
|
[node name="Movement_StateMachine" parent="." index="0"]
|
||||||
starting_state_name = "idle"
|
starting_state_name = "idle"
|
||||||
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ) ]
|
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), SubResource( 3 ) ]
|
||||||
|
|
||||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||||
frames = ExtResource( 2 )
|
frames = ExtResource( 2 )
|
||||||
|
|
@ -50,3 +70,16 @@ script = ExtResource( 6 )
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="4"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="4"]
|
||||||
position = Vector2( 0, 2 )
|
position = Vector2( 0, 2 )
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Health_Component" parent="." index="5" instance=ExtResource( 17 )]
|
||||||
|
max_health = 100
|
||||||
|
|
||||||
|
[node name="Hurtbox_Component" parent="." index="6" instance=ExtResource( 16 )]
|
||||||
|
collision_layer = 16
|
||||||
|
collision_mask = 128
|
||||||
|
hurtbox_entered_function = "hit_Receiver"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox_Component" index="0"]
|
||||||
|
modulate = Color( 0, 0, 1, 1 )
|
||||||
|
position = Vector2( -1, 2 )
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
[gd_scene load_steps=3 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/templates/level_templates/LevelTemplate.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://src/templates/level_templates/LevelTemplate.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/levels/LegacyFantasy-High_Forest/tileset.tres" type="TileSet" id=2]
|
[ext_resource path="res://assets/levels/LegacyFantasy-High_Forest/tileset.tres" type="TileSet" id=2]
|
||||||
|
[ext_resource path="res://lib/components/Hitbox_Component.tscn" type="PackedScene" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id=1]
|
||||||
|
radius = 5.09902
|
||||||
|
|
||||||
[node name="TestBox" instance=ExtResource( 1 )]
|
[node name="TestBox" instance=ExtResource( 1 )]
|
||||||
|
|
||||||
|
|
@ -14,3 +18,18 @@ tile_set = ExtResource( 2 )
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
tile_data = PoolIntArray( 524288, 0, 2, 524307, 0, 3 )
|
tile_data = PoolIntArray( 524288, 0, 2, 524307, 0, 3 )
|
||||||
|
|
||||||
|
[node name="Hitbox_Component" parent="." index="4" instance=ExtResource( 3 )]
|
||||||
|
damage_amount = 10
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="Hitbox_Component" index="0"]
|
||||||
|
margin_left = 263.0
|
||||||
|
margin_top = 115.0
|
||||||
|
margin_right = 273.0
|
||||||
|
margin_bottom = 124.0
|
||||||
|
color = Color( 1, 0, 0, 1 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox_Component" index="1"]
|
||||||
|
modulate = Color( 1, 0, 0, 1 )
|
||||||
|
position = Vector2( 268, 119 )
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user