mirror of
https://github.com/Xevion/Boids.git
synced 2025-12-06 11:14:25 -06:00
changed bool based stance locking to tween start counting system with _UILock property
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -31,7 +32,11 @@ public class UIController : MonoBehaviour {
|
|||||||
private CanvasScaler _scaler;
|
private CanvasScaler _scaler;
|
||||||
private Rect _canvasRect;
|
private Rect _canvasRect;
|
||||||
private float _scaleFactor;
|
private float _scaleFactor;
|
||||||
private bool _UILock;
|
private int _activeTweens;
|
||||||
|
private bool _UILock {
|
||||||
|
get => _activeTweens > 0;
|
||||||
|
set { }
|
||||||
|
}
|
||||||
|
|
||||||
// Element Displacements
|
// Element Displacements
|
||||||
private Vector3 _aboutDiff;
|
private Vector3 _aboutDiff;
|
||||||
@@ -92,16 +97,21 @@ public class UIController : MonoBehaviour {
|
|||||||
ChangeStance(UIStance.Title);
|
ChangeStance(UIStance.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnlockStanceChange() {
|
|
||||||
Debug.Log("Unlocking stance changes");
|
private void TweenEnd() {
|
||||||
_UILock = false;
|
_activeTweens -= 1;
|
||||||
|
if(!_UILock)
|
||||||
|
Debug.Log("Unlocking Stance Changes");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LockStanceChange() {
|
private Action StartTween() {
|
||||||
Debug.Log("Locking stance changes");
|
if(!_UILock)
|
||||||
_UILock = true;
|
Debug.Log("Locking Stance Changes");
|
||||||
|
_activeTweens += 1;
|
||||||
|
return TweenEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ChangeStance(UIStance stance) {
|
private void ChangeStance(UIStance stance) {
|
||||||
// Quit early if UI is currently "locked" due to an active tween
|
// Quit early if UI is currently "locked" due to an active tween
|
||||||
if (_UILock || stance == _currentUI)
|
if (_UILock || stance == _currentUI)
|
||||||
@@ -158,9 +168,6 @@ public class UIController : MonoBehaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void MoveElements(UIGroup group, bool away) {
|
private void MoveElements(UIGroup group, bool away) {
|
||||||
// Disable changing of stances until all tweens are complete
|
|
||||||
LockStanceChange();
|
|
||||||
|
|
||||||
switch (group) {
|
switch (group) {
|
||||||
case UIGroup.TitleScreen:
|
case UIGroup.TitleScreen:
|
||||||
// Main Title and Start/Settings Buttons
|
// Main Title and Start/Settings Buttons
|
||||||
@@ -169,7 +176,7 @@ public class UIController : MonoBehaviour {
|
|||||||
.move(element, element.transform.position + _titleDiff * (away ? 1 : -1), away ? 0.65f : 1.15f)
|
.move(element, element.transform.position + _titleDiff * (away ? 1 : -1), away ? 0.65f : 1.15f)
|
||||||
.setDelay(away ? 0f : 0.35f)
|
.setDelay(away ? 0f : 0.35f)
|
||||||
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic)
|
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic)
|
||||||
.setOnComplete(UnlockStanceChange);
|
.setOnComplete(StartTween());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottom Right About Button
|
// Bottom Right About Button
|
||||||
@@ -185,7 +192,7 @@ public class UIController : MonoBehaviour {
|
|||||||
adjPanelGo.transform.position + _adjustmentsDiff * (away ? 1 : -1), 1.15f)
|
adjPanelGo.transform.position + _adjustmentsDiff * (away ? 1 : -1), 1.15f)
|
||||||
.setDelay(away ? 0f : 0.15f)
|
.setDelay(away ? 0f : 0.15f)
|
||||||
.setEase(LeanTweenType.easeInOutCubic)
|
.setEase(LeanTweenType.easeInOutCubic)
|
||||||
.setOnComplete(UnlockStanceChange);
|
.setOnComplete(StartTween());
|
||||||
break;
|
break;
|
||||||
case UIGroup.AboutScreen:
|
case UIGroup.AboutScreen:
|
||||||
LeanTween
|
LeanTween
|
||||||
@@ -193,7 +200,7 @@ public class UIController : MonoBehaviour {
|
|||||||
away ? 0.6f : 1f)
|
away ? 0.6f : 1f)
|
||||||
.setDelay(away ? 0f : 0.40f)
|
.setDelay(away ? 0f : 0.40f)
|
||||||
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic)
|
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic)
|
||||||
.setOnComplete(UnlockStanceChange);
|
.setOnComplete(StartTween());
|
||||||
break;
|
break;
|
||||||
case UIGroup.SettingsScreen:
|
case UIGroup.SettingsScreen:
|
||||||
LeanTween
|
LeanTween
|
||||||
@@ -201,7 +208,7 @@ public class UIController : MonoBehaviour {
|
|||||||
away ? 0.7f : 1.1f)
|
away ? 0.7f : 1.1f)
|
||||||
.setDelay(away ? 0.05f : 0.15f)
|
.setDelay(away ? 0.05f : 0.15f)
|
||||||
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic)
|
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic)
|
||||||
.setOnComplete(UnlockStanceChange);
|
.setOnComplete(StartTween());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(@group), @group, null);
|
throw new ArgumentOutOfRangeException(nameof(@group), @group, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user