Exemple #1
0
 public override bool interact(Player p)
 {
     toggled = !toggled;
     SoundSystem.play("lever");
     for (int i = 0; i < coords.Length; i++)
     {
         DoorEntity d = p.world.entityAt(coords[i].x, coords[i].y) as DoorEntity;
         if (d != null)
         {
             d.open = !d.open;
         }
     }
     return(true);
 }
Exemple #2
0
 void door(Player p, Entity e)
 {
     if (Player.items[(int)Player.Item.KeyCard])
     {
         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, "The keycard opened the door!"));
         SoundSystem.play("door");
     }
     else
     {
         p.pushState(new TextBox(p.getState(), p, "This door is locked."));
     }
 }
Exemple #3
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();
     }
 }
Exemple #4
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?"));
     }
 }
Exemple #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);
        }
Exemple #6
0
 public static void scienceMachine(Player p, Entity e)
 {
     SoundSystem.play("error");
 }
        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();
        }