public static String GetRolesString(PlayerControl p, bool useColors, RoleType[] excludeRoles = null, bool includeHidden = false, string joinSeparator = " ") { if (p?.Data?.Disconnected != false) return ""; var roleInfo = getRoleInfoForPlayer(p, excludeRoles, includeHidden); string roleName = String.Join(joinSeparator, roleInfo.Select(x => useColors ? Helpers.cs(x.color, x.name) : x.name).ToArray()); if (Lawyer.target != null && p?.PlayerId == Lawyer.target.PlayerId && PlayerControl.LocalPlayer != Lawyer.target) roleName += (useColors ? Helpers.cs(Pursuer.color, " §") : " §"); if (p.hasModifier(ModifierType.Madmate) || p.hasModifier(ModifierType.CreatedMadmate)) { // Madmate only if (roleInfo.Contains(crewmate)) { roleName = useColors ? Helpers.cs(Madmate.color, Madmate.fullName) : Madmate.fullName; } else { string prefix = useColors ? Helpers.cs(Madmate.color, Madmate.prefix) : Madmate.prefix; roleName = String.Join(joinSeparator, roleInfo.Select(x => useColors ? Helpers.cs(Madmate.color, x.name) : x.name).ToArray()); roleName = prefix + roleName; } } if (p.hasModifier(ModifierType.LastImpostor)) { if (roleInfo.Contains(impostor)) { roleName = useColors ? Helpers.cs(LastImpostor.color, LastImpostor.fullName) : LastImpostor.fullName; } else { string postfix = useColors ? Helpers.cs(LastImpostor.color, LastImpostor.postfix) : LastImpostor.postfix; roleName = String.Join(joinSeparator, roleInfo.Select(x => useColors? Helpers.cs(x.color, x.name) : x.name).ToArray()); roleName = roleName + postfix; } } if(p.hasModifier(ModifierType.Munou)) { if(PlayerControl.LocalPlayer.Data.IsDead || Munou.endGameFlag) { string postfix = useColors ? Helpers.cs(Munou.color, Munou.postfix) : Munou.postfix; // roleName = String.Join(joinSeparator, roleInfo.Select(x => useColors? Helpers.cs(x.color, x.name) : x.name).ToArray()); roleName = roleName + postfix; } } if(p.hasModifier(ModifierType.AntiTeleport)) { string postfix = useColors ? Helpers.cs(AntiTeleport.color, AntiTeleport.postfix) : AntiTeleport.postfix; // roleName = String.Join(joinSeparator, roleInfo.Select(x => useColors? Helpers.cs(x.color, x.name) : x.name).ToArray()); roleName = roleName + postfix; } return roleName; }
public static string getProgressString(float progress) { // Go from green -> yellow -> red based on infection progress Color color; var prog = progress / infectDuration; if (prog < 0.5f) { color = Color.Lerp(Color.green, Color.yellow, prog * 2); } else { color = Color.Lerp(Color.yellow, Color.red, prog * 2 - 1); } float progPercent = prog * 100; return(Helpers.cs(color, $"{progPercent.ToString("F1")}%")); }
public static void divine(PlayerControl p) { // FortuneTeller.divine(p, resultIsCrewOrNot); string msgBase = ""; string msgInfo = ""; Color color = Color.white; if (divineResult == DivineResults.BlackWhite) { if (p.isCrew()) { msgBase = "divineMessageIsCrew"; color = Color.white; } else { msgBase = "divineMessageIsntCrew"; color = Palette.ImpostorRed; } } else if (divineResult == DivineResults.Team) { msgBase = "divineMessageTeam"; if (p.isCrew()) { msgInfo = ModTranslation.getString("divineCrew"); color = Color.white; } else if (p.isNeutral()) { msgInfo = ModTranslation.getString("divineNeutral"); color = Color.yellow; } else { msgInfo = ModTranslation.getString("divineImpostor"); color = Palette.ImpostorRed; } } else if (divineResult == DivineResults.Role) { msgBase = "divineMessageRole"; msgInfo = String.Join(" ", RoleInfo.getRoleInfoForPlayer(p).Select(x => Helpers.cs(x.color, x.name)).ToArray()); } string msg = string.Format(ModTranslation.getString(msgBase), p.name, msgInfo); if (!string.IsNullOrWhiteSpace(msg)) { FortuneTeller.fortuneTellerMessage(msg, 5f, color); } if (Constants.ShouldPlaySfx()) { SoundManager.Instance.PlaySound(DestroyableSingleton <HudManager> .Instance.TaskCompleteSound, false, 0.8f); } numUsed += 1; // 占いを実行したことで発火される処理を他クライアントに通知 MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FortuneTellerUsedDivine, Hazel.SendOption.Reliable, -1); writer.Write(PlayerControl.LocalPlayer.PlayerId); writer.Write(p.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.fortuneTellerUsedDivine(PlayerControl.LocalPlayer.PlayerId, p.PlayerId); numUsed += 1; }
public void UpdateStatusText() { // ロード画面でstatusTextを生成すると上手く表示されないのでゲームが開始してから最初に感染させた時点から表示する if (!hasInfected()) { return; } if (MeetingHud.Instance != null) { if (statusText != null) { statusText.gameObject.SetActive(false); } return; } if ((player != null && PlayerControl.LocalPlayer == player) || PlayerControl.LocalPlayer.isDead()) { if (statusText == null) { GameObject gameObject = UnityEngine.Object.Instantiate(HudManager.Instance?.roomTracker.gameObject); gameObject.transform.SetParent(HudManager.Instance.transform); gameObject.SetActive(true); UnityEngine.Object.DestroyImmediate(gameObject.GetComponent <RoomTracker>()); statusText = gameObject.GetComponent <TMPro.TMP_Text>(); gameObject.transform.localPosition = new Vector3(-2.7f, -0.1f, gameObject.transform.localPosition.z); statusText.transform.localScale = new Vector3(1f, 1f, 1f); statusText.fontSize = 1.5f; statusText.fontSizeMin = 1.5f; statusText.fontSizeMax = 1.5f; statusText.alignment = TMPro.TextAlignmentOptions.BottomLeft; } statusText.gameObject.SetActive(true); string text = $"[{ModTranslation.getString("plagueDoctorProgress")}]\n"; foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (p == player) { continue; } if (dead.ContainsKey(p.PlayerId) && dead[p.PlayerId]) { continue; } text += $"{p.name}: "; if (infected.ContainsKey(p.PlayerId)) { text += Helpers.cs(Color.red, ModTranslation.getString("plagueDoctorInfectedText")); } else { // データが無い場合は作成する if (!progress.ContainsKey(p.PlayerId)) { progress[p.PlayerId] = 0f; } text += getProgressString(progress[p.PlayerId]); } text += "\n"; } statusText.text = text; } }
public static void updateGhostInfo() { if (!MapOptions.showGhostInfo) { return; } 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>" : ""; playerGhostInfo.text = $"{roleNames} {taskInfo}".Trim(); if (meetingGhostInfo != null) { meetingGhostInfo.text = MeetingHud.Instance.state == MeetingHud.VoteStates.Results ? "" : $"{roleNames} {taskInfo}".Trim(); } } }
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 playerInfoText = ""; string meetingInfoText = ""; if (p == PlayerControl.LocalPlayer) { playerInfoText = $"{roleNames}"; if (DestroyableSingleton <TaskPanelBehaviour> .InstanceExists) { TMPro.TextMeshPro tabText = DestroyableSingleton <TaskPanelBehaviour> .Instance.tab.transform.FindChild("TabText_TMP").GetComponent <TMPro.TextMeshPro>(); tabText.SetText($"Tasks {taskInfo}"); } meetingInfoText = $"{roleNames} {taskInfo}".Trim(); } else if (MapOptions.ghostsSeeRoles && MapOptions.ghostsSeeTasks) { playerInfoText = $"{roleNames} {taskInfo}".Trim(); meetingInfoText = playerInfoText; } else if (MapOptions.ghostsSeeTasks) { playerInfoText = $"{taskInfo}".Trim(); meetingInfoText = playerInfoText; } else if (MapOptions.ghostsSeeRoles) { playerInfoText = $"{roleNames}"; meetingInfoText = playerInfoText; } playerInfo.text = playerInfoText; playerInfo.gameObject.SetActive(p.Visible); if (meetingInfo != null) { meetingInfo.text = MeetingHud.Instance.state == MeetingHud.VoteStates.Results ? "" : meetingInfoText; } } }