Exemplo n.º 1
0
        public PacmanGame()
        {
            CurrentGameEvent = new List <KeyValuePair <EventType, string> >();
            Board            = new PacmanBoard();
            CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.BoardReset, GetBoardString()));
            Pacman = new PacmanPacman();
            CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.PacmanLives, $"{Pacman.Lives}"));
            Ghosts = new PacmanGhost[4]
            {
                new PacmanGhost(1),
                new PacmanGhost(2),
                new PacmanGhost(3),
                new PacmanGhost(4)
            };
            Random random = new Random();

            for (var i = 0; i < Ghosts.Length; i++)
            {
                Ghosts[i].Facing = (PacmanPacman.Direction)random.Next(1, 5);
                CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.GhostUpdate, $"{i} {Ghosts[i].GetPosition().ToString()} {Ghosts[i].IsDead} {Ghosts[i].IsVulnerable}"));
            }
            Score = 0;
            CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.Score, $"{Score}"));
            GhostScoreMultiplier = 1;
            PoweredUpCounter     = 0;
            FruitSpawnCounter    = 0;
            TimeStarted          = DateTime.Now;
            GameRunning          = true;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Call after all dots and powerUp are consumed
 /// </summary>
 private void ResetBoard()
 {
     Board  = new PacmanBoard();
     Pacman = new PacmanPacman();
     Ghosts = new PacmanGhost[]
     {
         new PacmanGhost(1),
         new PacmanGhost(2),
         new PacmanGhost(3),
         new PacmanGhost(4)
     };
     CurrentGameEvent.Add(new KeyValuePair <EventType, string>(EventType.BoardReset, GetBoardString()));
 }