/// <summary> /// start the game /// </summary> /// <param name="param"></param> public void Start(GameParam param) { GameManager.Instance.CreateGame(param); GameManager.Instance.onPlayerDie += OnPlayerDie; m_context = GameManager.Instance.Context; PlayerData pd = new PlayerData(); pd.id = m_mainPlayerId; pd.userId = UserManager.Instance.MainUserData.id; pd.snakeData.id = SkinManager.Instance.SkinType; pd.snakeData.length = 50; pd.ai = 0; GameManager.Instance.RegPlayerData(pd); //initial Game Input GameInput.Create(); GameInput.OnVkey += OnVKey; //listen on EnterFrame MonoHelper.AddFixedUpdateListener(FixedUpdate); GameCamera.FocusPlayerId = m_mainPlayerId; }
//-------------------------------------------------- /// <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(); }
private void InitGameInput() { GameInput.Create(); GameInput.OnVkey += OnVkey; }