diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-02-24 15:36:34 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-02-24 15:36:34 -0500 |
| commit | 2128897be0bb267e68b01cc6d9e94d3fe6faa8db (patch) | |
| tree | 8ff85615a61a220af8a916d732db693585608250 | |
| parent | 24b4fb4f8fa0392c8a44aefa734ff6d558f3583d (diff) | |
| download | manifold-garden-archipelago-2128897be0bb267e68b01cc6d9e94d3fe6faa8db.tar.gz manifold-garden-archipelago-2128897be0bb267e68b01cc6d9e94d3fe6faa8db.tar.bz2 manifold-garden-archipelago-2128897be0bb267e68b01cc6d9e94d3fe6faa8db.zip | |
Notifications fade one-by-one
| -rw-r--r-- | Notifications.cs | 20 |
1 files changed, 17 insertions, 3 deletions
| diff --git a/Notifications.cs b/Notifications.cs index 20e5e51..99db0bb 100644 --- a/Notifications.cs +++ b/Notifications.cs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | using System; | 1 | using System; |
| 2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
| 3 | using System.Linq; | ||
| 3 | using TMPro; | 4 | using TMPro; |
| 4 | using UnityEngine; | 5 | using UnityEngine; |
| 5 | 6 | ||
| @@ -30,19 +31,24 @@ namespace ManifoldGardenArchipelago | |||
| 30 | 31 | ||
| 31 | void Update() | 32 | void Update() |
| 32 | { | 33 | { |
| 33 | while (_notifications.Count > 0 && _notifications[_notifications.Count - 1].ReadyToBeDestroyed()) | 34 | if (_notifications.Count > 0 && _notifications[_notifications.Count - 1].ReadyToBeDestroyed()) |
| 34 | { | 35 | { |
| 35 | NotificationLine toDestroy = _notifications[_notifications.Count - 1]; | 36 | NotificationLine toDestroy = _notifications[_notifications.Count - 1]; |
| 36 | GameObject.Destroy(toDestroy.gameObject); | 37 | GameObject.Destroy(toDestroy.gameObject); |
| 37 | _notifications.RemoveAt(_notifications.Count - 1); | 38 | _notifications.RemoveAt(_notifications.Count - 1); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 41 | if (_notifications.Count > 0 && _notifications[_notifications.Count - 1].IsIdling()) | ||
| 42 | { | ||
| 43 | _notifications[_notifications.Count - 1].StopIdling(); | ||
| 44 | } | ||
| 45 | |||
| 40 | if (_queuedMessages.Count > 0) | 46 | if (_queuedMessages.Count > 0) |
| 41 | { | 47 | { |
| 42 | if (_notifications.Count > 0 && !_notifications[0].ReadyToBeSurplanted()) | 48 | if (_notifications.Count > 0 && !_notifications[0].ReadyToBeSurplanted()) |
| 43 | { | 49 | { |
| 44 | if (!_notifications[0].IsMoving() && | 50 | if (!_notifications[0].IsMoving() && |
| 45 | !(_notifications.Count >= MAX_VISIBLE && !_notifications[_notifications.Count - 1].IsFadingOut())) | 51 | _notifications.Count(n => !n.IsFadingOut()) < MAX_VISIBLE) |
| 46 | { | 52 | { |
| 47 | foreach (var notification in _notifications) | 53 | foreach (var notification in _notifications) |
| 48 | { | 54 | { |
| @@ -98,6 +104,7 @@ namespace ManifoldGardenArchipelago | |||
| 98 | private enum FadeState | 104 | private enum FadeState |
| 99 | { | 105 | { |
| 100 | FadingIn, | 106 | FadingIn, |
| 107 | Idling, | ||
| 101 | Waiting, | 108 | Waiting, |
| 102 | FadingOut, | 109 | FadingOut, |
| 103 | ReadyToDestroy, | 110 | ReadyToDestroy, |
| @@ -146,7 +153,7 @@ namespace ManifoldGardenArchipelago | |||
| 146 | { | 153 | { |
| 147 | if (_textMeshPro.alpha >= _alphaTarget) | 154 | if (_textMeshPro.alpha >= _alphaTarget) |
| 148 | { | 155 | { |
| 149 | _fadeState = FadeState.Waiting; | 156 | _fadeState = FadeState.Idling; |
| 150 | } | 157 | } |
| 151 | } | 158 | } |
| 152 | else if (_fadeState == FadeState.Waiting) | 159 | else if (_fadeState == FadeState.Waiting) |
| @@ -198,6 +205,13 @@ namespace ManifoldGardenArchipelago | |||
| 198 | _moveState = MoveState.Waiting; | 205 | _moveState = MoveState.Waiting; |
| 199 | } | 206 | } |
| 200 | 207 | ||
| 208 | public bool IsIdling() => _fadeState == FadeState.Idling; | ||
| 209 | |||
| 210 | public void StopIdling() | ||
| 211 | { | ||
| 212 | _fadeState = FadeState.Waiting; | ||
| 213 | } | ||
| 214 | |||
| 201 | public bool IsFadingOut() => _fadeState == FadeState.FadingOut; | 215 | public bool IsFadingOut() => _fadeState == FadeState.FadingOut; |
| 202 | 216 | ||
| 203 | public bool ReadyToBeDestroyed() => _fadeState == FadeState.ReadyToDestroy; | 217 | public bool ReadyToBeDestroyed() => _fadeState == FadeState.ReadyToDestroy; |
