Esempio n. 1
0
        public static void OnSendIntoGame1v1(int _fromClient, Packet _packet)
        {
            Match1v1         m         = Server.match1v1Database.GetMatchByPlayer(Server.playerDatabase.GetPlayerById(_fromClient));
            List <Vector3>   spawns    = new List <Vector3>(Constants.team1Spawns);
            List <SpawnInfo> spawnInfo = new List <SpawnInfo>();

            int     team  = 0;
            int     n     = new Random().Next(0, spawns.Count - 1);
            Vector3 spawn = spawns[n];

            spawns.RemoveAt(n);
            spawnInfo.Add(new SpawnInfo(spawn, team, m.player1.username));

            spawns = new List <Vector3>(Constants.team2Spawns);
            team   = 1;
            n      = new Random().Next(0, spawns.Count - 1);
            spawn  = spawns[n];
            spawns.RemoveAt(n);
            spawnInfo.Add(new SpawnInfo(spawn, team, m.player2.username));

            VaccineSpawn v = new VaccineSpawn();
            SickSpawn    s = new SickSpawn();

            ServerSend.SpawnPlayer1v1(m.player1.id, spawnInfo, s, v);

            ServerSend.SpawnPlayer1v1(m.player2.id, spawnInfo, s, v);
        }
Esempio n. 2
0
        public static void OnSendIntoGame(int _fromClient, Packet _packet)
        {
            VaccineSpawn     v         = new VaccineSpawn();
            SickSpawn        s         = new SickSpawn();
            Match            m         = Server.matchDatabase.GetMatchByPlayer(Server.playerDatabase.GetPlayerById(_fromClient));
            List <Vector3>   spawns    = new List <Vector3>(Constants.team1Spawns);
            List <SpawnInfo> spawnInfo = new List <SpawnInfo>();

            foreach (Lobby l in m.team1)
            {
                foreach (Player p in l.GetPlayers())
                {
                    int     team  = 0;
                    int     n     = new Random().Next(0, spawns.Count - 1);
                    Vector3 spawn = spawns[n];
                    spawns.RemoveAt(n);
                    spawnInfo.Add(new SpawnInfo(spawn, team, p.username));
                }
            }

            spawns = new List <Vector3>(Constants.team2Spawns);
            foreach (Lobby l in m.team2)
            {
                foreach (Player p in l.GetPlayers())
                {
                    int     team  = 1;
                    int     n     = new Random().Next(0, spawns.Count - 1);
                    Vector3 spawn = spawns[n];
                    spawns.RemoveAt(n);
                    spawnInfo.Add(new SpawnInfo(spawn, team, p.username));
                }
            }

            foreach (Lobby l in m.team1)
            {
                foreach (Player p in l.GetPlayers())
                {
                    ServerSend.SpawnPlayer(p.id, spawnInfo, s, v);
                }
            }


            foreach (Lobby l in m.team2)
            {
                foreach (Player p in l.GetPlayers())
                {
                    ServerSend.SpawnPlayer(p.id, spawnInfo, s, v);
                }
            }
        }
Esempio n. 3
0
        public static void SpawnPlayer1v1(int _toClient, List <SpawnInfo> info, SickSpawn s, VaccineSpawn v)
        {
            using (Packet _packet = new Packet((int)ServerPackets.spawnPlayer1v1))
            {
                _packet.Write(v.finalPos);
                _packet.Write(s.finalPos);
                _packet.Write(s.finalRotation);
                foreach (SpawnInfo si in info)
                {
                    _packet.Write(si.username);
                    _packet.Write(si.team);
                    _packet.Write(si.spawn);
                }
                _packet.Write(_toClient);

                SendTCPData(_toClient, _packet);
            }
        }