Esempio n. 1
0
 public void StartGameSession()
 {
     if (PhotonNetwork.player.isMasterClient)
     {
         PhotonNetwork.room.open = false;
         int gameModeId;
         Dictionary <int, int> characterSet;
         int maxPlayerNumber = GameSessionService.SerializeGameConfigParameters(m_GameConfigView, out gameModeId, out characterSet);
         if (PhotonNetwork.playerList.Length <= maxPlayerNumber)
         {
             int[] allocatedPhotonViewIds = GameSessionService.AllocatePhotonViewIds();
             photonView.RPC("StartRemoteGameSession", PhotonTargets.AllViaServer, allocatedPhotonViewIds, PhotonNetwork.playerList, gameModeId, characterSet);
         }
         else
         {
             Debug.LogError("角色数量不足,游戏未能成功创建!");
         }
     }
 }
Esempio n. 2
0
        private void StartRemoteGameSession(int[] allocatedPhotonViewIds, PhotonPlayer[] players, int gameModeId, Dictionary <int, int> characterSet)
        {
            GameModeModel gameMode = null;

            foreach (GameModeModel gameModeModel in m_GameModeDatabase.GameModeModels)
            {
                if (gameModeModel.Id == gameModeId)
                {
                    gameMode = gameModeModel;
                    break;
                }
            }
            int[] otherPhotonViewIds = allocatedPhotonViewIds.Skip(1).ToArray();
            bool  hasStarted         = GameSessionService.StartGameSession(allocatedPhotonViewIds[0], otherPhotonViewIds, players, gameMode, characterSet);

            if (PhotonNetwork.player.isMasterClient)
            {
                PhotonNetwork.room.open = !hasStarted;
            }
            GameSessionService.GameSession.transform.parent = this.transform;
            onStartRemoteGameSession.Invoke();
            UpdateLog(Timestamp.ImprintLocalTime() + "游戏已开始。");
        }
Esempio n. 3
0
 public void EndLocalGameSession()
 {
     GameSessionService.EndGameSession();
     onEndLocalGameSession.Invoke();
     UpdateLog(Timestamp.ImprintLocalTime() + "已退出当前游戏。");
 }
Esempio n. 4
0
 private void EndRemoteGameSession()
 {
     GameSessionService.EndGameSession();
     onEndRemoteGameSession.Invoke();
     UpdateLog(Timestamp.ImprintLocalTime() + "当前游戏已结束。");
 }