コード例 #1
0
        public void OnDrop()
        {
            var pair = Rt.Get(1);

            if (pair.Values.Count == 2 && pair.Value == "itemID")
            {
                if (int.TryParse(pair.Values[1], out var id))
                {
                    int x = (int)(Player.Pos.X + (Player.RotatingLeft ? -32 : 32)) / 32, y = (int)(Player.Pos.Y) / 32;

                    if (World.Blocks[x + y * World.Width].Fg.CollisionType == 1)
                    {
                        Player.SendTextOverlay("You can't drop that here, face somewhere with open space.");
                        Player.SendSound("cant_place_tile");
                        return;
                    }

                    if (Player.Inventory.Find(id, out var amount))
                    {
                        DialogBuilder db = new DialogBuilder();
                        db.SetDefaultColor()
                        .AddLabelWithIcon($"`wDrop {Tile.Parse(id).Name}``", id, false)
                        .AddTextBox("How many to drop?")
                        .AddTextInput("count", "", amount.ToString(), 5)
                        .AddEmbedData("itemID", id)
                        .EndDialog("drop", "Cancel", "OK");

                        Player.SendDialog(db);
                    }
                    else
                    {
                        Player.Disconnect();
                    }
                }
                else
                {
                    Player.Disconnect();
                }
            }
            else
            {
                Player.Disconnect();
            }
        }
コード例 #2
0
        public void OnGuestLogin()
        {
            if (Rt.TryGet("requestedName", out var requestedName))
            {
                Player.RequestedName = requestedName;

                DialogBuilder db = new DialogBuilder();

                db.SetDefaultColor()
                .AddBigLabel("Create account")
                .AddSmallSpacer()
                .AddTextInput("username", "Username:"******"", 15)
                .AddTextInput("password", "Password:"******"", 15)
                .AddSmallSpacer()
                .EndDialog("account", "", "OK");

                Player.SendDialog(db);
            }
        }