Exemplo n.º 1
0
 public override void DataHandle(Guid userToken, GameNetObject gameNetObject)
 {
     if (gameNetObject is PositionChange)
     {
         var positionNetObj = gameNetObject as PositionChange;
         int playerId       = ContainsPlayer(userToken);
         if (!m_playerDic.ContainsKey(playerId))
         {
             m_playerDic.Add(playerId,
                             new HauntedHouseNetObjectState()
             {
                 Position = new Vector3(positionNetObj.x, positionNetObj.y, positionNetObj.z),
                 EType    = positionNetObj.EType
             });
         }
         else
         {
             m_playerDic[playerId] = new HauntedHouseNetObjectState()
             {
                 Position = new Vector3(positionNetObj.x, positionNetObj.y, positionNetObj.z),
                 EType    = positionNetObj.EType
             };
         }
     }
     //保存玩家信息
     if (gameNetObject is PlayerSelectRole)
     {
         PlayerSelectRole psr = gameNetObject as PlayerSelectRole;
         UserData[psr.PlayerID] = psr.Player;
     }
     base.DataHandle(userToken, gameNetObject);
 }
Exemplo n.º 2
0
        public void Datahandle(byte[] bytes)
        {
            BaseNetObject bno = NetBaseTool.BytesToObject(bytes) as BaseNetObject;

            if (bno is SystemNetObject)
            {
                SystemNetObject systemNetObject = bno as SystemNetObject;
                if (systemNetObject.GetType() == typeof(Msg))
                {
                    Console.WriteLine(systemNetObject);
                }
                else if (systemNetObject.GetType() == typeof(GetMyUserData))
                {
                    MyUserData = (systemNetObject as GetMyUserData).userData;
                }
                else if (systemNetObject.GetType() == typeof(CreateRoomS2C))
                {
                    transmit = (systemNetObject as CreateRoomS2C).PlayerId;
                    wait.Set();
                }
                else if (systemNetObject.GetType() == typeof(JoinRoomS2C))
                {
                    transmit = (systemNetObject as JoinRoomS2C);
                    wait.Set();
                }
                else if (systemNetObject.GetType() == typeof(GetRoomListS2C))
                {
                    transmit = (systemNetObject as GetRoomListS2C).rooms;
                    wait.Set();
                }
                else if (systemNetObject.GetType() == typeof(PlayerJoinS2C))
                {
                    PlayerJoin?.Invoke((systemNetObject as PlayerJoinS2C).playerId);
                }
                else if (systemNetObject.GetType() == typeof(PlayerLeaveS2C))
                {
                    PlayerLeave?.Invoke((systemNetObject as PlayerLeaveS2C).playerId);
                }
                else if (systemNetObject.GetType() == typeof(GameStart))
                {
                    StartAction?.Invoke();
                }
            }
            else
            {
                GameNetObject gno = bno as GameNetObject;
                if (gno == null)
                {
                    throw new ArgumentException(bno.GetType() + " Can't Used");
                }
                ReceiveAction?.Invoke(gno);
            }
            //防止死锁
            // wait.Set();
        }
Exemplo n.º 3
0
 static void Handle(GameNetObject hauntedHouseNetObject)
 {
     Console.WriteLine(hauntedHouseNetObject);
 }
Exemplo n.º 4
0
 public virtual void DateHandle(int i, GameNetObject gno)
 {
     Console.WriteLine("PlayerNum : " + i + " Send " + gno);
 }
Exemplo n.º 5
0
 public abstract void DataHandle(GameNetObject gno);
Exemplo n.º 6
0
 public void Send(GameNetObject gno)
 {
     Send(gno);
 }