Files
SVSimServer/SVSim.BattleEngine/Engine/UITweenAlpha.cs
gamer147 957af3d1ec feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
2026-06-05 17:22:20 -04:00

243 lines
3.8 KiB
C#

using UnityEngine;
public class UITweenAlpha : MonoBehaviour
{
public delegate void FinishCallBack(UITweenAlpha in_FadeObject);
public AnimationCurve _curve;
public bool _autoStart;
public float _from;
public float _to;
public float _delayTime;
public float _endTime;
public bool _loop;
public bool PingPong;
public UITweenAlpha[] LinkTargets;
private UIPanel _panel;
private UIWidget _uiWidget;
private UIRect _rect;
private bool _isPlay;
private bool _isEnd;
private bool _isPlayFoward;
private bool _initialized;
private float _value;
public FinishCallBack _finishCallBack { get; set; }
public float Timer { get; set; }
private void Awake()
{
if (!_initialized)
{
Initialize();
}
}
private void Initialize()
{
_initialized = true;
_panel = base.gameObject.GetComponent<UIPanel>();
if (_panel != null)
{
_rect = _panel;
}
else
{
_uiWidget = base.gameObject.GetComponent<UIWidget>();
if (_uiWidget == null && _panel == null)
{
_uiWidget = base.gameObject.AddComponent<UIWidget>();
}
_rect = _uiWidget;
}
if (_autoStart)
{
PlayForward(isReset: true);
}
if (LinkTargets == null)
{
return;
}
for (int i = 0; i < LinkTargets.Length; i++)
{
if (LinkTargets[i].isActiveAndEnabled)
{
Timer = LinkTargets[i].Timer;
break;
}
}
}
private void Update()
{
if (_isPlay)
{
Timer += Time.deltaTime;
if (Timer >= _delayTime)
{
float b = (Timer - _delayTime) / (_curve.keys[_curve.length - 1].time * _endTime);
b = Mathf.Min(_curve.keys[_curve.length - 1].time, b);
if (_isPlayFoward)
{
_value = _from + (_to - _from) * _curve.Evaluate(b);
}
else
{
_value = _from + (_to - _from) * _curve.Evaluate(_curve.keys[_curve.length - 1].time - b);
}
_rect.alpha = _value;
if (b >= _curve.keys[_curve.length - 1].time)
{
if (_isPlayFoward)
{
_rect.alpha = _to;
}
else
{
_rect.alpha = _from;
}
if (PingPong)
{
Timer = 0f;
if (_isPlayFoward)
{
_isPlayFoward = false;
}
else
{
_isPlayFoward = true;
}
}
else if (!_loop)
{
_isPlay = false;
_isEnd = true;
}
else
{
Timer = 0f;
}
}
}
}
if (_isEnd)
{
if (_finishCallBack != null)
{
_finishCallBack(this);
}
_isEnd = false;
}
}
public void Cancel(bool isFrom = false, bool isTo = false)
{
_isPlay = false;
if (isFrom)
{
_rect.alpha = _from;
}
else if (isTo)
{
_rect.alpha = _to;
}
}
public void PlayForward(bool isReset = false)
{
if (!base.gameObject.activeSelf)
{
return;
}
if (!_initialized)
{
Initialize();
}
if (_curve == null)
{
return;
}
_isPlayFoward = true;
if (isReset)
{
_rect.alpha = _from;
}
if (!_loop)
{
if (_rect.alpha != _to || isReset)
{
_isPlay = true;
Timer = 0f;
}
else
{
_isEnd = true;
}
}
else
{
_isPlay = true;
Timer = 0f;
}
}
public void PlayReverse(bool isReset = false)
{
if (!base.gameObject.activeSelf || _curve == null)
{
return;
}
_isPlayFoward = false;
if (isReset)
{
_rect.alpha = _to;
}
if (!_loop)
{
if (_rect.alpha != _from || isReset)
{
_isPlay = true;
Timer = 0f;
}
else
{
_isEnd = true;
}
}
else
{
_isPlay = true;
Timer = 0f;
}
}
public void End()
{
if (_isPlay)
{
_isPlay = false;
if (_finishCallBack != null)
{
_finishCallBack(this);
}
}
}
}