Beispiel #1
0
 public void DrawGhosts(IEnumerable <Ghost> ghosts)
 {
     foreach (var g in ghosts)
     {
         DrawBoardSprite(_spriteSet.Ghost(g), g.Location);
     }
 }
Beispiel #2
0
        public bool Tick()
        {
            ShowText(1, _scoreBoard.HighScoreText);
            ShowText(1, () => _scoreBoard.Player1Score(0));
            ShowText(1, () => _scoreBoard.HighScore(_uiSystem.GetAndUpdateHighScore(0)));

            ShowText(2, () => _scoreBoard.Player1Text(true));
            ShowText(2, () => _scoreBoard.Player2Text(true));
            ShowText(2, () => _scoreBoard.Credits(0));

            ShowText(3, "CHARACTER / NICKNAME", TextColour.White, 7, 5);

            DrawGhostAfter(63, GhostColour.Red, 7,
                           TextColour.Red, "-SHADOW", "\"BLINKY\"");

            DrawGhostAfter(183, GhostColour.Pink, 10,
                           TextColour.Pink, "-SPEEDY", "\"PINKY\"");

            DrawGhostAfter(303, GhostColour.Cyan, 13,
                           TextColour.Cyan, "-BASHFUL", "\"INKY\"");

            DrawGhostAfter(423, GhostColour.Orange, 16,
                           TextColour.Orange, "-POKEY", "\"CLYDE\"");

            ShowText(573, "10 pts", TextColour.White, 12, 24);
            ShowText(573, "50 pts", TextColour.White, 12, 26);
            ShowIcon(573, _spriteSet.Pill, 10, 24);
            ShowIcon(573, _spriteSet.PowerPill, 10, 26);

            ShowText(633, "c 1980 MIDWAY MFG.CO.", TextColour.Pink, 4, 31);
            ShowIcon(633, _spriteSet.PowerPill, 4, 20);

            if (_attractTick > 690)
            {
                if ((_attractTick / 8) % 2 == 0)
                {
                    _display.Update(_spriteSet.PowerPill, 10, 26);
                    if (_showPowerPill)
                    {
                        _display.Update(_spriteSet.PowerPill, 4, 20);
                    }
                }
                else
                {
                    _display.Update(_spriteSet.Blank, 10, 26);
                    _display.Update(_spriteSet.Blank, 4, 20);
                }

                if (_pointsCounter == 0)
                {
                    if (_pacMan.Location.X < 4)
                    {
                        _pacMan.ChangeDirection(Direction.Right);
                    }

                    if (_pacMan.Location.X < 5)
                    {
                        _showPowerPill = false;
                        foreach (var ghost in _ghosts)
                        {
                            ghost.SetFrightened(60 * 60);
                            ghost.SetNextDirection(Direction.Right, new Location(_display.Width + 1, 20));
                        }
                    }

                    _pacMan.Move(_pacMan.Direction == Direction.Left ? -0.125m : 0.125m, 0);
                    _pacMan.Animation.Tick();

                    foreach (var ghost in _ghosts.Where(g => g.State != GhostState.Hidden))
                    {
                        if (ghost.NextDirection == Direction.Left)
                        {
                            ghost.Move(-0.125m, 0);
                            if (_attractTick % 12 == 0)
                            {
                                ghost.Move(-0.125m, 0);
                            }
                        }
                        else
                        {
                            if (_attractTick % 2 == 0)
                            {
                                ghost.Move(0.125m, 0);
                            }
                        }

                        if (ghost.Frightened && _pacMan.Location.IsNearTo(ghost.Location))
                        {
                            _pointsCounter = 50;
                            ghost.ChangeState(GhostState.Hidden);
                        }
                    }
                }
                else
                {
                    _pointsCounter--;
                    if (_pointsCounter == 0)
                    {
                        _points++;
                    }
                }

                DrawSprite(_pointsCounter > 0
                        ? _spriteSet.GhostPoints(_points)
                        : _spriteSet.PacMan(_pacMan),
                           _pacMan.Location);


                foreach (var ghost in _ghosts.Where(g => g.State != GhostState.Hidden))
                {
                    DrawSprite(_spriteSet.Ghost(ghost), ghost.Location);
                }
            }

            _attractTick++;

            return(_pacMan.Direction != Direction.Right || _pacMan.Location.X < _display.Width + 2);
        }