Exemplo n.º 1
0
        protected virtual bool CanGoDirection(Vector2 direction)
        {
            Vector2 destinationTilePosition = (TilePosition + new Vector2(level.TileSize / 2)) + (direction * level.TileSize);

            if (!level.GetAt(destinationTilePosition).Blocked)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        private void Collision()
        {
            Tile currentTile = currentLevel.GetAt(pacman.Position);

            if (currentTile.Powerup != null)
            {
                pacman.Score += currentLevel.GetAt(pacman.Position).Powerup.Score;


                switch (currentTile.Powerup.Type)
                {
                case PowerUpType.WallEater:
                    pacman.ActivatePowerup(currentTile.Powerup);
                    hud.AddGainedScore(new GainedScore(currentTile, currentLevel.GetAt(pacman.Position).Powerup.Score, 1000));
                    break;

                case PowerUpType.GhostEater:
                    pacman.ActivatePowerup(currentTile.Powerup);
                    hud.AddGainedScore(new GainedScore(currentTile, currentLevel.GetAt(pacman.Position).Powerup.Score, 1000));
                    break;

                case PowerUpType.BigFood:
                    hud.AddGainedScore(new GainedScore(currentTile, currentLevel.GetAt(pacman.Position).Powerup.Score, 1000));
                    break;

                default:
                    break;
                }
                currentTile.Powerup = null;
            }

            foreach (Ghost ghost in ghosts)
            {
                if (ghost.TilePosition == pacman.TilePosition && pacman.ActivePowerupType != PowerUpType.GhostEater)
                {
                    pacman.LoseLives();
                }
                else if (ghost.TilePosition == pacman.TilePosition && pacman.ActivePowerupType == PowerUpType.GhostEater)
                {
                    ghost.Dead    = true;
                    pacman.Score += 200;
                    hud.AddGainedScore(new GainedScore(currentTile, 200, 1000));
                }
            }
        }