Example #1
0
    public override void Update(float delta)
    {
        var direction = (Target.Position - Enemy.Position).Normalized();

        Enemy.MoveAndSlide(direction * 50);

        if (AttackRange.OverlapsBody(Target))
        {
            StateMachine.ChangeState <EnemyAttackState>(StateTypes.Enemy);
        }
    }
    public override void Update(float delta)
    {
        if (!AttackRange.OverlapsBody(Target))
        {
            StateMachine.ChangeState <EnemyChaseState>(StateTypes.Enemy);
        }

        if (Enemy.AttackRate.IsStopped())
        {
            Enemy.Attack(Target);
            Enemy.AttackRate.Start();
        }
    }