public void BuildGameMap(Player player, GameLevel level) { this.level = level; BuildMap(null); CentreCamera(); BuildContent(null); BuildPlayerAvatar(player, null); BuildNPC(level); BuildAffector(null); }
public void BuildGameMap(Player player, JsonSavedGame savedGame) { this.level = savedGame.Level; BuildMap(savedGame.Map); CentreCamera(); BuildContent(savedGame.Map); BuildPlayerAvatar(player, savedGame.Player); BuildNPC(level, savedGame.NPCList); BuildAffector(savedGame.Map.DrugAffect); }
public override void LoadContent() { _font = Resources.GetFont(Resources.FontResources.NinaB); var tempSheet = Resources.GetBitmap(Resources.BitmapResources.pacman); _spriteSheet = new Bitmap(tempSheet.Width, tempSheet.Height); _spriteSheet.DrawImage(0, 0, tempSheet, 0, 0, tempSheet.Width, tempSheet.Height); _spriteSheet.MakeTransparent(Microsoft.SPOT.Presentation.Media.Color.Black); _maze = new Maze(); _maze.Draw(Surface, Host); _pacman = new Player(_spriteSheet, _maze); #region Initialize Bonus Point Sprites _bonus200 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(80, 104, 16, 8) })); _bonus400 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(96, 104, 16, 8) })); _bonus800 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(112, 104, 16, 8) })); _bonus1600 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(128, 104, 16, 8) })); _bonus100 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(0, 112, 16, 8) })); _bonus300 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(16, 112, 16, 8) })); _bonus500 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(32, 112, 16, 8) })); _bonus700 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(48, 112, 16, 8) })); _bonus1000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(64, 112, 20, 8) })); _bonus2000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(84, 112, 20, 8) })); _bonus3000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(106, 112, 20, 8) })); _bonus5000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(128, 112, 16, 8) })); #endregion #region Initialize Ghosts _blinky = new Ghost(_spriteSheet, _maze, _pacman, 16, new Personality() { ScatterX = 13 * 16, ScatterY = -2 * 16, TargetOffsetX = 0, TargetOffsetY = 0, HouseX = 7 * 16, HouseY = 7 * 16, StartX = 7 * 16, StartY = 5 * 16 }); _blinky.CurrentDirection = Direction.Left; _pinky = new Ghost(_spriteSheet, _maze, _pacman, 32, new Personality() { ScatterX = 1 * 16, ScatterY = -2 * 16, TargetOffsetX = 4 * 16, TargetOffsetY = 0, HouseX = 6 * 16, HouseY = 7 * 16, StartX = 6 * 16, StartY = 7 * 16 }); _pinky.CurrentDirection = Direction.Left; _inky = new Ghost(_spriteSheet, _maze, _pacman, 48, new Personality() { ScatterX = 14 * 16, ScatterY = 15 * 16, TargetOffsetX = -3 * 16, TargetOffsetY = 0, HouseX = 7 * 16, HouseY = 7 * 16, StartX = 7 * 16, StartY = 7 * 16 }); _inky.CurrentDirection = Direction.Left; _clyde = new Ghost(_spriteSheet, _maze, _pacman, 64, new Personality() { ScatterX = 0 * 16, ScatterY = 15 * 16, TargetOffsetX = 0, TargetOffsetY = -2 * 16, HouseX = 8 * 16, HouseY = 7 * 16, StartX = 8 * 16, StartY = 7 * 16 }); _clyde.CurrentDirection = Direction.Left; #endregion _pacman.Enemies = new Ghost[] { _blinky, _pinky, _inky, _clyde }; #region Add objects to scene AddToScene(_showBonusCountDown); AddToScene(_showBonusScoreCountDown); AddToScene(_maze); AddToScene(_pacman); AddToScene(_blinky); AddToScene(_pinky); AddToScene(_inky); AddToScene(_clyde); #endregion _maze.LevelComplete += MazeLevelComplete; _showBonusCountDown.Expired += BonusCountDown_Expired; MessageService.Instance.Subscribe(typeof(Messages.PacmanDeadMessage), HandlePacmanDeadMessage); MessageService.Instance.Subscribe(typeof(Messages.PacmanAteGhostMessage), HandlePacmanAteGhostMessage); MessageService.Instance.Subscribe(typeof(Messages.AteBonusItemMessage), HandleAteBonusItem); base.LoadContent(); Reset(); }
private Tile LoadPacman(int x, int y) { pacman = new Player(this, new Vector2(Tile.Width * x, Tile.Width * y)); return LoadTile("Empty", TileCollision.Passable); }
private void BuildPlayerAvatar(Player player, JsonPlayer? jsonPlayer) { singlePlayer = player; if (jsonPlayer == null) singlePlayer.Initialize(); else singlePlayer.Initialize(jsonPlayer.Value); }
public Ghost(Bitmap spriteSheet, Maze maze, Player player, int spriteSheetYOffset, Personality personality) : base(maze) { _game = (PacmanGame)GameManager.Game; Player = player; _personality = personality; // NB: The sequence of the animations must match the // "Animation Selection Constants" defined above SetAnimationSequences(new AnimationSequence[] { // 0 - Left new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(0, spriteSheetYOffset, 16, 16), new Rect(16, spriteSheetYOffset, 16, 16), }), // 1 - Right new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(32, spriteSheetYOffset, 16, 16), new Rect(48, spriteSheetYOffset, 16, 16), }), // 2 - Up new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(64, spriteSheetYOffset, 16, 16), new Rect(80, spriteSheetYOffset, 16, 16), }), // 3 - Down new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(96, spriteSheetYOffset, 16, 16), new Rect(112, spriteSheetYOffset, 16, 16), }), // 4 - Frightened new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(128, 16, 16, 16), new Rect(144, 16, 16, 16), }), // 5 - Recovering new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(128, 16, 16, 16), new Rect(128, 32, 16, 16), new Rect(144, 16, 16, 16), new Rect(144, 32, 16, 16), }), // 6 - Left Dead new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(128, 48, 16, 16), }), // 7 - Right Dead new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(144, 48, 16, 16), }), // 8 - Up Dead new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(128, 64, 16, 16), }), // 9 - Down Dead new AnimationSequence(spriteSheet, 6, new Rect[] { new Rect(144, 64, 16, 16), }), }); Reset(); MessageService.Instance.Subscribe(typeof(Messages.AtePowerPillMessage), HandleAtePowerPillMessage); MessageService.Instance.Subscribe(typeof(Messages.PacmanDyingMessage), HandlePacmanDyingMessage); MessageService.Instance.Subscribe(typeof(Messages.PacmanDeadMessage), HandlePacmanDeadMessage); _stateCountDown.Expired += StateCountDown_Expired; }
private Direction HuntTarget(Player player) { int tx = player.X; int ty = player.Y; switch (player.CurrentDirection) { case Direction.Left: tx -= _personality.TargetOffsetX; break; case Direction.Right: tx += _personality.TargetOffsetX; break; case Direction.Up: ty -= _personality.TargetOffsetY; break; case Direction.Down: ty += _personality.TargetOffsetY; break; } return HuntTarget(tx, ty); }
public void OnObjectForSaveInstantiated(IJsonSerializable jsonObject) { switch (jsonObject.JsonType) { case JsonObjectType.Map: map = (GameMap)jsonObject; break; case JsonObjectType.Player: player = (Player)jsonObject; break; case JsonObjectType.NPC: npcList.Add((NonPlayerController)jsonObject); break; } }
public void BindPlayer(Player player) { player.EventStateChanged = OnStateChanged; }