Example #1
0
        protected override void ReceiveUnusedIdentity(int index, int characterId)
        {
            PlayerIdentity unusedIdentity = m_UnusedIdentities[index];

            unusedIdentity.UpdateIdentity(characterId);
            unusedIdentity.MarkAsRevealed(true);
            onSingleUnusedIdentityUpdate.Invoke(index.ToString(), unusedIdentity);
        }
Example #2
0
        protected override void ReceivePlayerIdentity(int number, int characterId)
        {
            PlayerIdentity playerIdentity = m_PlayerIdentities[number];

            playerIdentity.UpdateIdentity(characterId);
            playerIdentity.MarkAsRevealed(true);
            onSinglePlayerIdentityUpdate.Invoke(number.ToString(), playerIdentity);
        }
Example #3
0
        private void ReceiveUnusedIdentityHistory(int index, int characterId)
        {
            PlayerIdentity unusedIdentity = new PlayerIdentity();

            unusedIdentity.UpdateNumber(index);
            unusedIdentity.UpdateIdentity(characterId);

            m_UnusedIdentitiesHistory[m_GameHistoryIndex].Add(unusedIdentity);
        }
Example #4
0
        public override void GeneratePlayerIdentities()
        {
            if (!PhotonNetwork.isMasterClient)
            {
                return;
            }

            //随机生成玩家编号,0号预留给上帝玩家
            List <int> playerNumbers = new List <int>();

            for (int i = 1; i < m_Players.Length; i++)
            {
                playerNumbers.Add(i);
            }
            playerNumbers = playerNumbers.Shuffle().ToList();

            //向其他玩家分配编号列表
            photonView.RPC("ReceivePlayerNumbers", PhotonTargets.All, playerNumbers.ToArray());

            //生成所有游戏身份
            List <int> characterIds = new List <int>();

            foreach (int id in m_CharacterSet.Keys)
            {
                characterIds.AddRange(Enumerable.Repeat(id, m_CharacterSet[id]));
            }
            characterIds = characterIds.Shuffle().ToList();

            //对应编号分配游戏身份,上帝(0号玩家)本身不获得游戏身份
            int k = 0;

            foreach (int index in m_PlayerIdentities.Keys)
            {
                if (index != 0)
                {
                    PlayerIdentity playerIdentity = m_PlayerIdentities[index];
                    playerIdentity.UpdateIdentity(characterIds[k++]);
                    playerIdentity.MarkAsRevealed(true);
                }
            }
            UpdatePlayerIdentities();

            //收集多余游戏身份
            for (int i = 0; i < characterIds.Count() - k; i++)
            {
                PlayerIdentity unusedIdentity = m_UnusedIdentities[i];
                unusedIdentity.UpdateIdentity(characterIds[k + i]);
                unusedIdentity.MarkAsRevealed(true);
            }
            UpdateUnusedIdentities();

            FindObjectOfType <GameHistoryServiceView>().RecordIdentitiesHistory(m_PlayerIdentities, m_UnusedIdentities);

            //向其他玩家分配各自身份
            DistributePlayerIdentities();
        }
Example #5
0
        private void ReceivePlayerIdentityHistory(int playerNumber, PhotonPlayer player, int characterId)
        {
            PlayerIdentity playerIdentity = new PlayerIdentity();

            playerIdentity.UpdateNumber(playerNumber);
            playerIdentity.UpdatePlayer(player);
            playerIdentity.UpdateIdentity(characterId);

            m_PlayerIdentitiesHistory[m_GameHistoryIndex][playerNumber] = playerIdentity;
        }