public void onTransportAdded(Transport transport) { Debug.Log("onTransportAdded " + transport); ViewS.getInstance().SetNickname(FNet.Instance.nickname); ViewS.getInstance().JoinRoom(); FNet.Instance.connectionState = ConnectionState.MAIN; }
public void Quit() { ViewS.getInstance().LeaveRoom(0); object obj = new object(); Action done = () => { lock (obj) { Monitor.Pulse(obj); } }; lock (obj) { Endpoint.closeEngine(done); Monitor.Wait(obj); } }
/// <summary> /// 将自己的位置同步到服务器 /// </summary> /// <param name="curPos"></param> public void SetPosition(Vector3 curPos) { if (connectionState != ConnectionState.OFFLINE) { //这里记得检查抛出异常,不然玩家人数减少后会导致连接中断 try { ViewS.getInstance().SetPosition(curPos.x, curPos.z); } catch (Exception) { Debug.Log("Error in FNet.SetPosition. Now UpdatePlayers..."); UpdatePlayers(); } } }
/// <summary> /// 将自己的血量同步到服务器 /// </summary> /// <param name="curHp"></param> public void SetHp(int curHp) { if (connectionState != ConnectionState.OFFLINE) { //这里记得检查抛出异常,不然玩家人数减少后会导致连接中断 try { ViewS.getInstance().SetHp(curHp); } catch (Exception) { Debug.Log("Error in FNet.SetHp. Now UpdatePlayers..."); UpdatePlayers(); } } }