Beispiel #1
0
        private void PlayersUpdated(List <ITAlertPlayer> players)
        {
            CheckShowToTalk(players.Count);

            foreach (var player in players)
            {
                if (_playerVoiceItems.TryGetValue(player.PhotonId, out var playerVoiceItem) == false)
                {
                    var playerItem = Object.Instantiate(_playerChatItemPrefab);


                    var nameText = playerItem.transform.FindText("Name");
                    nameText.text = player.Name;

                    var scoreText = playerItem.transform.FindText("PlayerScore");

                    var scoreIncrementText = scoreText.transform.FindText("ScoreChange");

                    var soundIcon = playerItem.transform.FindImage("SoundIcon");


                    playerItem.transform.SetParent(_chatPanel.transform, false);

                    playerVoiceItem = new PlayerVoiceItem
                    {
                        GameObject         = playerItem,
                        VoiceIcon          = soundIcon,
                        NameText           = nameText,
                        ScoreText          = scoreText,
                        ScoreIncrementText = scoreIncrementText
                    };

                    _playerVoiceItems.Add(player.PhotonId, playerVoiceItem);
                }
                UpdatePlayerVoiceItem(player, playerVoiceItem);
            }
            foreach (var playerVoiceItem in _playerVoiceItems)
            {
                if (players.All(p => p.PhotonId != playerVoiceItem.Key))
                {
                    Object.Destroy(playerVoiceItem.Value.GameObject);
                }
            }
            _playerVoiceItems = _playerVoiceItems.Where(p => p.Value.GameObject != null).ToDictionary(p => p.Key, p => p.Value);
            _playerIdPair     = GameObjectUtilities.FindGameObject("Game").GetComponentsInChildren <PlayerBehaviour>(true).ToDictionary(p => p.PhotonId, p => p.Id);
        }
Beispiel #2
0
        private void UpdatePlayerVoiceItem(ITAlertPlayer player, PlayerVoiceItem playerVoiceItem)
        {
            if (ColorUtility.TryParseHtmlString(player.Colour, out var colour))
            {
                playerVoiceItem.NameText.color           = colour;
                playerVoiceItem.ScoreText.color          = colour;
                playerVoiceItem.VoiceIcon.color          = colour;
                playerVoiceItem.ScoreIncrementText.color = colour;

                if (PhotonNetwork.player.ID == player.PhotonId && PlatformUtils.IsMobile)
                {
                    UpdatePressToTalkButton(colour);
                }
            }
            if (playerVoiceItem.NameText.text != player.Name)
            {
                playerVoiceItem.NameText.GetComponent <TextCutoff>().text = player.Name;
            }
        }