Example #1
0
 public void ForeachState(StateProcess process)
 {
     foreach (KeyValuePair <T, IState> kvp in states)
     {
         process(kvp.Key, kvp.Value);
     }
 }
 public void SetStateProcessOnEnter(int state, OnEnter fn)
 {
     if (!states.ContainsKey(state))
     {
         Logger.LogWarning("Failed to add state process on enter: Bad state: " + state);
         return;
     }
     states[state] = new StateProcess(states[state].canEnterFn, fn, states[state].onExitFn);
 }
Example #3
0
    public GenerationManager()
    {
        //	世代の操作情報保持リストを初期化
        m_currentGenInputBitList = initGenerationList(false);
        m_nextGenInputBitList    = initGenerationList(true);        //	参照されるため、空の情報を追加する

        //	初期化から開始
        m_stateProc = procStateInit;
    }
Example #4
0
    /**
     * 初期化
     */
    State procStateInit()
    {
        m_generation = 0;
        m_play_count = 0;

        m_tetrisList = createGeneration();
        m_stateProc  = procStateUpdate;

        return(State.Init);
    }
Example #5
0
    void SetProcess(T state)
    {
        var new_process = stateMachine.state_process[state];

        if (new_process != null)
        {
            active_process = new_process;
        }
        else
        {
            active_process = new StateProcess();
        }
    }
        //Sets the internal state
        private void SetState(string state)
        {
            StateProcess prev    = ProcessState;
            string       prevStr = State;
            bool         found   = stateProcesses.TryGetValue(state, out ProcessState);

            if (found)
            {
                State = state;
                //Debug.Log("GameController new state: " + state);
            }
            else
            {
                Debug.LogError("Invalid state requested: '" + state + "'. Returning to previous state: '" + prevStr + "'.");
                ProcessState = prev;
            }
        }
Example #7
0
    /**
     * 更新
     */
    State procStateUpdate()
    {
        for (int i = 0; i < PROC_COUNT_PER_FRAME; i++)
        {
            foreach (Tetris tetris in m_tetrisList)
            {
                tetris.update();
            }
        }

        if (true == isAllGameOver())
        {
            m_stateProc = procStateChange;
        }

        return(State.Play);
    }
        //Sets the internal state
        protected void SetState(string state)
        {
            StateProcess prev    = ProcessState;
            string       prevStr = State;
            bool         found   = stateProcesses.TryGetValue(state, out ProcessState);

            if (found)
            {
                State = state;
                //Debug.Log("Player " + PlayerNumber + " new state: " + state);
            }
            else
            {
                Debug.LogError("Invalid player state requested: '" + state + "'. Returning to previous state: '" + prevStr + "'.");
                ProcessState = prev;
            }
        }
Example #9
0
    /**
     * 盤面の変更
     */
    State procStateChange()
    {
        m_play_count++;
        int nums = m_play_count * MAX_PLAY_NUMS;

        //	操作情報を保持
        pushInputBitList();

        //	1世代分の実行数に達したら次の世代へ
        if (GENERATION_NUMS <= nums)
        {
            //	操作の遺伝
            inheritGeneration();

            m_play_count = 0;
            m_generation++;
        }

        m_tetrisList = createGeneration();
        m_stateProc  = procStateUpdate;

        return(State.Change);
    }