Exemplo n.º 1
0
        private void chestroom(CommandArgs args)
        {
            Stopwatch sw      = Stopwatch.StartNew();
            int       X       = args.Player.TileX;
            int       Y       = args.Player.TileY;
            string    cmd     = args.Parameters.Count > 0 ? args.Parameters[0].ToLower() : "";
            int       offsetX = 0,
                      offsetY = 0;
            bool error        = false;

            if (cmd.Length != 2)
            {
                error = true;
            }
            for (int i = 0; i < cmd.Length; i++)
            {
                switch (cmd[i])
                {
                case 't':
                    offsetX -= -2;
                    break;

                case 'b':
                    offsetY -= Chestroom.RowHeight - 4;
                    break;

                case 'l':
                    offsetX -= 2;
                    break;

                case 'c':
                    offsetX -= (Chestroom.RowWidth - 2) / 2;
                    break;

                case 'r':
                    offsetX -= Chestroom.RowWidth - 4;
                    break;

                default:
                    error = true;
                    break;
                }
            }
            if (error)
            {
                args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /chestroom <tl/tr/bl/br/tc/bc>");
                args.Player.SendErrorMessage("t = top, l = left, r = right, b = bottom, c = center");
                args.Player.SendErrorMessage("This is where you will stand when the chestroom spawns.");
                return;
            }
            Chestroom chestRoom = new Chestroom(config.CustomRoom);

            args.Player.SendSuccessMessage("Creating Chestroom...");


            Task.Run(async() =>
            {
                bool success = await chestRoom.Build(args.Player, X + offsetX, Y + offsetY);

                if (success)
                {
                    sw.Stop();
                    Utils.informplayers();
                    args.Player.SendInfoMessage(string.Format("Chestroom created in {0} seconds. ({1} items in {2} chests)", sw.Elapsed.TotalSeconds, Chestroom.ItemIds.Length, Chestroom.MaxChests));
                }
            });
        }
Exemplo n.º 2
0
        private void chestroom(CommandArgs args)
        {
            Stopwatch sw = Stopwatch.StartNew();
            int X = args.Player.TileX;
            int Y = args.Player.TileY;
            string cmd = args.Parameters.Count > 0 ? args.Parameters[0].ToLower() : "";
            int offsetX = 0,
                offsetY = 0;
            bool error = false;
            if (cmd.Length != 2)
                error = true;
            for (int i = 0; i < cmd.Length; i++)
            {
                switch (cmd[i])
                {
                    case 't':
                        offsetX -= -2;
                        break;
                    case 'b':
                        offsetY -= Chestroom.RowHeight - 4;
                        break;
                    case 'l':
                        offsetX -= 2;
                        break;
                    case 'c':
                        offsetX -= (Chestroom.RowWidth - 2) / 2;
                        break;
                    case 'r':
                        offsetX -= Chestroom.RowWidth - 4;
                        break;
                    default:
                        error = true;
                        break;
                }
            }
            if (error)
            {
                args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /chestroom <tl/tr/bl/br/tc/bc>");
                args.Player.SendErrorMessage("t = top, l = left, r = right, b = bottom, c = center");
                args.Player.SendErrorMessage("This is where you will stand when the chestroom spawns.");
                return;
            }
            Chestroom chestRoom = new Chestroom(config.CustomRoom);
            args.Player.SendSuccessMessage("Creating Chestroom...");

            if (chestRoom.Build(args.Player, X + offsetX, Y + offsetY))
            {
                sw.Stop();
                Utils.informplayers();
                args.Player.SendInfoMessage(string.Format("Chestroom created in {0} seconds. ({1} items in {2} chests)", sw.Elapsed.TotalSeconds, Chestroom.ActualMaxItems, Chestroom.MaxChests));
            }
        }