Exemple #1
0
        private void SpawnMenu()
        {
            int x      = 80;
            int y      = 180;
            int width  = 300;
            int height = 106;

            if (!initMenu)
            {
                label = new string[]
                {
                    "ID",
                    "Life",
                    "Defense",
                    "Damage",
                    "KB Resist"
                };
                box   = new Rectangle(x - 10, y, width + 164, height);
                input = new TextBox[]
                {
                    new TextBox(new Rectangle(x + 100, y + 4, width - 20, 18)),
                    new TextBox(new Rectangle(x + 100, y + 24, width - 20, 18)),
                    new TextBox(new Rectangle(x + 100, y + 44, width - 20, 18)),
                    new TextBox(new Rectangle(x + 100, y + 64, width - 20, 18)),
                    new TextBox(new Rectangle(x + 100, y + 84, width - 20, 18))
                };
                button = new Button[]
                {
                    new Button("Spawn", new Rectangle(x + width + 90, y + 4, 60, 18)),
                    new Button("Clear", new Rectangle(x + width + 90, y + 34, 60, 18))
                };
                initMenu = true;
            }
            sb.Draw(Main.magicPixel, box, Color.Black * 0.25f);
            for (int n = 0; n < label.Length; n++)
            {
                sb.DrawString(Main.fontMouseText, label[n], new Vector2(x - 6, y + 4 + n * 20), Color.White * 0.9f);
            }
            foreach (TextBox t in input)
            {
                if (t.box.Contains(Main.MouseScreen.ToPoint()) && LeftClick())
                {
                    foreach (var i in input)
                    {
                        i.active = false;
                    }
                    t.active = true;
                }
                if (t.active)
                {
                    t.UpdateInput();
                }
                t.DrawText();
            }
            foreach (Button b in button)
            {
                if (b.LeftClick())
                {
                    if (b.text == "Clear")
                    {
                        foreach (var t in input)
                        {
                            t.text   = "";
                            t.active = false;
                        }
                    }
                    else if (b.text == "Spawn")
                    {
                        float[] vars = new float[5];
                        for (int i = 0; i < input.Length; i++)
                        {
                            float.TryParse(input[i].text, out vars[i]);
                        }
                        float randX = Main.rand.NextFloat(player.position.X - 300, player.position.X + 300);
                        float Y     = player.position.Y - 100;
                        if (Main.netMode != 0)
                        {
                            NetHandler.Send(Packet.SpawnNPC, -1, -1, (int)vars[0], vars[1], vars[2], (int)vars[3], false, vars[4], Main.MouseWorld.X, Main.MouseWorld.Y);
                        }
                        else
                        {
                            int n = NPC.NewNPC((int)randX, (int)Y, (int)vars[0], 0);
                            Main.npc[n].lifeMax         = (int)vars[1];
                            Main.npc[n].life            = (int)vars[1];
                            Main.npc[n].defense         = (int)vars[2];
                            Main.npc[n].damage          = (int)vars[3];
                            Main.npc[n].knockBackResist = vars[4];
                        }
                    }
                }
                b.Draw();
            }
        }
Exemple #2
0
 public override void HandlePacket(BinaryReader reader, int whoAmI)
 {
     NetHandler.Receive(reader);
 }
