Esempio n. 1
0
 public override void run(Player p)
 {
     if (Map2.passId == -1)
     {
         p.popState();
         p.pushState(new TextBox(p.getState(), p, "So much work for a password."));
         return;
     }
     if (flags[0] == -2)
     {
         p.pushState(new KeyboardDialogue(this, "Password:"******"poster",
             "11",
             "password1"
         };
         if (s.ToLower() == choices[Map2.passId])
         {
             Map2.passId = -1;
             World w = p.world;
             w.editing = true;
             w.setBlockAt(12, 1, 0);
             w.setBlockAt(12, 2, 0);
             w.editing = false;
             w.entityAt(12, 1).forceRemove();
             w.entityAt(12, 2).forceRemove();
             SoundSystem.play("door");
         }
         p.popState();
     }
 }
Esempio n. 2
0
 void boardedDoor(Player p, Entity e)
 {
     if (Player.items[(int)Player.Item.HammerHandle] && Player.items[(int)Player.Item.HammerHead])
     {
         if (Player.items[(int)Player.Item.DuctTape])
         {
             p.world.editing = true;
             p.world.setBlockAt(e.x, e.y, 0);
             p.world.editing = false;
             e.forceRemove();
             p.pushState(new TextBox(p.getState(), p, "Somehow you fix a hammer and use it to pry open the door. Not even you are sure how you managed that."));
             SoundSystem.play("door");
         }
         else
         {
             p.pushState(new TextBox(p.getState(), p, "You have the hammer parts, but nothing to keep them together."));
         }
     }
     else
     {
         p.pushState(new TextBox(p.getState(), p, "The door is boarded shut. Maybe you can find something to pry the boards off?"));
     }
 }
Esempio n. 3
0
 public EndState(Player p) : base(p)
 {
     SoundSystem.setBackgroundMusic("emergency");
 }
Esempio n. 4
0
 public DeathState(Player p, string message) : base(p)
 {
     this.message = message;
     p.pushState(new TextBox(this, p, message));
     SoundSystem.setBackgroundMusic("emergency");
 }
Esempio n. 5
0
        public override bool interact(Player p)
        {
            if (xOffset != 0 || yOffset != 0)
            {
                return(false);
            }
            int x = this.x;
            int y = this.y;

            switch (p.dir)
            {
            case 0: x++; break;

            case 1: y--; break;

            case 2: x--; break;

            case 3: y++; break;
            }
            if (world.entityAt(x, y) == null)
            {
                if (world.getBlockAt(x, y) == 0 && world.getTileAt(x, y) != 0)
                {
                    WorldState w = p.getState() as WorldState;
                    if (w == null)
                    {
                        return(false);
                    }
                    if (w.getWaterPixel() > 0)
                    {
                        switch (p.dir)
                        {
                        case 0:
                            this.x++;
                            xOffset = -15;
                            break;

                        case 1:
                            this.y--;
                            yOffset = 15;
                            break;

                        case 2:
                            this.x--;
                            xOffset = 15;
                            break;

                        case 3:
                            this.y++;
                            yOffset = -15;
                            break;
                        }
                        SoundSystem.play("box move");
                    }
                    else
                    {
                        p.pushState(new TextBox(w, p, "A large box. You wonder if it would float."));
                    }
                }
            }
            return(true);
        }
Esempio n. 6
0
 public static void scienceMachine(Player p, Entity e)
 {
     SoundSystem.play("error");
 }
Esempio n. 7
0
        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--;
            }
        }
