Last stretch
This commit is contained in:
parent
466a154972
commit
68271c94ed
13 changed files with 338 additions and 99 deletions
|
@ -4,18 +4,20 @@ using System;
|
|||
public partial class Claw : CharacterBody2D
|
||||
{
|
||||
[Export] public float MovingSpeed = 32f;
|
||||
|
||||
public enum State
|
||||
{
|
||||
Waiting,
|
||||
Moving,
|
||||
Prepare,
|
||||
Attack
|
||||
}
|
||||
|
||||
private State _state = State.Moving;
|
||||
private State _state = State.Waiting;
|
||||
private float _stateTimeout = 0;
|
||||
private bool _isPlayerNearBy = false;
|
||||
private AnimatedSprite2D _sprite;
|
||||
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
|
@ -32,6 +34,9 @@ public partial class Claw : CharacterBody2D
|
|||
_stateTimeout -= (float)delta;
|
||||
switch (_state)
|
||||
{
|
||||
case State.Waiting:
|
||||
break;
|
||||
|
||||
case State.Moving:
|
||||
var direction = (Player.Instance.Position - Position).Normalized();
|
||||
Velocity = direction * MovingSpeed;
|
||||
|
@ -46,6 +51,7 @@ public partial class Claw : CharacterBody2D
|
|||
_state = State.Attack;
|
||||
_stateTimeout = 0.25f;
|
||||
}
|
||||
|
||||
break;
|
||||
case State.Attack:
|
||||
_sprite.Play("attack");
|
||||
|
@ -55,10 +61,10 @@ public partial class Claw : CharacterBody2D
|
|||
if (_isPlayerNearBy)
|
||||
Player.Instance.Kill(this);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void _OnEntered(Node2D body)
|
||||
{
|
||||
|
@ -75,7 +81,10 @@ public partial class Claw : CharacterBody2D
|
|||
{
|
||||
_isPlayerNearBy = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
GD.Print("Boss enabled");
|
||||
_state = State.Moving;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue