Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
0
        public static void GameSpawn(List<Client> clients, Muid playerId, Position position, Direction direction)
        {
            using (var packet = new PacketWriter(Operation.GameResponseSpawn, CryptFlags.Encrypt))
            {
                packet.Write(playerId);
                packet.Write((UInt16)position.X);
                packet.Write((UInt16)position.Y);
                packet.Write((UInt16)position.Z);
                packet.Write((UInt16)(direction.X * 32000.0));
                packet.Write((UInt16)(direction.Y * 32000.0));
                packet.Write((UInt16)(direction.Z * 32000.0));

                clients.ForEach(c => c.Send(packet));
            }
        }
Exemplo n.º 3
0
        private Map LoadMap(string mapname)
        {
            Map map = new Map();
            XmlReader reader;
            if (Type.GetType("Mono.Runtime") == null)
                reader = new XmlTextReader("Maps\\" + mapname + "\\map.xml");
            else
                reader = new XmlTextReader("Maps/" + mapname + "/map.xml");

            SpawnType lastType = SpawnType.Solo;
            Position p = new Position();
            Direction d = new Direction();
            string[] cords;
            while (reader.Read())
            {
                switch (reader.Name)
                {
                    case "DUMMY":
                        p = new Position();
                        d = new Direction();
                        string name = reader.GetAttribute("name");

                        if (name != null && name.StartsWith("spawn_solo"))
                        {
                            lastType = SpawnType.Solo;
                        }
                        else if (name != null && name.StartsWith("spawn_team1"))
                        {
                            lastType = SpawnType.Red;
                        }
                        else if (name != null && name.StartsWith("spawn_team2"))
                        {
                            lastType = SpawnType.Blue;
                        }
                        else if (name != null && name.StartsWith("wait_"))
                        {
                            lastType = SpawnType.Wait;
                        }
                        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]);
                        break;
                    case "DIRECTION":
                        cords = reader.ReadElementContentAsString().Split(' ');

                        d.X = float.Parse(cords[0]);
                        d.Y = float.Parse(cords[1]);
                        d.Z = float.Parse(cords[2]);

                        if (lastType == SpawnType.Solo)
                        {
                            map.Deathmatch.Add(new Pair<Position, Direction>(p, d));
                        }
                        else if (lastType == SpawnType.Red)
                        {
                            map.TeamRed.Add(new Pair<Position, Direction>(p, d));
                        }
                        else if (lastType == SpawnType.Blue)
                        {
                            map.TeamBlue.Add(new Pair<Position, Direction>(p, d));
                        }
                        break;
                }
            }
            return map;
        }
Exemplo n.º 4
0
        public static void ProcessGameSpawn(Client client, PacketReader packetReader)
        {
            var uid = packetReader.ReadUInt64();
            var xpos = packetReader.ReadSingle();
            var ypos = packetReader.ReadSingle();
            var zpos = packetReader.ReadSingle();
            var xdir = packetReader.ReadSingle();
            var ydir = packetReader.ReadSingle();
            var zdir = packetReader.ReadSingle();

            if (client.GetStage() != null)
            {
                var traits = client.GetStage().GetTraits();

                if (traits.Ruleset.IsDuel())
                {
                    if (traits.DuelQueue.Challenger != client && traits.DuelQueue.Champion != client)
                        return;
                }
                if (traits.Ruleset.IsTeam())
                    return;

                var position = new Position();
                var direction = new Direction();

                position.X = xpos;
                position.Y = ypos;
                position.Z = zpos;

                direction.X = xdir;
                direction.Y = ydir;
                direction.Z = zdir;
                lock (client.GetStage().ObjectLock)
                {
                    Battle.GameSpawn(client.GetStage().GetTraits().Players, client.GetMuid(),
                                     position, direction);
                }
            }
        }