public static void updateGhostInfo() { foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (p != PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead) { continue; } Transform playerGhostInfoTransform = p.transform.FindChild("GhostInfo"); TMPro.TextMeshPro playerGhostInfo = playerGhostInfoTransform != null?playerGhostInfoTransform.GetComponent <TMPro.TextMeshPro>() : null; if (playerGhostInfo == null) { playerGhostInfo = UnityEngine.Object.Instantiate(p.nameText, p.nameText.transform.parent); playerGhostInfo.transform.localPosition += Vector3.up * 0.25f; playerGhostInfo.fontSize *= 0.75f; playerGhostInfo.gameObject.name = "GhostInfo"; } PlayerVoteArea playerVoteArea = MeetingHud.Instance?.playerStates?.FirstOrDefault(x => x.TargetPlayerId == p.PlayerId); Transform meetingGhostInfoTransform = playerVoteArea != null?playerVoteArea.transform.FindChild("GhostInfo") : null; TMPro.TextMeshPro meetingGhostInfo = meetingGhostInfoTransform != null?meetingGhostInfoTransform.GetComponent <TMPro.TextMeshPro>() : null; if (meetingGhostInfo == null && playerVoteArea != null) { meetingGhostInfo = UnityEngine.Object.Instantiate(playerVoteArea.NameText, playerVoteArea.NameText.transform.parent); meetingGhostInfo.transform.localPosition += Vector3.down * (MeetingHud.Instance.playerStates.Length > 10 ? 0.4f : 0.25f); meetingGhostInfo.fontSize *= 0.75f; meetingGhostInfo.gameObject.name = "GhostInfo"; } 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 || (MapOptions.ghostsSeeRoles && MapOptions.ghostsSeeTasks)) { info = $"{roleNames} {taskInfo}".Trim(); } else if (MapOptions.ghostsSeeTasks) { info = $"{taskInfo}".Trim(); } else if (MapOptions.ghostsSeeRoles) { info = $"{roleNames}"; } playerGhostInfo.text = info; playerGhostInfo.gameObject.SetActive(p.Visible); if (meetingGhostInfo != null) { meetingGhostInfo.text = MeetingHud.Instance.state == MeetingHud.VoteStates.Results ? "" : info; } } }
static void snitchUpdate() { if (Snitch.localArrows == null) { return; } foreach (Arrow arrow in Snitch.localArrows) { arrow.arrow.SetActive(false); } if (Snitch.snitch == null || Snitch.snitch.Data.IsDead) { return; } var(playerCompleted, playerTotal) = TasksHandler.taskInfo(Snitch.snitch.Data); int numberOfTasks = playerTotal - playerCompleted; if (PlayerControl.LocalPlayer.Data.IsImpostor && numberOfTasks <= Snitch.taskCountForImpostors) { if (Snitch.localArrows.Count == 0) { Snitch.localArrows.Add(new Arrow(Color.blue)); } if (Snitch.localArrows.Count != 0 && Snitch.localArrows[0] != null) { Snitch.localArrows[0].arrow.SetActive(true); Snitch.localArrows[0].Update(Snitch.snitch.transform.position); } } else if (PlayerControl.LocalPlayer == Snitch.snitch && numberOfTasks == 0) { int arrowIndex = 0; foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (p.Data.IsImpostor && !p.Data.IsDead) { if (arrowIndex >= Snitch.localArrows.Count) { Snitch.localArrows.Add(new Arrow(Color.blue)); } if (arrowIndex < Snitch.localArrows.Count && Snitch.localArrows[arrowIndex] != null) { Snitch.localArrows[arrowIndex].arrow.SetActive(true); Snitch.localArrows[arrowIndex].Update(p.transform.position); } arrowIndex++; } } } }
public static bool isCompletedNumTasks(PlayerControl p) { var(tasksCompleted, tasksTotal) = TasksHandler.taskInfo(p.Data); return(tasksCompleted >= numTasks); }