Esempio n. 1
0
        /// <summary>
        /// Sends newly connected client data about players, monsters and items on the ground
        /// </summary>
        /// <param name="c"></param>
        private void InitNewPlayer(ServerClient client, byte[] rawData)
        {
            var data = Functions.GetData(rawData);

            client.Hero.Name  = data[0] as string;
            client.Hero.Class = (HeroClass)Convert.ToChar(data[1]);
            MobMap heroMap = (MobMap)Convert.ToChar(data[2]);

            TransferClient(client, heroMap);
            client.Hero.Position = new Vector3(0, 0, 0);
            //tell old players about new player and new player about old players
            foreach (var c in client.Room.Clients.Where(c1 => c1 != client))
            {
                client.SendAddPlayer(c.Hero);
                c.SendAddPlayer(client.Hero);
            }
            //send mob data
            foreach (Mob m in client.Room.Mobs)
            {
                client.SendNewMob(m);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Sends newly connected client data about players, monsters and items on the ground
 /// </summary>
 /// <param name="c"></param>
 private void InitNewPlayer(ServerClient client, byte[] rawData)
 {
     var data = Functions.GetData(rawData);
     client.Hero.Name = data[0] as string;
     client.Hero.Class = (HeroClass)Convert.ToChar(data[1]);
     MobMap heroMap = (MobMap)Convert.ToChar(data[2]);
     TransferClient(client, heroMap);
     client.Hero.Position = new Vector3(0, 0, 0);
     //tell old players about new player and new player about old players
     foreach (var c in client.Room.Clients.Where(c1 => c1 != client))
     {
         client.SendAddPlayer(c.Hero);
         c.SendAddPlayer(client.Hero);
     }
     //send mob data
     foreach (Mob m in client.Room.Mobs)
         client.SendNewMob(m);
 }