using System; using System.Collections; using System.Collections.Generic; using System.Text; using InnerNet; using UnityEngine; public class HudManager : DestroyableSingleton { public Coroutine ReactorFlash { get; set; } public Coroutine OxyFlash { get; set; } public MeetingHud MeetingPrefab; public KillButtonManager KillButton; public UseButtonManager UseButton; public ReportButtonManager ReportButton; public TextRenderer GameSettings; public GameObject TaskStuff; public ChatController Chat; public DialogueBox Dialogue; public TextRenderer TaskText; public Transform TaskCompleteOverlay; private float taskDirtyTimer; public MeshRenderer ShadowQuad; public SpriteRenderer FullScreen; public SpriteRenderer MapButton; public KillOverlay KillOverlay; public IVirtualJoystick joystick; public MonoBehaviour[] Joysticks; public DiscussBehaviour discussEmblem; public ShhhBehaviour shhhEmblem; public IntroCutscene IntroPrefab; public OptionsMenuBehaviour GameMenu; public NotificationPopper Notifier; public RoomTracker roomTracker; public AudioClip SabotageSound; public AudioClip TaskCompleteSound; public AudioClip TaskUpdateSound; private StringBuilder tasksString = new StringBuilder(); public void Start() { this.SetTouchType(SaveManager.TouchConfig); } public void ShowTaskComplete() { base.StartCoroutine(this.CoTaskComplete()); } private IEnumerator CoTaskComplete() { if (Constants.ShouldPlaySfx()) { SoundManager.Instance.PlaySound(this.TaskCompleteSound, false, 1f); } this.TaskCompleteOverlay.gameObject.SetActive(true); yield return Effects.Slide2D(this.TaskCompleteOverlay, new Vector2(0f, -8f), Vector2.zero, 0.25f); for (float time = 0f; time < 0.75f; time += Time.deltaTime) { yield return null; } yield return Effects.Slide2D(this.TaskCompleteOverlay, Vector2.zero, new Vector2(0f, 8f), 0.25f); this.TaskCompleteOverlay.gameObject.SetActive(false); yield break; } public void SetJoystickSize(float size) { if (this.joystick != null && this.joystick is VirtualJoystick) { VirtualJoystick virtualJoystick = (VirtualJoystick)this.joystick; virtualJoystick.transform.localScale = new Vector3(size, size, 1f); AspectPosition component = virtualJoystick.GetComponent(); float num = Mathf.Lerp(0.65f, 1.1f, FloatRange.ReverseLerp(size, 0.5f, 1.5f)); component.DistanceFromEdge = new Vector3(num, num, -10f); component.AdjustPosition(); } } public void SetTouchType(int type) { if (this.joystick != null && !(this.joystick is KeyboardJoystick)) { UnityEngine.Object.Destroy((this.joystick as MonoBehaviour).gameObject); } MonoBehaviour monoBehaviour = UnityEngine.Object.Instantiate(this.Joysticks[Mathf.Clamp(type + 1, 1, this.Joysticks.Length)]); monoBehaviour.transform.SetParent(base.transform, false); this.joystick = monoBehaviour.GetComponent(); } public void OpenMap() { this.ShowMap(delegate(MapBehaviour m) { m.ShowNormalMap(); }); } public void ShowMap(Action mapAction) { if (!ShipStatus.Instance) { return; } if (!MapBehaviour.Instance) { MapBehaviour.Instance = UnityEngine.Object.Instantiate(ShipStatus.Instance.MapPrefab, base.transform); MapBehaviour.Instance.gameObject.SetActive(false); } mapAction(MapBehaviour.Instance); } public void SetHudActive(bool isActive) { DestroyableSingleton.Instance.UseButton.gameObject.SetActive(isActive); DestroyableSingleton.Instance.UseButton.Refresh(); DestroyableSingleton.Instance.ReportButton.gameObject.SetActive(isActive); GameData.PlayerInfo data = PlayerControl.LocalPlayer.Data; DestroyableSingleton.Instance.KillButton.gameObject.SetActive(isActive && data.IsImpostor && !data.IsDead); DestroyableSingleton.Instance.TaskText.transform.parent.gameObject.SetActive(isActive); } public void FixedUpdate() { this.taskDirtyTimer += Time.fixedDeltaTime; if (this.taskDirtyTimer > 0.25f) { this.taskDirtyTimer = 0f; if (!PlayerControl.LocalPlayer) { this.TaskText.Text = string.Empty; return; } GameData.PlayerInfo data = PlayerControl.LocalPlayer.Data; if (data == null) { return; } bool isImpostor = data.IsImpostor; this.tasksString.Clear(); if (PlayerControl.LocalPlayer.myTasks.Count == 0) { this.tasksString.Append("None"); } else { for (int i = 0; i < PlayerControl.LocalPlayer.myTasks.Count; i++) { PlayerTask playerTask = PlayerControl.LocalPlayer.myTasks[i]; if (playerTask) { if (playerTask.TaskType == TaskTypes.FixComms && !isImpostor) { this.tasksString.Clear(); playerTask.AppendTaskText(this.tasksString); break; } playerTask.AppendTaskText(this.tasksString); } } this.tasksString.TrimEnd(); } this.TaskText.Text = this.tasksString.ToString(); } } public IEnumerator ShowEmblem(bool shhh) { if (shhh) { this.shhhEmblem.gameObject.SetActive(true); yield return this.shhhEmblem.PlayAnimation(); this.shhhEmblem.gameObject.SetActive(false); } else { this.discussEmblem.gameObject.SetActive(true); yield return this.discussEmblem.PlayAnimation(); this.discussEmblem.gameObject.SetActive(false); } yield break; } public void StartReactorFlash() { if (this.ReactorFlash == null) { this.ReactorFlash = base.StartCoroutine(this.CoReactorFlash()); } } public void StartOxyFlash() { if (this.OxyFlash == null) { this.OxyFlash = base.StartCoroutine(this.CoReactorFlash()); } } public void ShowPopUp(string text) { this.Dialogue.Show(text); } public void StopReactorFlash() { if (this.ReactorFlash != null) { base.StopCoroutine(this.ReactorFlash); this.FullScreen.enabled = false; this.ReactorFlash = null; } } public void StopOxyFlash() { if (this.OxyFlash != null) { base.StopCoroutine(this.OxyFlash); this.FullScreen.enabled = false; this.OxyFlash = null; } } public IEnumerator CoFadeFullScreen(Color source, Color target, float duration = 0.2f) { if (this.FullScreen.enabled && this.FullScreen.color == target) { yield break; } this.FullScreen.enabled = true; for (float t = 0f; t < duration; t += Time.deltaTime) { this.FullScreen.color = Color.Lerp(source, target, t / duration); yield return null; } this.FullScreen.color = target; if (target.a < 0.05f) { this.FullScreen.enabled = false; } yield break; } private IEnumerator CoReactorFlash() { WaitForSeconds wait = new WaitForSeconds(1f); this.FullScreen.color = new Color(1f, 0f, 0f, 0.37254903f); for (;;) { this.FullScreen.enabled = !this.FullScreen.enabled; SoundManager.Instance.PlaySound(this.SabotageSound, false, 1f); yield return wait; } yield break; } public IEnumerator CoShowIntro(List yourTeam) { DestroyableSingleton.Instance.FullScreen.transform.localPosition = new Vector3(0f, 0f, -250f); yield return DestroyableSingleton.Instance.ShowEmblem(true); IntroCutscene introCutscene = UnityEngine.Object.Instantiate(this.IntroPrefab, base.transform); yield return introCutscene.CoBegin(yourTeam, PlayerControl.LocalPlayer.Data.IsImpostor); PlayerControl.LocalPlayer.SetKillTimer(10f); ((SabotageSystemType)ShipStatus.Instance.Systems[SystemTypes.Sabotage]).ForceSabTime(10f); yield return this.CoFadeFullScreen(Color.black, Color.clear, 0.2f); DestroyableSingleton.Instance.FullScreen.transform.localPosition = new Vector3(0f, 0f, -500f); yield break; } public void OpenMeetingRoom(PlayerControl reporter) { if (MeetingHud.Instance) { return; } Debug.Log("Opening meeting room: " + reporter); ShipStatus.Instance.RepairSystem(SystemTypes.Reactor, PlayerControl.LocalPlayer, 16); ShipStatus.Instance.RepairSystem(SystemTypes.LifeSupp, PlayerControl.LocalPlayer, 16); MeetingHud.Instance = UnityEngine.Object.Instantiate(this.MeetingPrefab); MeetingHud.Instance.ServerStart(reporter.PlayerId); AmongUsClient.Instance.Spawn(MeetingHud.Instance, -2, SpawnFlags.None); } }