コード例 #1
0
        private static void HandleDestroy(ClientTCP client, byte[] data)
        {
            using (PacketBuffer buffer = new PacketBuffer())
            {
                buffer.WriteBytes(data);
                buffer.ReadInteger();
                ObjectType type  = (ObjectType)buffer.ReadInteger();
                int        index = buffer.ReadInteger();
                switch (type)
                {
                case ObjectType.player:
                    client.room.roomPlayers[index].Destroy(client.room);
                    break;

                case ObjectType.spell:
                    if (client.room.dynamicObjectsList[index] != null)     // Kostil
                    {
                        client.room.dynamicObjectsList[index].Destroy(client.room);
                    }
                    break;

                case ObjectType.staticObjects:
                    client.room.staticObjectsList[index].Destroy(client.room);
                    break;
                }
            }
        }
コード例 #2
0
ファイル: ServerTCP.cs プロジェクト: LanaFan/ElecyNetwork
 public static void SendDataToRoomPlayers(BaseGameRoom room, ClientTCP exceptClient, byte[] data)
 {
     try
     {
         for (int i = 0; i < room.PlayersCount; i++)
         {
             try
             {
                 if (room.playersTCP[i] != null && !exceptClient.Equals(room.playersTCP[i]))
                 {
                     room.playersTCP[i].socket.Send(data);
                 }
             }
             catch (Exception ex)
             {
                 room.playersTCP[i].Close();
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         Global.serverForm.Debug(ex + "");
     }
 }
コード例 #3
0
        private static void HandleDamage(ClientTCP client, byte[] data)
        {
            using (PacketBuffer buffer = new PacketBuffer())
            {
                buffer.WriteBytes(data);
                buffer.ReadInteger();
                ObjectType type          = (ObjectType)buffer.ReadInteger();
                int        _index        = buffer.ReadInteger();
                int        _physicDamage = buffer.ReadInteger();
                int        _ignisDamage  = buffer.ReadInteger();
                int        _terraDamage  = buffer.ReadInteger();
                int        _aquaDamage   = buffer.ReadInteger();
                int        _caeliDamage  = buffer.ReadInteger();
                int        _pureDamage   = buffer.ReadInteger();
                bool       _heal         = buffer.ReadBool();
                switch (type)
                {
                case ObjectType.player:
                    client.room.roomPlayers[_index].TakeDamage(client, _index, _physicDamage, _ignisDamage, _terraDamage, _aquaDamage, _caeliDamage, _pureDamage, _heal);
                    break;

                case ObjectType.spell:
                    client.room.dynamicObjectsList[_index].TakeDamage(client, _index, _physicDamage, _ignisDamage, _terraDamage, _aquaDamage, _caeliDamage, _pureDamage, _heal);
                    break;
                }
            }
        }
コード例 #4
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     int treeCount;
        ///                     for(treeCount)
        ///                     {
        ///                         int Index;
        ///                         int Health;
        ///                         float[3] pos;
        ///                         float[4] rot;
        ///                     }
        ///
        /// </summary>
        public static void SendTreeSpawned(ClientTCP client, int[] ranges)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.STreeSpawned);
            int start = ranges[0];
            int end   = ranges[1];

            buffer.WriteInteger(end - start + 1);
            while (start <= end)
            {
                var k = client.room.staticObjectsList.Get(start).GetInfo();
                buffer.WriteInteger(start);
                buffer.WriteInteger(k.Item1);
                buffer.WriteFloat(k.Item2[0]);
                buffer.WriteFloat(k.Item2[1]);
                buffer.WriteFloat(k.Item2[2]);
                buffer.WriteFloat(k.Item3[0]);
                buffer.WriteFloat(k.Item3[1]);
                buffer.WriteFloat(k.Item3[2]);
                buffer.WriteFloat(k.Item3[3]);
                start++;
            }
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #5
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string race;
        ///                     int spellCount;
        ///                     short[spellCount] spellIndex
        /// </summary>
        private static void HandleSaveSkillBuild(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            string race       = buffer.ReadString();
            int    spellCount = buffer.ReadInteger();

            string[] spellBuild = new string[spellCount];
            for (int i = 0; i < spellCount; i++)
            {
                string spellIndex = "" + buffer.ReadShort();
                while (spellIndex.Length != 4)
                {
                    spellIndex = "0" + spellIndex;
                }
                string spellType = "" + buffer.ReadShort();
                while (spellType.Length != 4)
                {
                    spellType = "0" + spellType;
                }
                spellBuild[i] = spellIndex + "" + spellType;
            }
            buffer.Dispose();
            //Global.data.SetSkillBuildData(client.nickname, race, spellBuild);
            SendDataTCP.SendBuildSaved(client);
        }
コード例 #6
0
 /// <summary>
 ///             Buffer:
 ///                     int PacketNum;
 ///                     int SpellIndex; (index in client's spell array)
 ///                     int ParentIndex;
 ///                     float[3] position;
 ///                     float[4] rotation;
 ///                     int hp;
 /// </summary>
 private static void HandleInstantiate(ClientTCP client, byte[] data)
 {
     using (PacketBuffer buffer = new PacketBuffer())
     {
         buffer.WriteBytes(data);
         buffer.ReadInteger();
         client.room.dynamicObjectsList.Add(
             client.room,
             buffer.ReadInteger(),
             buffer.ReadInteger(),
             new float[] {
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat()
         },
             new float[] {
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat()
         },
             new float[] {
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat()
         },
             buffer.ReadInteger(),
             client.nickname
             );
     }
 }
コード例 #7
0
 /// <summary>
 ///             Buffer:
 ///                     int PacketNum;
 /// </summary>
 private static void HandleQueueStop(ClientTCP client, byte[] data)
 {
     Queue.StopSearch(client);
     foreach (ClientTCP friend in client.friends)
     {
         SendDataTCP.SendFriendChange(client, friend);
     }
 }
コード例 #8
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendRoomLogOut(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SPlayerLogOut);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #9
0
ファイル: Queue.cs プロジェクト: LanaFan/ElecyNetwork
 public static void StopSearch(ClientTCP client)
 {
     if (client.room != null)
     {
         client.room.DeletePlayer(client);
     }
     client.playerState = NetPlayerState.InMainLobby;
 }
コード例 #10
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendRegisterOk(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SRegisterOK);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #11
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendBuildSaved(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SBuildSaved);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #12
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendClientConnetionOK(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SConnectionOK);
            ServerTCP.SendClientConnection(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #13
0
ファイル: BaseGameRoom.cs プロジェクト: LanaFan/ElecyNetwork
 public void LoadSpells(ClientTCP client)
 {
     short[][] spellBuilds = new short[PlayersCount][];
     for (int i = 0; i < PlayersCount; i++)
     {
         spellBuilds[i] = playersTCP[i].accountData.AccountSkillBuilds.IgnisBuild.ToArray();
     }
     SendDataTCP.SendLoadSpells(client, spellBuilds);
 }
コード例 #14
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     float loadProgress;
        /// </summary>
        public static void SendEnemyProgress(BaseGameRoom room, ClientTCP client, float loadProgress)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SEnemyLoadProgress);
            buffer.WriteFloat(loadProgress);
            ServerTCP.SendDataToRoomPlayers(room, client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #15
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string message;
        /// </summary>
        public static void SendClientAlert(ClientTCP client, string message)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SAlert);
            buffer.WriteString(message);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #16
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     int mapIndex;
        /// </summary>
        public static void SendMapData(int mapIndex, ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SMapLoad);
            buffer.WriteInteger(mapIndex);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #17
0
        public static void SendFriendLeave(ClientTCP player, ClientTCP friend)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SFriendLeave);
            buffer.WriteString(player.accountData.GuideKey);
            ServerTCP.SendDataToClient(friend, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #18
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string message;
        /// </summary>
        public static void SendPlayerConnectionOK(ClientTCP player)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SConnectionOK);
            buffer.WriteString("Hello sexy guy...We've been waiting for you =*");
            ServerTCP.SendDataToClient(player, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #19
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string message;
        /// </summary>
        private static void HandleGlChatMsg(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            SendDataTCP.SendGlChatMsg(client.nickname, buffer.ReadString() /* message */);
            buffer.Dispose();
        }
コード例 #20
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string winnerNickname;
        /// </summary>
        public static void SendMatchEnded(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SMatchResult);
            buffer.WriteString(client.nickname);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #21
0
        private static void HandleTreesSpawn(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            client.room.SetLoadProgress(client, buffer.ReadFloat());
            client.room.SpawnTree(client, buffer.ReadInteger(), buffer.ReadBool(), buffer.ReadBool(), buffer.ReadBool());
            buffer.Dispose();
        }
コード例 #22
0
        private static void HandleGetSpells(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            client.room.SetLoadProgress(client, buffer.ReadFloat());
            buffer.Dispose();
            client.room.LoadSpells(client);
        }
コード例 #23
0
 private static void HandleTestRoom(ClientTCP client, byte[] data)
 {
     using (PacketBuffer buffer = new PacketBuffer())
     {
         buffer.WriteBytes(data);
         buffer.ReadInteger();
         int mapIndex = buffer.ReadInteger();
         client.race = buffer.ReadString();
         Global.roomsList.Add(new TestRoom(client, mapIndex));
     }
 }
コード例 #24
0
ファイル: BaseGameRoom.cs プロジェクト: LanaFan/ElecyNetwork
 public void Surrended(ClientTCP client)
 {
     CloseUpdateTimer();
     Status = RoomState.MatchEnded;
     foreach (ClientTCP player in playersTCP)
     {
         player.playerState = NetPlayerState.EndPlaying;
     }
     _closeTimer = new Timer(EndGameSession, null, 300000, Timeout.Infinite);
     SendDataTCP.SendMatchEnded(client.nickname, this);
 }
コード例 #25
0
        private static void HandleAddFriend(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            string guideTag = buffer.ReadString();

            buffer.Dispose();
            client.AddFriend(guideTag);
        }
コード例 #26
0
ファイル: ServerTCP.cs プロジェクト: LanaFan/ElecyNetwork
 public static void SendDataToClient(ClientTCP client, byte[] data)
 {
     try
     {
         client.socket.Send(data);
     }
     catch
     {
         client.Close();
     }
 }
コード例 #27
0
        public static void SendFriendInfo(ClientTCP player, ClientTCP friend)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SFriendInfo);
            buffer.WriteString(friend.nickname);
            buffer.WriteString(friend.accountData.GuideKey);
            buffer.WriteInteger((int)friend.playerState);
            ServerTCP.SendDataToClient(player, buffer.ToArray());
            buffer.Dispose();
        }
