public override void Bump(Player player) { base.Bump(player); if (player.Keys[Color] == 0) return; player.Keys[Color]--; Dead = true; }
/// <summary> /// Called when the player stands on top of a non-solid object /// </summary> /// <param name="player"></param> /// <param name="controller"></param> public virtual void PlayerEnter(Player player, GameController controller) { }
/// <summary> /// Called for a solid, non-pushable object when the player tries to move into it /// </summary> public virtual void Bump(Player player) { }
public override void PlayerEnter(Player player, GameController controller) { player.Keys[Color]++; Dead = true; }
public override void PlayerEnter(Player player, GameController controller) { base.PlayerEnter(player, controller); controller.ExitLevel(); }
public override void PlayerEnter(Player player, GameController controller) { controller.ShowMessage(_message); }
/// <summary> /// Load the Items layer from the map into the 2d Items array /// </summary> /// <returns></returns> private Grid<Item> LoadItems() { var cells = new Grid<Item>(MapSize); var layer = Map.Layers["Items"]; var playerSet = false; foreach (var tile in layer.Tiles) { if (tile.Gid == 0) continue; // No item here var sprite = SpriteLibrary[tile.Gid]; switch (sprite.Type) { case "Gold": cells[tile.X, tile.Y] = new Gold(); break; case "Key": cells[tile.X, tile.Y] = new Key(sprite); break; case "Start": if (playerSet) throw new ArgumentException("Map contains multiple start locations"); PlayerLocation = new Point(tile.X, tile.Y); Player = new Player(); playerSet = true; break; case "Door": cells[tile.X, tile.Y] = new Door(sprite); break; case "Gate": cells[tile.X, tile.Y] = new Gate(sprite); break; case "Scroll": if( ! Map.Properties.ContainsKey("ScrollMessage")) throw new ArgumentException("Map contains scrolls but no ScrollMessage"); var msg = Map.Properties["ScrollMessage"]; msg = msg.Replace('~', '\n'); cells[tile.X, tile.Y] = new Scroll(msg, sprite); break; case "Crate": cells[tile.X, tile.Y] = new Crate(sprite); break; case "Boulder": cells[tile.X, tile.Y] = new Boulder(sprite); break; case "Skull": cells[tile.X, tile.Y] = new Skull(sprite); break; case "Exit": cells[tile.X, tile.Y] = new Exit(); break; default: cells[tile.X, tile.Y] = new Item { Type = sprite.Type, Sprite = sprite }; break; } } if (!playerSet) throw new ArgumentException("Map contains no start location"); var exits = cells.Where(item => item is Exit); if (!exits.Any()) throw new ArgumentException("Map contains no exit"); if (exits.Count() > 1) throw new ArgumentException("Map contains multiple exits"); return cells; }