Esempio n. 1
0
        public static void updatePlayerInfo()
        {
            foreach (PlayerControl p in PlayerControl.AllPlayerControls)
            {
                if (p != PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead)
                {
                    continue;
                }

                Transform         playerInfoTransform = p.transform.FindChild("Info");
                TMPro.TextMeshPro playerInfo          = playerInfoTransform != null?playerInfoTransform.GetComponent <TMPro.TextMeshPro>() : null;

                if (playerInfo == null)
                {
                    playerInfo = UnityEngine.Object.Instantiate(p.nameText, p.nameText.transform.parent);
                    playerInfo.transform.localPosition += Vector3.up * 0.25f;
                    playerInfo.fontSize       *= 0.75f;
                    playerInfo.gameObject.name = "Info";
                }

                PlayerVoteArea playerVoteArea       = MeetingHud.Instance?.playerStates?.FirstOrDefault(x => x.TargetPlayerId == p.PlayerId);
                Transform      meetingInfoTransform = playerVoteArea != null?playerVoteArea.transform.FindChild("Info") : null;

                TMPro.TextMeshPro meetingInfo = meetingInfoTransform != null?meetingInfoTransform.GetComponent <TMPro.TextMeshPro>() : null;

                if (meetingInfo == null && playerVoteArea != null)
                {
                    meetingInfo = UnityEngine.Object.Instantiate(playerVoteArea.NameText, playerVoteArea.NameText.transform.parent);
                    meetingInfo.transform.localPosition += Vector3.down * (MeetingHud.Instance.playerStates.Length > 10 ? 0.4f : 0.25f);
                    meetingInfo.fontSize       *= 0.75f;
                    meetingInfo.gameObject.name = "Info";
                }

                var(tasksCompleted, tasksTotal) = TasksHandler.taskInfo(p.Data);
                string roleNames = String.Join(", ", RoleInfo.getRoleInfoForPlayer(p).Select(x => Helpers.cs(x.color, x.name)).ToArray());
                string taskInfo  = tasksTotal > 0 ? $"<color=#FAD934FF>({tasksCompleted}/{tasksTotal})</color>" : "";

                string info = "";
                if (p == PlayerControl.LocalPlayer)
                {
                    info = $"{roleNames}";
                    if (DestroyableSingleton <TaskPanelBehaviour> .InstanceExists)
                    {
                        TMPro.TextMeshPro tabText = DestroyableSingleton <TaskPanelBehaviour> .Instance.tab.transform.FindChild("TabText_TMP").GetComponent <TMPro.TextMeshPro>();

                        tabText.SetText($"Tasks {taskInfo}");
                    }
                }
                else if (MapOptions.ghostsSeeRoles && MapOptions.ghostsSeeTasks)
                {
                    info = $"{roleNames} {taskInfo}".Trim();
                }
                else if (MapOptions.ghostsSeeTasks)
                {
                    info = $"{taskInfo}".Trim();
                }
                else if (MapOptions.ghostsSeeRoles)
                {
                    info = $"{roleNames}";
                }

                playerInfo.text = info;
                playerInfo.gameObject.SetActive(p.Visible);
                if (meetingInfo != null)
                {
                    meetingInfo.text = MeetingHud.Instance.state == MeetingHud.VoteStates.Results ? "" : info;
                }
            }
        }