Ejemplo n.º 1
0
        public void ProcessGame()
        {
            InputCommand command = MasterInputManager.PopCommand();
            PlayerEntity player  = MasterEntityManager.GetPlayer() as PlayerEntity;

            if (player == null)
            {
                Console.WriteLine("Player is NULL");
                Environment.Exit(0);
            }

            if (command == InputCommand.Unknown)
            {
                //If there are no commands to process don't do anything
                return;
            }

            if (command == InputCommand.RestartGameSameMap)
            {
                if (MasterWorldManager.GetCurrentMap() == null)
                {
                    MasterWorldManager.Initialize();
                }
                else
                {
                    ResetGame(ref player);
                }

                MasterGameState = GameState.Running;
            }

            if (command == InputCommand.RestartGameDifferentMap)
            {
                MasterWorldManager.Initialize();
                player.Reset();
                MasterGameState = GameState.Running;
            }

            if (command == InputCommand.ExitGame)
            {
                MasterGameState = GameState.Ended;
                Console.Clear();
                Console.WriteLine("Thank you for playing!");
                Thread.Sleep(2000);
                Environment.Exit(0);
            }

            if (!player.isAlive())
            {
                MasterGameState = GameState.Ended;
                return;
            }

            if (MasterGameState == GameState.Running)
            {
                Point currentPosition = player.Position;
                MoveEntities(player, command);
                UpdateTiles(currentPosition, player.Position);
                UpdateDamage(player);
                if (ReadyForPlayerTransition(currentPosition))
                {
                    TransitionMap(player);
                }
            }
        }
Ejemplo n.º 2
0
 protected void LoadManagers()
 {
     MasterWorldManager.Initialize();
     MasterEntityManager.Initialize();
 }