예제 #1
0
        public static void SpawnWorldItem(Client client, ItemSpawn item)
        {
            using (var packet = new PacketWriter(Operation.MatchWorldItemSpawn, CryptFlags.Encrypt))
            {
                packet.Write(1, 12);
                packet.Write((UInt16)item.ItemUid);
                packet.Write((UInt16)item.ItemId);
                packet.Write((UInt16)1);
                packet.Write((UInt16)item.Position.X);
                packet.Write((UInt16)item.Position.Y);
                packet.Write((UInt16)item.Position.Z);

                client.Send(packet);
            }
        }
예제 #2
0
        public static void LoadSpawns(string mapname, ref Map map)
        {
            XmlTextReader reader;
            if (Type.GetType("Mono.Runtime") == null)
                reader = new XmlTextReader("Maps\\" + mapname + "\\spawn.xml");
            else
                reader = new XmlTextReader("Maps/" + mapname + "/spawn.xml");

            var lastType = SpawnType.Solo;
            var p = new Position();
            var item = 0;
            double time = 0;

            string[] cords;
            while (reader.Read())
            {
                switch (reader.Name)
                {
                    case "GAMETYPE":
                        string name = reader.GetAttribute("id");

                        if (name != null && name.StartsWith("solo"))
                        {
                            lastType = SpawnType.Solo;
                        }
                        else if (name != null && name.StartsWith("team"))
                        {
                            lastType = SpawnType.Red;
                        }
                        break;

                    case "SPAWN":
                        p = new Position();
                        string curitem = reader.GetAttribute("item");
                        if (curitem == null)
                            continue;
                        time = int.Parse(reader.GetAttribute("timesec"));

                        if (curitem.Equals("bullet02"))
                        {
                            item = 8;
                        }
                        else if (curitem.StartsWith("hp02"))
                        {
                            item = 2;
                        }
                        else if (curitem.StartsWith("ap02"))
                        {
                            item = 5;
                        }
                        else if (curitem.StartsWith("hp03"))
                        {
                            item = 3;
                        }
                        else if (curitem.StartsWith("ap03"))
                        {
                            item = 6;
                        }
                        break;
                    case "POSITION":
                        cords = reader.ReadElementContentAsString().Split(' ');

                        p.X = float.Parse(cords[0]);
                        p.Y = float.Parse(cords[1]);
                        p.Z = float.Parse(cords[2]);
                        if (lastType == SpawnType.Solo)
                        {
                            var i = new ItemSpawn();
                            i.Position = p;
                            i.ItemId = item;
                            i.SpawnTime = (int)(time / 1000);
                            i.NextSpawn = DateTime.Now;
                            map.DeathMatchItems.Add(i);
                        }
                        else if (lastType == SpawnType.Red)
                        {
                            var i = new ItemSpawn();
                            i.Position = p;
                            i.ItemId = item;
                            i.SpawnTime = (int)(time / 1000);
                            i.NextSpawn = DateTime.Now;
                            map.TeamItems.Add(i);
                        }
                        break;
                }
            }
        }
예제 #3
0
        public static void ResponseSpawnWorldItem(Client client, PacketReader packet)
        {
            var charId = packet.ReadMuid();
            var itemId = packet.ReadInt32();
            var X = packet.ReadSingle();
            var Y = packet.ReadSingle();
            var Z = packet.ReadSingle();

            var spawn = new ItemSpawn();
            spawn.Position.X = X;
            spawn.Position.Y = Y;
            spawn.Position.Z = Z;
            spawn.ItemId = (ushort)itemId;
            spawn.Taken = false;
            spawn.ItemUid = client.GetStage().GetTraits().WorldItemUid;
            spawn.NextSpawn = DateTime.Now.AddMilliseconds(WorldItemManager.GetTime(itemId));

            Interlocked.Increment(ref client.GetStage().GetTraits().WorldItemUid);

            lock (client.GetStage().GetTraits().WorldItems)
                client.GetStage().GetTraits().WorldItems.Add(spawn);

            lock (client.GetStage().ObjectLock)
                Battle.SpawnWorldItem(client.GetStage().GetTraits().Players,
                                       spawn);
        }