コード例 #1
0
ファイル: Main.cs プロジェクト: minhhh/unity-fsm
    void Start()
    {
        customFSMManager = gameObject.AddComponent <CustomFSMManager>();
        customFSMManager.Initialize(typeof(MyState), this.GetType());

        customFSMManager.StateMachineChange(MyState.Loop);
        // Should print
        // Exit Start to Loop
        // Enter Loop from Start
        // Exit Loop to End
        // Enter End from Loop
    }
コード例 #2
0
 // Use this for initialization
 public virtual void Initialize(GeneralOptions options, GameScene gameScene)
 {
     this.gameScene = gameScene;
     difficultLevel = (DifficultLevel)options["difficultLevel"];
     gameMode       = (GameMode)options["gameMode"];
     isSavedGame    = (bool)options ["isSavedGame"];
     SetupRowColOfBoard(difficultLevel);
     // setup custom fsm
     fsm = gameObject.AddComponent <CustomFSMManager> ();
     fsm.Initialize(typeof(GameState), this, false);
     StateMachineChange = new StateMachineChangeDelegate(fsm.StateMachineChange);
     if (isSavedGame)
     {
         StateMachineChange(GameState.LoadSavedGame);
     }
     else
     {
         StateMachineChange(GameState.StartGame);
     }
 }