Example #1
0
        private void TurnCreation(byte[] data, EndPoint sender)
        {
            uint       clientId = BitConverter.ToUInt32(data, 1);
            GameClient client   = GetClientFromID(clientId);

            uint       roomId = BitConverter.ToUInt32(data, 5);
            ServerRoom room   = GetRoomFromID(roomId);

            if (!room.GetClientTable().Contains(client))
            {
                client.UpdateMalus();
                return;
            }

            uint heroId = BitConverter.ToUInt32(data, 9);

            if (!room.GetGameObjectTable().ContainsKey(heroId))
            {
                client.UpdateMalus();
                return;
            }

            RPGHero hero = (RPGHero)room.GetGameObjectFromId(heroId);

            room.AddNewTurn(hero);
        }
Example #2
0
 public void SendToAllClientsInARoom(Packet packet, ServerRoom room)
 {
     //room.Player1.Enqueue(packet);
     //room.Player2.Enqueue(packet);
     foreach (GameClient client in room.GetClientTable())
     {
         client.Enqueue(packet);
         Console.WriteLine("Send");
     }
 }
Example #3
0
        private void EndTurn(byte[] data, EndPoint sender)
        {
            uint       clientId = BitConverter.ToUInt32(data, 1);
            GameClient client   = GetClientFromID(clientId);

            uint       roomId = BitConverter.ToUInt32(data, 5);
            ServerRoom room   = GetRoomFromID(roomId);

            if (!room.GetClientTable().Contains(client))
            {
                client.UpdateMalus();
                return;
            }
            room.SetPlayerEndTurn(client);
        }
Example #4
0
        private void Ready(byte[] data, EndPoint sender)
        {
            uint       clientId      = BitConverter.ToUInt32(data, 1);
            GameClient client        = GetClientFromID(clientId);
            uint       roomId        = BitConverter.ToUInt32(data, 5);
            bool       isClientReady = BitConverter.ToBoolean(data, 9);

            Console.WriteLine(isClientReady);
            ServerRoom room = GetRoomFromID(roomId);

            if (room != null && room.GetClientTable().Contains(client))
            {
                room.SetPlayersReady(client, isClientReady);
            }
        }
Example #5
0
 public void SendToOtherClientsInARoom(Packet packet, ServerRoom room, GameClient sender = null)
 {
     /*
      * if (sender != room.Player1 && room.Player1 != null)
      *  room.Player1.Enqueue(packet);
      * else if (sender != room.Player2 && room.Player2 != null)
      *  room.Player2.Enqueue(packet);
      */
     foreach (GameClient client in room.GetClientTable())
     {
         if (client != null && client != sender)
         {
             client.Enqueue(packet);
             Console.WriteLine("Send");
         }
     }
 }
Example #6
0
        private void Spawn(byte[] data, EndPoint sender)
        {
            //2[0], myIdOnServer[1], serverRoomId[5], classIndex[9], x[13], y[17], z[21]
            uint       clientId = BitConverter.ToUInt32(data, 1);
            GameClient client   = GetClientFromID(clientId);

            uint       roomId = BitConverter.ToUInt32(data, 5);
            ServerRoom room   = GetRoomFromID(roomId);

            if (!room.GetClientTable().Contains(client))
            {
                client.UpdateMalus();
                return;
            }

            RPGHero newHero = SpawnHero(roomId);

            newHero.SetOwner(client);

            uint classId = BitConverter.ToUInt32(data, 9);

            newHero.SetInGameValues(classId, "");
            float x = BitConverter.ToSingle(data, 13);
            float y = BitConverter.ToSingle(data, 17);
            float z = BitConverter.ToSingle(data, 21);

            newHero.SetPosition(x, y, z);

            //byte[] name = new byte[12];
            //for (int i = 0; i < name.Length; i++)
            //{
            //    name[i] = data[25 + i];
            //}
            //string heroName = System.Text.Encoding.UTF8.GetString(name);
            //Console.WriteLine(heroName);

            Console.WriteLine("Spaned Object {0}", room.GetGameObjectTable().Count);
        }
Example #7
0
        private void SetTurnParameter(byte[] data, EndPoint sender)
        {
            uint       clientId = BitConverter.ToUInt32(data, 1);
            GameClient client   = GetClientFromID(clientId);

            uint       roomId = BitConverter.ToUInt32(data, 5);
            ServerRoom room   = GetRoomFromID(roomId);

            if (!room.GetClientTable().Contains(client))
            {
                client.UpdateMalus();
                return;
            }

            uint heroId = BitConverter.ToUInt32(data, 9);

            if (!room.GetGameObjectTable().ContainsKey(heroId))
            {
                client.UpdateMalus();
                return;
            }

            RPGHero hero = (RPGHero)room.GetGameObjectFromId(heroId);

            int     skillId  = BitConverter.ToInt32(data, 13);
            uint    targetId = BitConverter.ToUInt32(data, 17);
            RPGHero target   = null;

            if (targetId != 172)
            {
                target = (RPGHero)room.GetGameObjectFromId(targetId);
            }

            Console.WriteLine("Attacker : {0}, skill: {1}, Target: {2}", hero.ID, skillId, targetId);
            room.SetTurnParameters(hero, skillId, target);
        }