コード例 #1
0
        public void TransitionToState(StateFSM nextState)
        {
            if (nextState != RemainState)
            {
                if (nextState != CurrentState)
                {
                    OnExitState();
                }

                CurrentState = nextState;
            }
        }
コード例 #2
0
    public static void AddAllStates()
    {
        List <enumStates> _AllStates = Enum.GetValues(typeof(enumStates)).Cast <enumStates>().ToList();

        Debug.Log("ALL STATES ARE : " + _AllStates);
        AllStates = new HashSet <StateFSM>();
        foreach (enumStates s in _AllStates)
        {
            StateFSM newState = new StateFSM(s);
            AllStates.Add(newState);
        }
        managerInited = true;
    }
コード例 #3
0
ファイル: PartyManager.cs プロジェクト: Styvak/BattleRoyal
    void UpdateFSM()
    {
        var playerCount = GameObject.FindGameObjectsWithTag("Player").Length;

        switch (state)
        {
        case StateFSM.WaitForPlayers:
            if (playerCount == maxPlayer)
            {
                if (coroutineRunning)
                {
                    StopCoroutine("StartWithMinPlayer");
                    Debug.Log("Stop corou");
                    CmdSetCoroutine(false);
                    timerText.gameObject.SetActive(false);
                }
                state       = StateFSM.Battle;
                playerAlive = playerCount;
            }
            if (playerCount == minPlayer && !coroutineRunning)
            {
                StartCoroutine("StartWithMinPlayer");
            }
            break;

        case StateFSM.Battle:
            Debug.Log("Battle");
            _players = GameObject.FindGameObjectsWithTag("Player");
            GameObject.FindWithTag("Zone").GetComponent <Zone>().StartScaleZone();
            timerText.gameObject.SetActive(false);
            if (IsOnePlayerLeft())
            {
                state = StateFSM.End;
            }
            break;

        case StateFSM.End:
            //End
            break;

        case StateFSM.Restart:
            break;
        }
    }
コード例 #4
0
ファイル: PartyManager.cs プロジェクト: Styvak/BattleRoyal
    IEnumerator StartWithMinPlayer()
    {
        if (!isServer)
        {
            yield break;
        }
        CmdSetCoroutine(true);
        timerText.gameObject.SetActive(true);
        while (timeLeft > 0)
        {
            yield return(new WaitForSeconds(1f));

            timeLeft--;
        }
        CmdSetCoroutine(false);
        state = StateFSM.Battle;
        Debug.Log("End corou");
        playerAlive = GameObject.FindGameObjectsWithTag("Player").Length;
    }
コード例 #5
0
 public static void InvokeEvent(enumEvents _event)
 {
     Debug.Log("FSMLog - invoking event " + _event.ToString());
     if (currentState.HasConsequence(_event))
     {
         if (currentState.exit != null)
         {
             currentState.exit();
         }
         enumStates nextState = currentState.NextState(_event);
         var        query     = AllStates.Where(a => a.fsmState == nextState);
         currentState = stateFsmFromEnumState(nextState);
         if (currentState.enter != null)
         {
             currentState.enter();
         }
         Debug.Log("FSMLog - Entering state " + currentState.fsmState.ToString());
     }
     else
     {
         Debug.Log("FSMERROR - state " + currentState.fsmState + " has no consequence for the event " + _event);
     }
     // StateFSM tempState ;
 }
コード例 #6
0
 public static void ForceState(enumStates _state)
 {
     currentState = stateFsmFromEnumState(_state);
 }