diff options
Diffstat (limited to 'Client/Assembly-CSharp/NotificationPopper.cs')
-rw-r--r-- | Client/Assembly-CSharp/NotificationPopper.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/NotificationPopper.cs b/Client/Assembly-CSharp/NotificationPopper.cs new file mode 100644 index 0000000..8a98115 --- /dev/null +++ b/Client/Assembly-CSharp/NotificationPopper.cs @@ -0,0 +1,58 @@ +using System; +using System.Text; +using UnityEngine; + +public class NotificationPopper : MonoBehaviour +{ + public TextRenderer TextArea; + + public float zPos = -350f; + + private float alphaTimer; + + public float ShowDuration = 5f; + + public float FadeDuration = 1f; + + public Color textColor = Color.white; + + private StringBuilder builder = new StringBuilder(); + + public AudioClip NotificationSound; + + public void Update() + { + if (this.alphaTimer > 0f) + { + float num = Camera.main.orthographicSize * Camera.main.aspect; + if (!DestroyableSingleton<HudManager>.Instance.TaskText.isActiveAndEnabled) + { + float height = DestroyableSingleton<HudManager>.Instance.GameSettings.Height; + Transform transform = DestroyableSingleton<HudManager>.Instance.GameSettings.transform; + base.transform.localPosition = new Vector3(-num + 0.1f, transform.localPosition.y - height, this.zPos); + } + else + { + float height2 = DestroyableSingleton<HudManager>.Instance.TaskText.Height; + Transform parent = DestroyableSingleton<HudManager>.Instance.TaskText.transform.parent; + base.transform.localPosition = new Vector3(-num + 0.1f, parent.localPosition.y - height2 - 0.2f, this.zPos); + } + this.alphaTimer -= Time.deltaTime; + this.textColor.a = Mathf.Clamp(this.alphaTimer / this.FadeDuration, 0f, 1f); + this.TextArea.Color = this.textColor; + if (this.alphaTimer <= 0f) + { + this.builder.Clear(); + this.TextArea.Text = string.Empty; + } + } + } + + public void AddItem(string item) + { + this.builder.AppendLine(item); + this.TextArea.Text = this.builder.ToString(); + this.alphaTimer = this.ShowDuration; + SoundManager.Instance.PlaySound(this.NotificationSound, false, 1f); + } +} |