示例#1
0
        private void ResetActors()
        {
            var pacOrigin   = new Vector2(48 * Sprite.Scale / 2f, 48 * Sprite.Scale / 2f);
            var ghostOrigin = new Vector2(48 * Sprite.Scale / 2f, 51 * Sprite.Scale / 2f);

            PacMan = new PacMan(this, ScreenManager.PacManTileset, PacmanStartingPosition);

            //Blinky = new Blinky(this, ScreenManager.GhostBlinkyTileset, BlinkyStartingPosition);
            Blinky = new Blinky(this, ScreenManager.GhostBlinkyTileset, Utils.GridToAbs(new Vector2(26, 4), ghostOrigin));

            //Pinky = new Pinky(this, ScreenManager.GhostPinkyTileset, PinkyStartingPosition);
            Pinky = new Pinky(this, ScreenManager.GhostPinkyTileset, Utils.GridToAbs(new Vector2(4, 4), ghostOrigin));

            //Inky = new Inky(this, ScreenManager.GhostInkyTileset, InkyStartingPosition);
            Inky = new Inky(this, ScreenManager.GhostInkyTileset, Utils.GridToAbs(new Vector2(24, 32), ghostOrigin));

            //Clyde = new Clyde(this, ScreenManager.GhostClydeTileset, ClydeStartingPosition);
            Clyde = new Clyde(this, ScreenManager.GhostClydeTileset, Utils.GridToAbs(new Vector2(4, 32), ghostOrigin));
        }
示例#2
0
        public void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            DrawBoard(spriteBatch);

            // Draw items
            for (int y = 0; y < TilesHigh; y++)
            {
                for (int x = 0; x < TilesWide; x++)
                {
                    if (_tileItems[x, y] != null)
                    {
                        _tileItems[x, y].Draw(spriteBatch, gameTime);
                    }
                }
            }

#if DEBUG
            if (!HideBlinky)
            {
                DrawGhostDirection(spriteBatch, Blinky);
            }
            if (!HidePinky)
            {
                DrawGhostDirection(spriteBatch, Pinky);
            }
            if (!HideInky)
            {
                DrawGhostDirection(spriteBatch, Inky);
            }
            if (!HideClyde)
            {
                DrawGhostDirection(spriteBatch, Clyde);
            }
#endif

            PacMan.Draw(spriteBatch, gameTime);

            if (!HideBlinky)
            {
                Blinky.Draw(spriteBatch, gameTime);
            }
            if (!HidePinky)
            {
                Pinky.Draw(spriteBatch, gameTime);
            }
            if (!HideInky)
            {
                Inky.Draw(spriteBatch, gameTime);
            }
            if (!HideClyde)
            {
                Clyde.Draw(spriteBatch, gameTime);
            }

            // Fruit
            if (Fruit != null)
            {
                Fruit.Draw(spriteBatch, gameTime);
            }

            // Effects
            for (int i = 0; i < Effects.Count; i++)
            {
                Effects[i].Draw(spriteBatch, gameTime);
            }

            // HUD
            DrawHud(spriteBatch);
        }
示例#3
0
        public void Update(GameTime gameTime)
        {
            // Next level?
            if (DotsLeft + EnergizersLeft == 0)
            {
                NextLevel();
            }

            PacMan.Update(gameTime);

            if (!HideBlinky)
            {
                Blinky.Update(gameTime);
            }
            if (!HidePinky)
            {
                Pinky.Update(gameTime);
            }
            if (!HideInky)
            {
                Inky.Update(gameTime);
            }
            if (!HideClyde)
            {
                Clyde.Update(gameTime);
            }

            if (Fruit != null)
            {
                Fruit.Update(gameTime);

                if (!Fruit.IsFlashing && Fruit.Duration < 5)
                {
                    Fruit.Flash(4, 8);
                }

                if (Fruit.Duration < 0)
                {
                    Fruit = null;
                }
            }

            if (_ghostModeDuration > 0)
            {
                _ghostModeDuration -= gameTime.ElapsedGameTime.TotalSeconds;
            }

            if (_ghostModeDuration <= 0)
            {
                GhostMode = GhostMode.Chase;
            }

            // Frightened mode
            if (GhostMode == GhostMode.Frightened && !Inky.IsFlashing && _ghostModeDuration <= _ghostModeBeginFlashing)
            {
                Blinky.Flash(_ghostModeBeginFlashing, _ghostModeFlashes);
                Pinky.Flash(_ghostModeBeginFlashing, _ghostModeFlashes);
                Inky.Flash(_ghostModeBeginFlashing, _ghostModeFlashes);
                Clyde.Flash(_ghostModeBeginFlashing, _ghostModeFlashes);
            }

            // Effects
            for (int i = 0; i < Effects.Count; i++)
            {
                Effects[i].Update(gameTime);
            }
        }