예제 #1
0
 public override object Clone()
 {
     Door d = new Door(open, closed);
     d.X = X;
     d.Y = Y;
     d.Z = Z;
     return d;
 }
예제 #2
0
        public void Use(Player p, string[] args)
        {
            if (doory == null)
            {
                Door door = new Door(Block.NameToBlock(args[0]), Block.NameToBlock(args[1]));
                doory = door;
            }
            if (args.Length == 0) { Help(p); return; }
            if (!p.ExtraData.ContainsKey("Door"))
            {
                p.ExtraData.Add("Door", false);
            }

            if (!(bool)p.ExtraData["Door"])
            {
                Block b = Block.NameToBlock(args[0]);
                Block b1 = Block.NameToBlock(args[1]);
                if (b is UNKNOWN || b1 is UNKNOWN)
                {
                    p.SendMessage("Cannot find block \"" + args[0] + "\"!");
                    return;
                }
                PhysicsBlock.Add(doory);
                if (b.Permission > p.Group.Permission || b1.Permission > p.Group.Permission)
                {
                    p.SendMessage("Cannot place " + StringUtils.TitleCase(b.Name) + "!");
                    return;
                }

                p.ExtraData["Door"] = true;
                if (!p.ExtraData.ContainsKey("BlockDoor"))
                    p.ExtraData.Add("BlockDoor", b);
                p.SendMessage("&b" + StringUtils.TitleCase(b.Name) + Server.DefaultColor + " door mode &9on");
                p.OnPlayerBlockChange.Normal += OnPlayerBlockChangeOnNormal;
                return;
            }
            else
            {
                if (args[0] != ((Block)p.ExtraData["BlockDoor"]).Name)
                {
                    if (doory == null)
                    {
                        Door door = new Door(Block.NameToBlock(args[0]), Block.NameToBlock(args[1]));
                        doory = door;
                    }
                    Block b = Block.NameToBlock(args[0]);
                    Block b1 = Block.NameToBlock(args[1]);
                    if (b is UNKNOWN || b1 is UNKNOWN)
                    {
                        p.SendMessage("Cannot find block \"" + args[0] + "\"!");
                        return;
                    }
                    if (b.Permission > p.Group.Permission || b1.Permission > p.Group.Permission)
                    {
                        p.SendMessage("Cannot place " + StringUtils.TitleCase(b.Name) + "!");
                        return;
                    }

                    p.ExtraData["Door"] = true;
                    p.ExtraData["BlockDoor"] = b;

                    p.SendMessage("&b" + StringUtils.TitleCase(b.Name) + Server.DefaultColor + " mode &9on");
                    return;
                }
                if (!p.ExtraData.ContainsKey("BlockMode"))
                    throw new Exception("No block set in block mode");

                Block prev = (Block)p.ExtraData["BlockMode"];
                p.OnPlayerBlockChange.Normal -= OnPlayerBlockChangeOnNormal;
                doory = null;
                p.SendMessage("&b" + StringUtils.TitleCase(prev.Name) + Server.DefaultColor + " mode &coff");
                p.ExtraData["Mode"] = false;
                p.ExtraData["BlockMode"] = null;
            }
        }