Example #1
0
 public override bool Equals(object obj)
 {
     if (obj.GetType() == typeof(EndPoint) || obj.GetType() == typeof(IPEndPoint))
     {
         IPEndPoint point = obj as IPEndPoint;
         return(point.Address.ToString() == ip && port == point.Port);
     }
     else if (obj.GetType() == typeof(GIPEndPoint))
     {
         GIPEndPoint point = obj as GIPEndPoint;
         return(point.ip == ip && port == point.port);
     }
     return(false);
 }
        public void Deal_1_1(MessageData <BaseMessageData> data)
        {
            MessageData_1_1 messageData = data.body as MessageData_1_1;

            for (int i = 0; i < messageData.players.Count; i++)
            {
                MessageData_1_1.PlayerInfo playerInfo = messageData.players[i];
                GIPEndPoint playerIp = playerInfo.ip;
                if (!Main.Self.playerList.ContainsKey(playerIp))
                {
                    GameObject go       = GameObject.Instantiate(Resources.Load("Player") as GameObject);
                    Player     player   = go.AddComponent <Player> ();
                    Vector3    pos      = playerInfo.pos;
                    Vector3    rot      = playerInfo.rot;
                    double     aimValue = playerInfo.aimValue;
                    player.StartCallBack += () => {
                        player.curIp = playerIp;
                        player.SetName(playerIp.ToString());
                        player.SetTrans(new List <GVector3> ()
                        {
                            pos, rot
                        });
                        player.aimValue = (float)aimValue;
                    };
                    Main.Self.playerList.Add(playerIp, player);
                    if (Main.Self.curPlayer == null && data.body._ip.Equals(playerIp))
                    {
                        Main.Self.curPlayer   = player;
                        player.isLocalPlayer  = true;
                        player.StartCallBack += () => {
                            player.SetColor();
                        };
                    }
                }
            }
            Debug.Log("欢迎 " + data.body._ip.ToString());
        }
Example #3
0
 public void OnSocketConnect(Socket socket, GIPEndPoint point)
 {
 }