Working towards attacking and where to put optional states.
This commit is contained in:
parent
50c1c9db51
commit
3854b2ae32
|
|
@ -159,7 +159,7 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource( 2 )]
|
[node name="Player" parent="." instance=ExtResource( 2 )]
|
||||||
position = Vector2( 642, 62 )
|
position = Vector2( 137, 54 )
|
||||||
|
|
||||||
[node name="CameraControl" type="Position2D" parent="."]
|
[node name="CameraControl" type="Position2D" parent="."]
|
||||||
process_priority = 1
|
process_priority = 1
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ actor_type = "Enemy"
|
||||||
position = Vector2( 11, -7 )
|
position = Vector2( 11, -7 )
|
||||||
frames = SubResource( 20 )
|
frames = SubResource( 20 )
|
||||||
animation = "idle"
|
animation = "idle"
|
||||||
frame = 1
|
frame = 0
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_aseprite_wizard_config_": {
|
"_aseprite_wizard_config_": {
|
||||||
"layer": "",
|
"layer": "",
|
||||||
|
|
@ -165,7 +165,9 @@ cast_to = Vector2( 0, 17 )
|
||||||
collide_with_areas = true
|
collide_with_areas = true
|
||||||
|
|
||||||
[node name="PlayerDetection" type="RayCast2D" parent="." index="7"]
|
[node name="PlayerDetection" type="RayCast2D" parent="." index="7"]
|
||||||
|
enabled = true
|
||||||
cast_to = Vector2( 21, 0 )
|
cast_to = Vector2( 21, 0 )
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
[node name="Hitbox_Component" type="Area2D" parent="." index="8"]
|
[node name="Hitbox_Component" type="Area2D" parent="." index="8"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,23 @@ extends MovementComponent
|
||||||
|
|
||||||
onready var idle_timeout = $IdleTimeout
|
onready var idle_timeout = $IdleTimeout
|
||||||
onready var edge_detector:RayCast2D = $"../EdgeDetection"
|
onready var edge_detector:RayCast2D = $"../EdgeDetection"
|
||||||
|
onready var player_detector:RayCast2D = $"../PlayerDetection"
|
||||||
|
|
||||||
var flip_flop = false
|
var flip_flop = false
|
||||||
|
var wants_to_attack = false
|
||||||
|
|
||||||
func process_physics(delta):
|
func process_physics(delta):
|
||||||
if current_movement_state == "move" and edge_detector.is_colliding() == false:
|
if current_movement_state == "move" and edge_detector.is_colliding() == false:
|
||||||
#print(owner.name, "uh oh gonna fall!")
|
#print(owner.name, "uh oh gonna fall!")
|
||||||
stop()
|
stop()
|
||||||
return
|
return
|
||||||
|
if player_detector.is_colliding():
|
||||||
|
print(owner.name, " wants to attack")
|
||||||
|
stop()
|
||||||
|
wants_to_attack = true
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
wants_to_attack = false
|
||||||
|
|
||||||
func process(delta):
|
func process(delta):
|
||||||
if current_movement_state == "idle" and idle_timeout.time_left == 0:
|
if current_movement_state == "idle" and idle_timeout.time_left == 0:
|
||||||
|
|
@ -29,3 +38,6 @@ func process(delta):
|
||||||
idle_timeout.start()
|
idle_timeout.start()
|
||||||
stop()
|
stop()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
func wants_shoot() -> bool:
|
||||||
|
return wants_to_attack
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ export var debug_component: bool = false
|
||||||
onready var desired_movement_vector: Vector2 = Vector2(0,0)
|
onready var desired_movement_vector: Vector2 = Vector2(0,0)
|
||||||
var current_movement_state:String
|
var current_movement_state:String
|
||||||
|
|
||||||
|
# Since animactor state machine can actually view properties from this type
|
||||||
|
# I'm thinking about moving the velocity tracker in here instead of player.
|
||||||
|
var velocity = Vector2(0,0)
|
||||||
|
|
||||||
#Can't use floats here, switched to constants.
|
#Can't use floats here, switched to constants.
|
||||||
#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT}
|
#enum directions {UP = -1, DOWN = 1, LEFT, RIGHT}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ script = ExtResource( 8 )
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
frames = SubResource( 75 )
|
frames = SubResource( 75 )
|
||||||
frame = 3
|
frame = 1
|
||||||
playing = true
|
playing = true
|
||||||
flip_h = true
|
flip_h = true
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user