Beispiel #1
0
 public Game(int cellSize)
 {
     gameMatrix        = GameMatrices.gameMatrixWithDots;
     GameMatrixSize[0] = GameMatrix.GetLength(0);
     GameMatrixSize[1] = GameMatrix.GetLength(1);
     Human             = new Human(this.GameMatrixSize, cellSize, this, new int[] { 23, 14 }, Directions.Left, 1);
     blinky            = new Red(this.GameMatrixSize, cellSize, this, new int[] { 5, 6 }, Directions.Down, 1);
     pinky             = new Pink(this.GameMatrixSize, cellSize, this, new int[] { 29, 1 }, Directions.Right, 1);
     inky    = new Blue(this.GameMatrixSize, cellSize, this, new int[] { 29, 26 }, Directions.Up, 1);
     clyde   = new Orange(this.GameMatrixSize, cellSize, this, new int[] { 5, 26 }, Directions.Left, 1);
     Players = new Player[] { Human, blinky, pinky, inky, clyde };
     foreach (Player ght in Players)
     {
         if (ght is AI)
         {
             Human.HumanPositionChanged += ((AI)ght).OnHumanPositionChanged;
         }
     }
     blinky.RedPositionChanged += inky.OnRedPositionChanged;
     this.cellSize              = cellSize;
     dotsCount           = CountDots();
     frameTimer          = new DispatcherTimer();
     frameTimer.Interval = TimeSpan.FromMilliseconds(interval);
     frameTimer.Tick    += Timer_Tick;
     frameTimer.Start();
     gameTimer          = new Timer();
     gameTimer.Interval = gameTimerIntervals[gameTimerCounter];
     gameTimer.Elapsed += GameTimer_Elapsed;
     gameTimer.Start();
     stopwatch.Start();
     scaredTimer       = new DispatcherTimer();
     scaredTimer.Tick += ScaredTimer_Tick;
 }