public void Start(FSPParam param) { this.Log("Start()"); param.sid = m_playerId; m_mgrFSP = new FSPManager(); m_mgrFSP.Start(param, m_playerId); m_mgrFSP.SetFrameListener(OnEnterFrame); m_mgrFSP.onGameEnd += (arg) => { this.Log("OnGameEnd() " + arg); DelayInvoker.DelayInvoke(0.01f, Close); //Close(); }; m_mgrFSP.onGameExit += (playerId) => { this.Log("onGameExit() " + playerId); if (playerId == m_playerId) { DelayInvoker.DelayInvoke(0.01f, Close); //Close(); } }; m_mgrFSP.SendGameBegin(); }
public bool Start(FSPParam param) { m_mgrFSP = new FSPManager(); m_mgrFSP.Start(param, m_playerId); m_mgrFSP.SetFrameListener(OnEnterFrame); m_mgrFSP.SetGameStateListener(this); return(true); }
//-------------------------------------------------- /// <summary> /// 开始游戏 /// </summary> /// <param name="param"></param> public void Start(PVPStartParam param) { Debuger.Log(LOG_TAG, "StartGame() param:{0}", param); UserData mainUserData = UserManager.Instance.MainUserData; m_listPlayerData = param.players; for (int i = 0; i < m_listPlayerData.Count; i++) { if (m_listPlayerData[i].userId == mainUserData.id) { m_mainPlayerId = m_listPlayerData[i].id; GameCamera.FocusPlayerId = m_mainPlayerId; } //注册玩家数据,为在帧同步过程中创建玩家提供数据 //因为帧同步协议非常精简,不包含具体的玩家数据 GameManager.Instance.RegPlayerData(m_listPlayerData[i]); } //启动游戏逻辑 GameManager.Instance.CreateGame(param.gameParam); GameManager.Instance.onPlayerDie += OnPlayerDie; //有玩家死亡 m_context = GameManager.Instance.Context; //启动帧同步逻辑 m_mgrFSP = new FSPManager(); m_mgrFSP.Start(param.fspParam, m_mainPlayerId); m_mgrFSP.SetFrameListener(OnEnterFrame); m_mgrFSP.onGameBegin += OnGameBegin; //游戏开始 m_mgrFSP.onGameExit += OnGameExit; //有玩家退出 m_mgrFSP.onRoundEnd += OnRoundEnd; //有玩家退出 m_mgrFSP.onGameEnd += OnGameEnd; //游戏结束 //初始化输入 GameInput.Create(); GameInput.OnVkey += OnVKey; //监听EnterFrame MonoHelper.AddFixedUpdateListener(FixedUpdate); GameBegin(); }
//-------------------------------------------------- /// <summary> /// Start Game /// </summary> /// <param name="param"></param> public void Start(PVPStartParam param) { MyLogger.Log(LOG_TAG, "StartGame() param:{0}", param.ToString()); UserBean mainUserData = UserManager.Instance.MainUserData; playerDataList = param.players; for (int i = 0; i < playerDataList.Count; i++) { if (playerDataList[i].userId == mainUserData.id) { mainPlayerId = playerDataList[i].id; GameCamera.FocusPlayerId = mainPlayerId; } //register player data, this can provide player data for FSP //coz FSP is too easy to have player data GameManager.Instance.RegPlayerData(playerDataList[i]); } //start game GameManager.Instance.CreateGame(param.gameParam); GameManager.Instance.onPlayerDie += OnPlayerDie;//player died m_context = GameManager.Instance.Context; //start FSP mgrFSP = new FSPManager(); mgrFSP.Start(param.fspParam, mainPlayerId); mgrFSP.SetFrameListener(OnEnterFrame); mgrFSP.onGameBegin += OnGameBegin; //game start mgrFSP.onGameExit += OnGameExit; //player exit mgrFSP.onRoundEnd += OnRoundEnd; //player exit mgrFSP.onGameEnd += OnGameEnd; //game over //initial game input GameInput.Create(); GameInput.OnVkey += OnVKey; //listen on EnterFrame MonoHelper.AddFixedUpdateListener(FixedUpdate); GameBegin(); }
public void Start(PVPStartParam param) { m_waitGameEnd = false; uint mainPlayerId = 0; uint mainUserId = OnlineManager.Instance.MainUserData.id; for (int i = 0; i < param.players.Count; i++) { if (param.players[i].userId == mainUserId) { mainPlayerId = param.players[i].id; } } m_fsp = new FSPManager(); m_fsp.Start(param.fspParam, mainPlayerId); m_fsp.onGameEnd += OnGameEnd; m_fsp.onGameExit += OnGameExit; m_fsp.SetFrameListener(OnEnterFrame); }