Exemple #3
0
        public override void PreUpdate()
        {
            Color textColor = Color.Yellow;

            //  ITEM TEXT and SKY FORT DEBUG GEN
            if (!start && !Main.dedServ && KeyPress(Keys.F1) && KeyHold(Keys.Up))
            {
                if (Main.netMode == 0)
                {
                    Main.NewText("To enter commands, input [Tab + (Hold) Left Control] (instead of Enter), [F2 + LeftControl] for item spawning using chat search via item name, [F3 + LeftControl] for NPC debug and balancing", Color.LightBlue);
                    Main.NewText("Commands: /list 'npcs' 'items1' 'items2' 'items3', /npc [name], /npc 'strike', /item [name], /spawn, /day, /night, /rain 'off' 'on', hold [Left Control + Left Alt] and click to go to mouse", textColor);
                }
                if (Main.netMode == 2)
                {
                    NetMessage.BroadcastChatMessage(NetworkText.FromLiteral("Input /info and use [Tab] to list commands"), textColor);
                }
                start = true;
            }
            if (KeyHold(Keys.LeftAlt))
            {
                if (KeyPress(Keys.LeftControl))
                {
                    //SkyHall hall = new SkyHall();
                    //hall.SkyFortGen();

                    /*
                     * Vector2 position;
                     * do
                     * {
                     *  position = new Vector2(WorldGen.genRand.Next(200, Main.maxTilesX - 200), 50);
                     * } while (position.X < Main.spawnTileX + 150 && position.X > Main.spawnTileX - 150);
                     * var s = new Structures(position, ArchaeaWorld.skyBrick, ArchaeaWorld.skyBrickWall);
                     * s.InitializeFort();
                     */
                    if (Main.netMode == 0)
                    {
                        for (int i = 0; i < Main.rightWorld / 16; i++)
                        {
                            for (int j = 0; j < Main.bottomWorld / 16; j++)
                            {
                                Main.mapInit    = true;
                                Main.loadMap    = true;
                                Main.refreshMap = true;
                                Main.updateMap  = true;
                                Main.Map.Update(i, j, 255);
                                Main.Map.ConsumeUpdate(i, j);
                            }
                        }
                    }
                }
            }
            if (KeyHold(Keys.LeftControl) && KeyHold(Keys.LeftAlt) && LeftClick())
            {
                if (Main.netMode == 2)
                {
                    NetHandler.Send(Packet.TeleportPlayer, -1, -1, player.whoAmI, Main.MouseWorld.X, Main.MouseWorld.Y);
                }
                else
                {
                    player.Teleport(Main.MouseWorld);
                }
            }
            string chat           = (string)Main.chatText.Clone();
            bool   enteredCommand = KeyPress(Keys.Tab);

            if (chat.StartsWith("/info") && KeyHold(Keys.LeftControl))
            {
                if (enteredCommand)
                {
                    if (Main.netMode != 2)
                    {
                        Main.NewText("Commands: /list 'npcs' 'items1' 'items2' 'items3', /npc [name], /npc 'strike', /item [name], /spawn, /day, /night, /rain 'off' 'on', hold Left Control and click to go to mouse", textColor);
                        Main.NewText("Press [F2] and type an item name in chat, then hover over item icon", textColor);
                        Main.NewText("[F3] for NPC debug and balancing", textColor);
                    }
                }
            }
            if (chat.StartsWith("/") && KeyHold(Keys.LeftControl))
            {
                if (chat.StartsWith("/list"))
                {
                    string[] npcs = new string[]
                    {
                        "Fanatic",
                        "Hatchling_head",
                        "Mimic",
                        "Sky_1",
                        "Sky_2",
                        "Sky_3",
                        "Slime_Itchy",
                        "Slime_Mercurial",
                        "Magnoliac_head",
                        "Sky_boss",
                        "Sky_boss_legacy"
                    };
                    string[] items1 = new string[]
                    {
                        "cinnabar_bow",
                        "cinnabar_dagger",
                        "cinnabar_hamaxe",
                        "cinnabar_pickaxe",
                        "magno_Book",
                        "magno_summonstaff",
                        "magno_treasurebag",
                        "magno_trophy",
                        "magno_yoyo"
                    };
                    string[] items2 = new string[]
                    {
                        "c_Staff",
                        "c_Sword",
                        "n_Staff",
                        "r_Catcher",
                        "r_Flail",
                        "r_Javelin",
                        "r_Tomohawk",
                        "ShockLegs",
                        "ShockMask",
                        "ShockPlate"
                    };
                    string[] items3 = new string[]
                    {
                        "Broadsword",
                        "Calling",
                        "Deflector",
                        "Sabre",
                        "Staff"
                    };
                    if (chat.Contains("npcs"))
                    {
                        if (enteredCommand)
                        {
                            foreach (string s in npcs)
                            {
                                Main.NewText(s + " " + mod.NPCType(s), textColor);
                            }
                        }
                    }
                    if (chat.Contains("items1"))
                    {
                        if (enteredCommand)
                        {
                            foreach (string s in items1)
                            {
                                Main.NewText(s, textColor);
                            }
                        }
                    }
                    if (chat.Contains("items2"))
                    {
                        if (enteredCommand)
                        {
                            foreach (string s in items2)
                            {
                                Main.NewText(s, textColor);
                            }
                        }
                    }
                    if (chat.Contains("items3"))
                    {
                        if (enteredCommand)
                        {
                            foreach (string s in items3)
                            {
                                Main.NewText(s, textColor);
                            }
                        }
                    }
                }
                if (chat.StartsWith("/npc"))
                {
                    string text = Main.chatText.Substring(Main.chatText.IndexOf(' ') + 1);
                    if (!chat.Contains("strike"))
                    {
                        if (enteredCommand)
                        {
                            NPC n = mod.GetNPC(text).npc;
                            if (Main.netMode != 0)
                            {
                                NetHandler.Send(Packet.SpawnNPC, 256, -1, n.type, Main.MouseWorld.X, Main.MouseWorld.Y, player.whoAmI, n.boss);
                            }
                            else
                            {
                                if (n.boss)
                                {
                                    NPC.SpawnOnPlayer(player.whoAmI, n.type);
                                }
                                else
                                {
                                    NPC.NewNPC((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, n.type);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (enteredCommand)
                        {
                            foreach (NPC npc in Main.npc)
                            {
                                if (npc.active && !npc.friendly && npc.life > 0)
                                {
                                    npc.StrikeNPC(npc.lifeMax, 0f, 1, true);
                                    if (Main.netMode != 0)
                                    {
                                        NetMessage.SendData(MessageID.StrikeNPC, -1, -1, null, npc.whoAmI);
                                    }
                                }
                            }
                        }
                    }
                }
                if (chat.StartsWith("/item"))
                {
                    string text = Main.chatText;
                    if (enteredCommand)
                    {
                        string itemType   = text.Substring("/item ".Length);
                        string stackCount = "";
                        if (itemType.Count(t => t == ' ') != 0)
                        {
                            stackCount = itemType.Substring(text.LastIndexOf(' ') + 1);
                        }
                        bool modded = false;
                        int  type;
                        int  stack = 0;
                        int.TryParse(stackCount, out stack);
                        if (modded = !int.TryParse(itemType, out type))
                        {
                            type = mod.ItemType(itemType);
                        }
                        if (modded)
                        {
                            int t = Item.NewItem(Main.MouseWorld, type, mod.GetItem(itemType).item.maxStack);
                            if (Main.netMode != 0)
                            {
                                NetMessage.SendData(MessageID.SyncItem, -1, -1, null, t);
                            }
                        }
                        else
                        {
                            int.TryParse(stackCount, out stack);
                            int t2 = Item.NewItem(Main.MouseWorld, type, stack == 0 ? 1 : stack);
                            if (Main.netMode != 0)
                            {
                                NetMessage.SendData(MessageID.SyncItem, -1, -1, null, t2);
                            }
                        }
                    }
                }
                if (chat.StartsWith("/spawn"))
                {
                    if (enteredCommand)
                    {
                        if (Main.netMode != 0)
                        {
                            NetHandler.Send(Packet.TeleportPlayer, 256, -1, Main.LocalPlayer.whoAmI, Main.spawnTileX * 16, Main.spawnTileY * 16);
                        }
                        else
                        {
                            player.Teleport(new Vector2(Main.spawnTileX * 16, Main.spawnTileY * 16));
                        }
                    }
                }
                if (chat.StartsWith("/day"))
                {
                    if (enteredCommand)
                    {
                        float time = 10f * 60f * 60f / 2f;
                        if (Main.netMode == 0)
                        {
                            Main.dayTime = true;
                            Main.time    = time;
                        }
                        else
                        {
                            NetHandler.Send(Packet.WorldTime, 256, -1, 0, time, 0f, 0, true);
                        }
                    }
                }
                if (chat.StartsWith("/night"))
                {
                    if (enteredCommand)
                    {
                        float time = 8f * 60f * 60f / 2f;
                        if (Main.netMode == 0)
                        {
                            Main.dayTime = false;
                            Main.time    = time;
                        }
                        else
                        {
                            NetHandler.Send(Packet.WorldTime, 256, -1, 0, time, 0f, 0, false);
                        }
                    }
                }
                if (chat.StartsWith("/rain"))
                {
                    if (chat.Contains("off"))
                    {
                        if (enteredCommand)
                        {
                            Main.raining = false;
                        }
                    }
                    if (chat.Contains("on"))
                    {
                        if (enteredCommand)
                        {
                            Main.raining = true;
                        }
                    }
                }
            }
            if (enteredCommand)
            {
                Main.chatText          = string.Empty;
                Main.drawingPlayerChat = false;
                Main.chatRelease       = false;
            }
            if (KeyPress(Keys.F2) && KeyHold(Keys.LeftControl))
            {
                if (Main.netMode == 1)
                {
                    NetHandler.Send(Packet.Debug, 256, -1, player.whoAmI);
                }
                else
                {
                    debugMenu = !debugMenu;
                }
            }
            if (KeyPress(Keys.F3) && KeyHold(Keys.LeftControl))
            {
                if (Main.netMode == 1)
                {
                    NetHandler.Send(Packet.Debug, 256, -1, player.whoAmI, 1f);
                }
                else
                {
                    spawnMenu = !spawnMenu;
                }
            }
        }