public StartState(Player player) : base(player) { if (p.id == 1) { SoundSystem.setBackgroundMusic("main"); } }
public EndState(Player p) : base(p) { SoundSystem.setBackgroundMusic("emergency"); }
public DeathState(Player p, string message) : base(p) { this.message = message; p.pushState(new TextBox(this, p, message)); SoundSystem.setBackgroundMusic("emergency"); }
public override void run(Player p) { p.world.editing = true; p.world.setBlockAt(17, 3, 0); p.world.editing = false; if (p.xOffset == 0 && p.x == 16) { p.dir = 1; if (p.y == 3 && p.yOffset == 0) { p.dir = 0; if (frames >= 270) { WorldState.worldinit(); Player[] players = Game.players; for (int i = 0; i < players.Length; i++) { players[i] = new Player(i + 1); players[i].setState(new EndState(p)); } Game.waterRising = false; } else if (frames >= 150) { frames++; } else if (frames >= 140) { buns.attack = true; frames++; } else if (frames == 0) { SoundSystem.setBackgroundMusic("tbc"); frames++; } else { frames++; } } else if (p.yOffset == 0) { p.y--; p.yOffset = 15; p.dir = 1; } else { p.yOffset--; p.dir = 1; } } else if (p.x == 17) { p.x = 16; p.xOffset = 15; p.dir = 2; } else { p.xOffset--; } }
//most if this is kind of complicated, and shouldn't need to be modified. //code exists already for if we want underwater features for some reason. public override void draw(Graphics g, Player p) { List <DrawUnit>[] layers = new List <DrawUnit> [19]; int waterPixel = getWaterPixel(); if (p.id == 1 && !(this is EndAnimation)) { if (p.breath < Player.MAX_BREATH / 2) { SoundSystem.setBackgroundMusic("ohShiitakeMushrooms"); } else if (waterPixel > 12) { SoundSystem.setBackgroundMusic("emergency2"); } else { if (p.worldID == 0) { SoundSystem.setBackgroundMusic("beige"); } else if (p.worldID == 1) { SoundSystem.setBackgroundMusic("dracula"); } else if (p.worldID == 2) { SoundSystem.setBackgroundMusic("creepyMusic"); } else if (p.worldID == 3) { SoundSystem.setBackgroundMusic("eeyore"); } } } for (int i = 0; i < 19; i++) { layers[i] = new List <DrawUnit>(); } /*if (waterPixel==16) * { * g.Clear(Color.Black); * for (int x = p.x - 7; x <= p.x + 7; x++) //important! tiles get drawn on before blocks * { * for (int y = p.y - 5; y <= p.y + 5; y++) * { * if (p.world.getTileAt(x, y) == (int)Block.DeepWater) * if (st != null) * { * layers[y + 7 - p.y].Add(new DrawUnit(st, 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); * } * } * } * for(int i = 0; i < Game.players.Length; i++) * { * Player p2 = Game.players[i]; * if (p2.world == p.world) * { * if (p2.world.getTileAt(p2.x, p2.y) == (int)Block.DeepWater) * { * int layer = p2.y - p.y + 9; * if (layer >= 0 && layer < layers.Length) * layers[layer].Add(new DrawUnit(p2.getSprite(), 72 + p2.x * 16 + p2.xOffset - p.x * 16 - p.xOffset, 64 + p2.y * 16 + p2.yOffset - p.y * 16 - p.yOffset)); * } * } * } * List<Entity> entities = p.world.entities; * for (int i = 0; i < entities.Count; i++) * { * Entity e = entities[i]; * if (e.world.getTileAt(e.x, e.y) == (int)Block.DeepWater) * { * int layer = e.y - p.y + 9; * if (layer >= 0 && layer < layers.Length) * layers[layer].Add(new DrawUnit(e.getSprite(), 72 + 16 * e.x - p.x * 16 - p.xOffset, 64 + 16 * e.y - p.y * 16 - p.yOffset)); * } * } * for (int x = p.x - 7; x <= p.x + 7; x++) * { * for (int y = p.y - 5; y <= p.y + 6; y++) * { * if (p.world.getTileAt(x, y) != (int)Block.DeepWater) continue; * int block = p.world.getBlockAt(x, y); * if (block == 0) continue; * int layer = y - p.y + 8; * if (block == (int)Block.Kelp) layer++; * Sprite s = tileSprites[block]; * if (s != null) layers[layer].Add(new DrawUnit(s, 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); * } * } * } * else*/ { g.Clear(Color.Black); for (int x = p.x - 7; x <= p.x + 7; x++) //important! tiles get drawn on before blocks { for (int y = p.y - 5; y <= p.y + 5; y++) { Sprite s; int layer = y - p.y + 7; int tile = p.world.getTileAt(x, y); if (waterPixel > 0 && waterPixel < 16 && p.world.isInside(x, y) && (tile != (int)Block.UpStairs && tile != (int)Block.DownStairs)) { s = waterSprites[0]; layer--; } else { s = tileSprites[tile]; } layers[layer].Add(new DrawUnit(s, 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); } } for (int i = 0; i < Game.players.Length; i++) { Player p2 = Game.players[i]; if (p2.world == p.world) { p2.isScuba = waterPixel > 13; int layer = p2.y - p.y + 9; if (layer >= 0 && layer < layers.Length) { layers[layer].Add(new DrawUnit(p2.getSprite(), 72 + p2.x * 16 + p2.xOffset - p.x * 16 - p.xOffset, 64 + p2.y * 16 + p2.yOffset - p.y * 16 - p.yOffset)); if (waterPixel > 0 && waterPixel < 16) { layers[layer].Add(new DrawUnit(waterLevelSprites[waterPixel], 72 + p2.x * 16 + p2.xOffset - p.x * 16 - p.xOffset, 64 + p2.y * 16 + p2.yOffset - p.y * 16 - p.yOffset)); } } } } List <Entity> entities = p.world.entities; for (int i = 0; i < entities.Count; i++) { Entity e = entities[i]; int layer = e.y - p.y + 9; if (layer >= 0 && layer < layers.Length) { layers[layer].Add(new DrawUnit(e.getSprite(), 72 + 16 * e.x - p.x * 16 - p.xOffset + e.xOffset, 64 + 16 * e.y - p.y * 16 - p.yOffset + e.yOffset)); } } for (int x = p.x - 7; x <= p.x + 7; x++) { for (int y = p.y - 5; y <= p.y + 6; y++) { int block = p.world.getBlockAt(x, y); if (block == 0) { if (!p.world.isInside(x, y) || y == 0) { continue; } int t = p.world.getTileAt(x, y); if (p.world.getTileAt(x, y) != 0 && waterPixel < 16 && waterPixel != 0 && t != (int)Block.UpStairs && t != (int)Block.DownStairs) { //TODO draw various water levels Sprite s = waterSprites[(waterPixel)]; if (s != null) { layers[y - p.y + 8].Add(new DrawUnit(s, 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); } } } else { Sprite s = tileSprites[block]; if (s != null) { layers[y - p.y + 8].Add(new DrawUnit(s, 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); } if (waterPixel > 0 && waterPixel < 16) { if (BlockData.canHaveWater(block)) { layers[y - p.y + 8].Add(new DrawUnit(waterLevelSprites[waterPixel], 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); } /* * int block2 = p.world.getBlockAt(x, y + 1); * if (block < 512) * { * int block3 = p.world.getBlockAt(x, y - 1); * if (block2 == 0&&(block3==0||block3>=512)) * layers[y - p.y + 9].Add(new DrawUnit(waterLevelSprites[waterPixel], 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); * } else if(block2<512) * { * layers[y - p.y + 9].Add(new DrawUnit(waterLevelSprites[waterPixel], 72 - p.xOffset + 16 * (x - p.x), 64 - p.yOffset + 16 * (y - p.y))); * }*/ } } } } } for (int i = 0; i < layers.Length; i++) { foreach (DrawUnit d in layers[i]) { Sprite s = d.sprite; s.draw(g, d.x, d.y); } } if (waterPixel == 16) { SolidBrush sb = new SolidBrush(Color.FromArgb(128, Color.DarkBlue)); g.FillRectangle(sb, 0, 0, 200, 144); } if (p.isScuba) { for (int i = 0; i < 8 * p.breath / Player.MAX_BREATH; i++) { bubble.draw(g, 2 + i * 10, 2); } } }