public TileBlock(TileBlock tb) { gameObjects = new List<GameObject>(); intEvents = new Queue<Func<GameScreen,TileBlock,bool>>(); setTile(tb); }
public static bool OpenChest(GameScreen gs, TileBlock b) { Item i = GameScreen.Items[ItemId.Gold].Clone(); i.addToStack(ScreenManager.Rand.Next(6, 24)); b.setTile(TileBlock.OPEN_CHEST); gs.TileMap.dropItem(i, gs.Player); return true; }
public static bool NewTreasureRoom(GameScreen gs, TileBlock b) { if (gs.Player.Alive) { gs.setRoom(new TileMap(20, 5, MapType.Treasure, gs, gs.TileMap)); gs.Player.moveTo(new Vector2(0, TileMap.SPRITE_SIZE * 3)); } return true; }
public static bool WallHeal(GameScreen gs, TileBlock b) { if (gs.Player.Stats.HpPercent != 1) { gs.Player.heal((int) (gs.Player.Stats.MaxHp * 0.1)); b.setTile(TileBlock.EMPTYMAGIC_WALL); } return true; }
public static bool MapGoBack(GameScreen gs, TileBlock b) { if (gs.TileMap.OldMap != null) { gs.setRoom(gs.TileMap.OldMap); gs.Player.moveTo(gs.TileMap.LeavePoint); } else { gs.newMainRoom(); } return true; }
public static bool NewMainRoom(GameScreen gs, TileBlock b) { int idx = gs.Player.getItemIndex(ItemId.Key); if (gs.Player.Alive && idx >= 0) { gs.Player.addXP(20); gs.Player.heal(10); gs.Player.removeItem(idx); gs.newMainRoom(); } return true; }
private void setPixel(int x, int y, TileBlock b) { set(shrinkX(x, false), shrinkY(y, false), b); }
private void set(int w, int h, TileBlock b) { if (w < 0 || h < 0 || w >= Width || h >= Height) { throw new Exception("Tried to get a tile block out of range!"); } Map[h + w * Height] = b; }
public void dropItem(Item item, Entity e) { // TileBlock b = getPixel(item.Bounds.X, item.Bounds.Y); int sX = shrinkX(e.Bounds.Center.X, false); int sY = shrinkY(e.Bounds.Center.Y, false); // Get the floor TileBlock b = get(sX, sY); while (b.isWalkable()) { b = get(sX, ++sY); } // Up one from the floor b = get(sX, --sY); EItem eitem = new EItem(item, sX * TileMap.SPRITE_SIZE + (TileMap.SPRITE_SIZE/2-EItem.DROP_SIZE/2) + ScreenManager.Rand.Next(-4, 5), e.Bounds.Y); if (!b.isShared()) { b = new TileBlock(b); set(sX, sY, b); } b.addGameObject(eitem); addGameObject(eitem); }
public static bool Nothing(GameScreen gs, TileBlock b) { return false; }
public void setTile(TileBlock tb=null) { if (isShared()) { if (tb == null) { collide = false; sprite = new Sprite(GameScreen.sprTerrains[TerrainSpriteId.None]); } else { this.sprite = tb.sprite.Clone(); this.bounds = tb.bounds; this.collide = tb.collide; } } }
public TileBlock Clone() { TileBlock b = new TileBlock(this); // Copy event list Func<GameScreen, TileBlock, bool>[] ies = new Func<GameScreen,TileBlock,bool>[this.intEvents.Count]; this.intEvents.CopyTo(ies, 0); b.intEvents = new Queue<Func<GameScreen, TileBlock, bool>>(ies); return b; }