Esempio n. 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));
        }
Esempio n. 2
0
        /// <summary>
        /// Eat the item at position.
        /// </summary>
        /// <param name="position">Pac-Man position</param>
        /// <returns>Returns the type of item that was eaten.</returns>
        public TileItem EatItem(Vector2 position)
        {
            ScoreItem item = _tileItems[(int)position.X, (int)position.Y];

            if (item != null)
            {
                var type = item.ItemType;

                if (type == TileItem.Dot)
                {
                    DotsLeft--;
                    Blinky.HandleElroy(ScreenManager.CurrentLevel, DotsLeft);
                }
                else if (type == TileItem.Energizer)
                {
                    EnergizersLeft--;
                    GhostMode = GhostMode.Frightened;
                }
                item.Eat();
                _tileItems[(int)position.X, (int)position.Y] = null;

                // TODO: Spawn fruits after 70 dots or 70 dots+energizers?
                // 1st spawn after 70 dots have been cleared
                if (Fruit == null && DotsLeft == 170)
                {
                    SpawnFruit(ScreenManager.CurrentLevel);
                }

                // 2nd spawn after 170 dots have been cleared
                if (Fruit == null && DotsLeft == 70)
                {
                    SpawnFruit(ScreenManager.CurrentLevel);
                }

                return(type);
            }
            return(TileItem.None);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
            }
        }