Esempio n. 1
0
    public override Type Tick()
    {
        var chaseTarget = _fighter.CheckForAggro();

        if (chaseTarget != null)
        {
            _fighter.SetTarget(chaseTarget);
            return(typeof(ChaseState));
        }

        if (_fighter.Target == null)
        {
            _fighter.SetCastleTarget();
        }


        // this should probably be a new state something like "AttackCastleState"
        //or "AttackBuildingState" since all fighters share similar building aggro mechanics
        if (_fighter.reachedEndOfPath)
        {
            _attackReadyTimer -= Time.deltaTime;
            if (_attackReadyTimer <= 0f)
            {
                Debug.Log("Attack!");
                _fighter.Attack();
                _attackReadyTimer = 1.3f;
            }
        }

        return(null);
    }
Esempio n. 2
0
    public override Type Tick()
    {
        var chaseTarget = _fighter.CheckForAggro();

        if (chaseTarget != _fighter.Target)
        {
            _fighter.SetTarget(chaseTarget);
            return(typeof(ChaseState));
        }

        if (_fighter.Target == null)
        {
            return(typeof(TargetCastleState));
        }

        if (_fighter.reachedEndOfPath)
        {
            _attackReadyTimer -= Time.deltaTime;
            if (_attackReadyTimer <= 0f)
            {
                Debug.Log("Attack!");
                _fighter.Attack();
                _attackReadyTimer = 1.3f;
            }
        }
        return(null);
    }