コード例 #1
0
    private EnemyBehaviorStateS[] GetBehaviorStates()
    {
        EnemyBehaviorStateS[] states = new EnemyBehaviorStateS[behaviorStates.Count];

        int i = 0;

        foreach (GameObject bStateHolder in behaviorStates)
        {
            states[i] = bStateHolder.GetComponent <EnemyBehaviorStateS>();
            i++;
        }

        return(states);
    }
コード例 #2
0
    private void CheckStates()
    {
        if (!_isDead)
        {
            behaviorSet = false;

            foreach (EnemyBehaviorStateS bState in _behaviorStates)
            {
                if (bState.isActive() && !behaviorSet)
                {
                    stateToChangeTo = bState;
                    behaviorSet     = true;

                    if (debugState)
                    {
                        Debug.Log("Switch to " + bState.stateName);
                    }
                }
            }

            if (stateToChangeTo != null)
            {
                if (_currentState == null)
                {
                    ChangeBehaviorState(stateToChangeTo);
                }
                else
                {
                    if (_currentState != stateToChangeTo)
                    {
                        ChangeBehaviorState(stateToChangeTo);
                    }
                    else
                    {
                        _currentState.NextBehavior();
                    }
                }
            }
        }
    }
コード例 #3
0
 private void ChangeBehaviorState(EnemyBehaviorStateS newState)
 {
     _currentState = newState;
     _currentState.StartActions();
 }
コード例 #4
0
 public void ForceBehaviorState(EnemyBehaviorStateS newState)
 {
     _currentBehavior.EndAction();
     _currentState = newState;
 }
コード例 #5
0
 public virtual void SetState(EnemyBehaviorStateS myState)
 {
     myBehaviorState = myState;
 }
コード例 #6
0
 public virtual void SetState(EnemyBehaviorStateS myState)
 {
     myBehaviorState = myState;
 }