コード例 #28
0
ファイル: ServerTCP.cs プロジェクト: LanaFan/ElecyNetwork
 private static void AcceptCallback(IAsyncResult ar)
 {
     if (!Closed)
     {
         Socket socket = _serverSocket.EndAccept(ar);
         _serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);
         ClientTCP client = new ClientTCP(socket, socket.RemoteEndPoint as IPEndPoint);
         Global.clientList.Add(client);
         SendDataTCP.SendClientConnetionOK(client);
     }
 }
コード例 #29
0
ファイル: BaseGameRoom.cs プロジェクト: LanaFan/ElecyNetwork
 public void SpawnTree(ClientTCP client, int treeCount, bool bigTree, bool mediumTree, bool smallTree)
 {
     int[] ranges;
     lock (expectant)
     {
         if (!staticObjectsList.GetRange(StaticTypes.tree, out ranges))
         {
             ranges = staticObjectsList.Add(StaticTypes.tree, ObjectType.staticObjects, this, treeCount, bigTree, mediumTree, smallTree);
         }
     }
     SendDataTCP.SendTreeSpawned(client, ranges);
 }
コード例 #30
0
ファイル: Server.cs プロジェクト: LanaFan/ElecyNetwork
 public void AddClient(ClientTCP client)
 {
     if (listClients.InvokeRequired)
     {
         StringArgReturningVoidDelegate <ClientTCP> d = new StringArgReturningVoidDelegate <ClientTCP>(AddClient);
         Invoke(d, new object[] { client });
     }
     else
     {
         listClients.Items.Add(client);
     }
 }