Ejemplo n.º 1
0
 public void AddBehaviours(NPCStatesBehaviour npc, List <SteeringBehaviour> _behaviours, State _state)
 {
     foreach (State state in npc.states)
     {
         if (state == _state)
         {
             state.behaviours = _behaviours;
         }
     }
 }
Ejemplo n.º 2
0
    public void DeleteTransition(NPCStatesBehaviour npc, State currentState, List <NextStateInfo> nextStatesInfos)
    {
        Transition _transition = new Transition(currentState, nextStatesInfos);

        foreach (Transition trans in npc.transitions)
        {
            if (trans == _transition)
            {
                npc.transitions.Remove(trans);
            }
        }
    }
Ejemplo n.º 3
0
    public void AddTransition(NPCStatesBehaviour npc, STATE currentStateName, List <NextStateInfo> nextStateInfos)
    {
        State _currentState = npc.states.Find((x) => x.stateName == currentStateName);
        List <NextStateInfo> _nextStateInfos = nextStateInfos;

        Transition _transition = new Transition(_currentState, _nextStateInfos);

        foreach (Transition trans in npc.transitions)
        {
            if (trans == _transition) //TODO: falta delimitarlo más.
            {
                Debug.Log("Can't add it because there already is a transition like this");
            }
        }
        npc.transitions.Add(_transition);
    }
Ejemplo n.º 4
0
 public State GetNextState(NPCStatesBehaviour npc, bool _bool, State currentState, Condition condition)
 {
     foreach (Transition trans in npc.transitions)
     {
         if (trans.currentState == currentState)
         {
             foreach (NextStateInfo nsi in trans.nextStateInfo)
             {
                 if (condition == nsi.changeCondition && _bool)
                 {
                     return(nsi.stateCaseTrue);
                 }
                 else if (condition == nsi.changeCondition && !_bool)
                 {
                     return(nsi.stateCaseFalse);
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 5
0
 public NextStateInfo(NPCStatesBehaviour npc, STATE stateTrue, STATE stateFalse, Condition changeCondition)
 {
     this.stateCaseTrue   = FSMSystem.I.FindState(npc, stateTrue);
     this.stateCaseFalse  = FSMSystem.I.FindState(npc, stateFalse);
     this.changeCondition = changeCondition;
 }
Ejemplo n.º 6
0
    public State FindState(NPCStatesBehaviour npc, STATE stateName)
    {
        State returnState = npc.states.Find((x) => x.stateName == stateName);

        return(returnState);
    }
Ejemplo n.º 7
0
 public void AddState(NPCStatesBehaviour npc, State newState)
 {
     npc.states.Add(newState);
 }