コード例 #1
0
 public GameBaseState(
     GameStateTypes type,
     GameController controller)
 {
     _controller = controller;
     _type       = type;
 }
コード例 #2
0
ファイル: GameStateManager.cs プロジェクト: kyapp69/TreeGrow
    public void Reinitialize(GameStateTypes gameStateType)
    {
        _stateTypeToStateMap.Clear();

        InitializeGameStateTypes();
        PushGameState(gameStateType);
    }
コード例 #3
0
ファイル: GameStateManager.cs プロジェクト: kyapp69/TreeGrow
    public void PushGameState(GameStateTypes gameStateType)
    {
        if (_activeGameStates.Count > 0)
        {
            _activeGameStates.Peek().OnPauseState();
        }

        _activeGameStates.Push(_stateTypeToStateMap[gameStateType]);
        _stateTypeToStateMap[gameStateType].OnEnterState();
    }
コード例 #4
0
        public void ChangeState(GameStateTypes type)
        {
            if (_currentState != null)
            {
                _currentState.Finish();
            }

            Debug.Log("GameController -> changing state to : " + type.ToString());
            _currentState = CreateState(type, this);
            _currentState.Init();
        }
コード例 #5
0
        protected override void Awake()
        {
            base.Awake();
            _state = GameStateTypes.FPS;

            InputCtrl = gameObject.AddComponent <InputCtrl>();
            CamCtrl   = FindObjectOfType <CameraCtrl>();
            BeamsCtrl = FindObjectOfType <BeamsCtrl>();

            PlayerCtrl       = FindObjectOfType <PlayerCtrl>();
            SlotManager      = gameObject.AddComponent <SlotManager>();
            CrosshairManager = GetComponent <CrosshairManager>();
        }
コード例 #6
0
        static public GameBaseState CreateState(GameStateTypes type, GameController controller)
        {
            switch (type)
            {
            case GameStateTypes.INTRO: return(new GameIntroState(controller));

            case GameStateTypes.PLAYING: return(new GamePlayingState(controller));

            case GameStateTypes.MENU: return(new GameMenuState(controller));

            case GameStateTypes.END: return(new GameEndState(controller));
            }

            throw new System.NotImplementedException();
        }
コード例 #7
0
        /// <summary>
        /// Set a Current State of the Game
        /// </summary>
        /// <param name="newGameState">New Game state to set</param>
        public static void ChangeGameState(GameStateTypes newGameState)
        {
            if (m_currentGameState == newGameState)
            {
                return;
            }

            m_currentGameState = newGameState;

            /// Throw an event when game state
            /// change.
            if (OnGameStateChange != null)
            {
                OnGameStateChange(m_currentGameState);
            }
        }
コード例 #8
0
    public void OnGUI()
    {
        if (ShowFirstMenu)
        {
            //GL.Clear(true,true,Color.green);
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgroundTexture, ScaleMode.StretchToFill);
            if (centeredStyle2 == null)
            {
                centeredStyle2 = GUI.skin.GetStyle("Button");
            }
            // centeredStyle2.normal.background= NormalBackgroundOfButtonStart;
            //centeredStyle2.hover.background= NormalBackgroundOfButtonStart;
            // centeredStyle2.onHover.background= NormalBackgroundOfButtonStart;
            centeredStyle2.normal.textColor = Color.green;
            centeredStyle2.fontSize         = 25;
            // Graphics.Blit(NormalBackgroundOfButtonStart, null as RenderTexture);
            if (GUI.Button(new Rect(Screen.width / 2 - 50, -50 + Screen.height / 2 + 10, 200, 100), "Start", StartButton))
            {
                ShowFirstMenu = false;
                AudioSource audio = GetComponent <AudioSource>();
                audio.Stop();
                //var player = GameObject.FindGameObjectsWithTag("Player")[0];
                //player.GetComponent<RigidbodyFirstPersonController>().mouseLook.lockCursor= true;
            }
            GUILayout.Space(SpacingBetweenButtons);
            if (GUI.Button(new Rect(Screen.width / 2 - 50, 50 + Screen.height / 2 + 10, 200, 100), "Exit", ExitButton))
            {
                Application.Quit();
                                #if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
                                #endif
            }
        }


        if (ShowSecondMenu)
        {
            CurrentGameState = GameStateTypes.HandledDistilledWaterAndGlass;
            GUILayout.BeginArea(_firstMenuOnLoad);
            GUILayout.BeginVertical();

            if (GUILayout.Button("OK You Have Completed First\nPress To Continue", GUILayout.Width(200), GUILayout.Height(50)))
            {
                ShowSecondMenu = false;
            }
            GUILayout.Space(SpacingBetweenButtons);

            GUILayout.EndVertical();
            GUILayout.EndArea();
        }

        OnGUIGeneral();

        //GUI.Box(new Rect(0, 0, BoxWidth, BoxHeight), "This is a box");
        if (!ShowFirstMenu && !AllLevelsCompleted)
        {
            int h = 0;
            foreach (var content in contents)
            {
                if (content != null)
                {
                    GUI.Box(new Rect(0, h, BoxWidth, BoxHeight), content, style);
                }
                h += BoxHeight;
            }
        }
    }
コード例 #9
0
ファイル: GameStateManager.cs プロジェクト: kyapp69/TreeGrow
 public bool IsInState(GameStateTypes type)
 {
     return(_activeGameStates.Peek() == _stateTypeToStateMap[type]);
 }
コード例 #10
0
 public static bool IsStateRunning(GameStateTypes state)
 {
     return(Utilities.EnumIsInBitmaskEnum((int)state, (int)CurrentGameState));
 }