示例#1
0
        private void _UpdateInputState(GamePlayEngine gamePlayEngine)
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                gamePlayEngine.ExecuteCommand(new PlayerJumpCommand());
            }

            if (Input.GetKeyDown(KeyCode.Z))
            {
                gamePlayEngine.ExecuteCommand(new PlayerAttackCommand());
            }
        }
示例#2
0
        private IEnumerator _PlayMainGame(GamePlayEngine gamePlayEngine)
        {
            var state = gamePlayEngine.CurrentState;

            while (!state.Player.IsDead())
            {
                state = gamePlayEngine.Update(Time.deltaTime);

                _UpdateViews(state);
                _UpdateInputState(gamePlayEngine);
                yield return(null);
            }
        }
示例#3
0
        private IEnumerator _Main()
        {
            while (true)
            {
                var gamePlayEngine = new GamePlayEngine(
                    new GamePlayEngine.State
                {
                    Player = new Player(
                        position: Vector2D.ZERO,
                        acceleration: PLAYER_ACCELERATION),
                    Score   = 0,
                    Items   = new IItem[0],
                    Enemies = new IEnemy[0]
                });
                yield return(_PlayMainGame(gamePlayEngine));

                if (_bestScoreText != null)
                {
                    _bestScore          = Math.Max(_bestScore, gamePlayEngine.CurrentState.Score);
                    _bestScoreText.text = "Best Score: " + _bestScore;
                }

                if (_endGamePanelGameObject != null)
                {
                    _endGamePanelGameObject.SetActive(true);
                }

                while (!Input.GetKeyUp(KeyCode.Return))
                {
                    yield return(null);
                }

                if (_endGamePanelGameObject != null)
                {
                    _endGamePanelGameObject.SetActive(false);
                }
            }
        }