コード例 #1
0
 public void PopStateStack()
 {
     if (stateStack.Count == 0)
     {
         Debug.Log("PopStateStack has no state to remove.");
         curStateObj = new StateNormal();
         IGameState obj = curStateObj;
         inputHandler = obj.InputHandler;
         GameState    = GameState.Normal;
     }
     else
     {
         if (curStateObj != null)
         {
             Debug.Log("PopStateStack - Calling OnLeaveState");
             curStateObj.OnLeaveState();
             curStateObj = null;
         }
         StateEntry stateEntry = stateStack.Pop();
         inputHandler = stateEntry.InputHandler;
         GameState    = stateEntry.State;
         curStateObj  = stateEntry.StateObject;
         if (curStateObj != null)
         {
             curStateObj.OnRestoreState();
         }
         Debug.Log("StateStack now has " + stateStack.Count + " entries.");
     }
 }
コード例 #2
0
        private void Initialize()
        {
            Logger.Log("GameSystem: Starting GameSystem");
            IsInitialized   = true;
            AssetManager    = new AssetManager();
            AudioController = new AudioController();
            TextController  = new TextController();
            TextHistory     = new TextHistory();
            try
            {
                AssetManager.CompileIfNeeded();
                Logger.Log("GameSystem: Starting ScriptInterpreter");
                Type type = Type.GetType(ScriptInterpreterName);
                if (type == null)
                {
                    throw new Exception("Cannot find class " + ScriptInterpreterName + " through reflection!");
                }
                ScriptSystem = (Activator.CreateInstance(type) as IScriptInterpreter);
                if (ScriptSystem == null)
                {
                    throw new Exception("Failed to instantiate ScriptSystem!");
                }
                ScriptSystem.Initialize(this);
            }
            catch (Exception arg)
            {
                Logger.LogError($"Unable to load Script Interpreter of type {ScriptInterpreterName}!\r\n{arg}");
                throw;
                IL_00d0 :;
            }
            IsRunning   = true;
            GameState   = GameState.Normal;
            curStateObj = new StateNormal();
            IGameState obj = curStateObj;

            inputHandler      = obj.InputHandler;
            MessageBoxVisible = false;
            if (!PlayerPrefs.HasKey("width"))
            {
                PlayerPrefs.SetInt("width", 640);
            }
            if (!PlayerPrefs.HasKey("height"))
            {
                PlayerPrefs.SetInt("height", 480);
            }
            if (PlayerPrefs.GetInt("width") < 640)
            {
                PlayerPrefs.SetInt("width", 640);
            }
            if (PlayerPrefs.GetInt("height") < 480)
            {
                PlayerPrefs.SetInt("height", 480);
            }
            if ((Screen.width < 640 || Screen.height < 480) && !Screen.fullScreen)
            {
                Screen.SetResolution(640, 480, fullscreen: false);
            }
        }
コード例 #3
0
        public void ForceReturnNormalState()
        {
            stateStack.Clear();
            curStateObj = new StateNormal();
            IGameState obj = curStateObj;

            inputHandler = obj.InputHandler;
            GameState    = GameState.Normal;
        }
コード例 #4
0
 public void LeaveConfigScreen(ConfigManager.LeaveConfigDelegate callback)
 {
     inputHandler = null;
     configManager.Leave(delegate
     {
         PopStateStack();
         ExecuteActions();
         if (callback != null)
         {
             callback();
         }
     });
 }
コード例 #5
0
 private void PushStateStack(MGHelper.InputHandler newHandler, GameState newState)
 {
     if (curStateObj != null)
     {
         stateStack.Push(new StateEntry(curStateObj, GameState));
     }
     else
     {
         stateStack.Push(new StateEntry(inputHandler, GameState));
     }
     inputHandler = newHandler;
     GameState    = newState;
     curStateObj  = null;
 }
コード例 #6
0
        public void PushStateObject(IGameState stateObject)
        {
            if (curStateObj != null)
            {
                stateStack.Push(new StateEntry(curStateObj, GameState));
            }
            else
            {
                stateStack.Push(new StateEntry(inputHandler, GameState));
            }
            curStateObj = stateObject;
            IGameState obj = curStateObj;

            inputHandler = obj.InputHandler;
            GameState    = curStateObj.GetStateType();
        }
コード例 #7
0
 public void LeaveGalleryScreen(GalleryManager.GalleryCloseCallback callback)
 {
     if (!(galleryManager == null))
     {
         inputHandler = null;
         galleryManager.Close(delegate
         {
             PopStateStack();
             ExecuteActions();
             galleryManager = null;
             if (callback != null)
             {
                 callback();
             }
         });
     }
 }
コード例 #8
0
 public StateEntry(IGameState stateobj, GameState state)
 {
     StateObject  = stateobj;
     InputHandler = stateobj.InputHandler;
     State        = state;
 }
コード例 #9
0
 public StateEntry(MGHelper.InputHandler inputHandler, GameState state)
 {
     InputHandler = inputHandler;
     State        = state;
 }