Esempio n. 8
0
        public override void run(Player p)
        {
            startMenu();
            int waterPixel = getWaterPixel();

            if (p.xOffset == 0 && p.yOffset == 0 && p.wait == 0) //if the player is ready to move again
            {
                {
                    Block b = (Block)p.world.getTileAt(p.x, p.y);
                    if (b == Block.UpStairs)
                    {
                        if (stairCount < 3)
                        {
                            SoundSystem.play("stairs");
                            stairCount++;
                        }
                        if (p.worldID == 3)
                        {
                            p.dir = 3;
                            p.level--;
                            p.worldID--;
                            p.x       = 6;
                            p.y       = 1;
                            p.yOffset = WALK_SPEED - 16;
                        }
                        else
                        {
                            if (p.worldID == 1)
                            {
                                p.y--;
                            }
                            p.dir = 2;
                            p.level--;
                            p.x--; p.xOffset = 16 - WALK_SPEED;
                            p.worldID--;
                        }
                        return;
                    }
                    if (b == Block.DownStairs)
                    {
                        if (stairCount < 3)
                        {
                            SoundSystem.play("stairs");
                            stairCount++;
                        }
                        if (p.worldID == 2)
                        {
                            p.level++;
                            p.x = 6;
                            p.y = 1;
                            p.worldID++;
                            p.yOffset = WALK_SPEED - 16;
                            p.dir     = 3;
                        }
                        else
                        {
                            p.level++;
                            p.x--;
                            if (p.worldID == 0)
                            {
                                p.y++;
                            }
                            p.xOffset = 16 - WALK_SPEED;
                            p.dir     = 2;
                            p.worldID++;
                        }
                        return;
                    }
                }
                if (pKeyLeft)
                {
                    if (p.dir == 2)
                    {
                        if (canMove(p, p.x - 1, p.y))
                        {
                            p.x--;
                            p.xOffset = 16 - WALK_SPEED;
                            if (waterPixel == 0)
                            {
                                SoundSystem.play("footsteps");
                            }
                            else if (waterPixel < 16)
                            {
                                SoundSystem.play("water");
                            }
                        }
                    }
                    else
                    {
                        p.dir  = 2;
                        p.wait = WAIT;
                    }
                }
                else
                if (pKeyRight)
                {
                    if (p.dir == 0)
                    {
                        if (canMove(p, p.x + 1, p.y))
                        {
                            p.x++;
                            p.xOffset = WALK_SPEED - 16;
                            if (waterPixel == 0)
                            {
                                SoundSystem.play("footsteps");
                            }
                            else if (waterPixel < 16)
                            {
                                SoundSystem.play("water");
                            }
                        }
                    }
                    else
                    {
                        p.dir  = 0;
                        p.wait = WAIT;
                    }
                }
                else
                if (pKeyUp)
                {
                    if (p.dir == 1)
                    {
                        if (canMove(p, p.x, p.y - 1))
                        {
                            p.y--;
                            p.yOffset = 16 - WALK_SPEED;
                            if (waterPixel == 0)
                            {
                                SoundSystem.play("footsteps");
                            }
                            else if (waterPixel < 16)
                            {
                                SoundSystem.play("water");
                            }
                        }
                    }
                    else
                    {
                        p.dir  = 1;
                        p.wait = WAIT;
                    }
                }
                else
                if (pKeyDown)
                {
                    if (p.dir == 3)
                    {
                        if (canMove(p, p.x, p.y + 1))
                        {
                            p.y++;
                            p.yOffset = WALK_SPEED - 16;
                            if (waterPixel == 0)
                            {
                                SoundSystem.play("footsteps");
                            }
                            else if (waterPixel < 16)
                            {
                                SoundSystem.play("water");
                            }
                        }
                    }
                    else
                    {
                        p.dir  = 3;
                        p.wait = WAIT;
                    }
                }
                if (pKeyA && !keyA)
                {
                    int x = p.x;
                    int y = p.y;
                    switch (p.dir)
                    {
                    case 0: x++; break;

                    case 1: y--; break;

                    case 2: x--; break;

                    case 3: y++; break;
                    }
                    Entity e = p.world.entityAt(x, y);
                    if (e != null)
                    {
                        e.interact(p);
                    }
                }
            }
            else
            {
                //slides the player into the grid, will need to be modified if we want to stray from a grid based system
                if (p.xOffset > 0)
                {
                    p.xOffset -= WALK_SPEED;
                }
                if (p.xOffset < 0)
                {
                    p.xOffset += WALK_SPEED;
                }
                if (Math.Abs(p.xOffset) < WALK_SPEED)
                {
                    p.xOffset = 0;
                }
                if (p.yOffset > 0)
                {
                    p.yOffset -= WALK_SPEED;
                }
                if (p.yOffset < 0)
                {
                    p.yOffset += WALK_SPEED;
                }
                if (Math.Abs(p.yOffset) < WALK_SPEED)
                {
                    p.yOffset = 0;
                }
                if (p.wait > 0)
                {
                    p.wait--;
                }
            }
            if (p.xOffset == 0 && p.yOffset == 0 && p.getState() == this)
            {
                Entity e = p.world.entityAt(p.x, p.y);
                if (e != null)
                {
                    e.onStepOn(p);
                }
            }
            endMenu();
        }
Esempio n. 9
0
        //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);
                }
            }
        }