/// <summary> /// 通知游戏开始 /// </summary> /// <param name="args"></param> /// <param name="targetAddress"></param> private void _RPC_NotifyGameStart(byte[] buff, IPEndPoint targetAddress) { var info = PBSerializer.NDeserialize<FSPGameStartParam>(buff); PVPStartParam startParam = new PVPStartParam(); for (int i = 0; i < info.players.Count; i++) { byte[] customPlayerData = info.players[i].customPlayerData; PlayerData pd = PBSerializer.NDeserialize<PlayerData>(customPlayerData); pd.id = info.players [i].id; pd.userId = info.players [i].userId; pd.name = info.players [i].name; pd.teamId = (int)info.players [i].id; startParam.players.Add(pd); } startParam.fspParam = info.fspParam; startParam.gameParam = PBSerializer.NDeserialize<GameParam>(info.customGameParam); this.Log("RPC_NotifyGameStart() param: \n{0}", startParam.ToString()); if (onNotifyGameStart != null) { onNotifyGameStart(startParam); } }
private void NotifyGameStart(PVPStartParam param) { Debuger.LogWarning(param.ToString()); PVPStartParam startParam = param; //onNotifyGameStart.Invoke(startParam); ModuleManager.Instance.ShowModule(ModuleDef.GameModule, startParam); }
private void NotifyGameStart(PVPStartParam param) { Debuger.LogWarning(param.ToString()); for (int i = 0; i < param.players.Count; i++) { if (param.players[i].userId == m_mainUserId) { //param.fspParam.sid = param.players[i].sid; break; } } PVPStartParam startParam = param; //onNotifyGameStart.Invoke(startParam); }
//-------------------------------------------------- /// <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(); }