static public void PushHandler(NetConnection connection, object data) { PushData push = null; try { push = GSrv.Deserialize <PushData>((byte[])data); } catch { return; } if (!PlayerCaches.AuthDone(connection)) { return; } if (PlayerCaches.InLobby(connection)) { return; } int roomid = PlayerCaches.GetRoomID(connection); if (Lobby.GetRoomState(roomid) == 0) { return; } Lobby.Push(connection, roomid, push); }
public PushData GetPushData() { float xpos = transform.position.x; float ypos = transform.position.y; float zpos = transform.position.z; float xrot = fpsCamera.localEulerAngles.x; float yrot = transform.localEulerAngles.y; int animestate; if (haveGun) { animestate = fpsCon.isMoving ? 1 : 0; } else { animestate = fpsCon.isMoving ? 3 : 2; } PushData data = new PushData(); data.xpos = xpos; data.ypos = ypos; data.zpos = zpos; data.xrot = xrot; data.yrot = yrot; data.animestate = animestate; return(data); }
public void Push(NetConnection connection, PushData data) { PlayerSyncData sync = players[connection].sync; sync.xpos = data.xpos; sync.ypos = data.ypos; sync.zpos = data.zpos; sync.xrot = data.xrot; sync.yrot = data.yrot; sync.animestate = data.animestate; }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } GCli.Receive(); frameSpan += Time.deltaTime; if (frameSpan >= 0.1f) { frameSpan = 0; if (Players.GetPlayer() != null) { PushData push = Players.GetPushData(); if (push != null) { GCli.Send(MessageType.Push, GCli.Serialize <PushData>(push), NetDeliveryMethod.UnreliableSequenced); } } } }
public static void Push(NetConnection connection, int roomid, PushData data) { rooms[roomid].Push(connection, data); }