コード例 #1
0
    void Start()
    {
        // setting up study state machine
        _SSM = GetComponent <StudyStateMachine>();

        // creating states
        StateBase entrance        = new Entrance();
        StateBase welcome         = new WaitingRoom();
        StateBase training        = new TrainingGround();
        StateBase finish          = new LevelAfterFinish();
        StateBase finalFinish     = new LevelAfterFinish();
        StateBase recreation      = new RecreationRoom();
        StateBase finalRecreation = new FinalRecreationRoom();
        StateBase breaking        = new Break();

        // creating state transitions
        entrance.AddSuccessor(welcome, "");
        welcome.AddSuccessor(training, "");

        StateBase level;
        int       i = 0;

        for (; i < _listOfLevel.Count - 1; ++i)
        {
            level = new Level(_listOfLevel[i]);
            training.AddSuccessor(level, _listOfLevel[i]);
            level.AddSuccessor(finish, "");
        }
        level = new Level(_listOfLevel[i]);
        training.AddSuccessor(level, _listOfLevel[i]);
        level.AddSuccessor(finalFinish, "");

        finish.AddSuccessor(recreation, "");
        finalFinish.AddSuccessor(finalRecreation, "");
        recreation.AddSuccessor(breaking, "");
        breaking.AddSuccessor(training, "");

        _SSM.InitAndStart(entrance);
    }