Files
SVSimServer/SVSim.BattleEngine/Engine/TweenPositionY.cs
gamer147 824309ec44 feat(battle-engine): close the AI-simulation subsystem (verbatim)
Copied the 89 uncopied AI*SimulationUtility/extension files defining the
AIVirtualCard/AIVirtualField extension methods; the compile loop then auto-closed
the revealed type deps (~3049 files total, drift-clean). 10.0k -> 62 errors.
2026-06-05 20:30:59 -04:00

135 lines
2.6 KiB
C#

using System;
using UnityEngine;
[AddComponentMenu("NGUI/Tween/Tween Position Y")]
public class TweenPositionY : UITweener
{
public float from;
public float to;
[HideInInspector]
public bool worldSpace;
private Transform mTrans;
private UIRect mRect;
public Transform cachedTransform
{
get
{
if (mTrans == null)
{
mTrans = base.transform;
}
return mTrans;
}
}
[Obsolete("Use 'value' instead")]
public float positionY
{
get
{
return Yvalue;
}
set
{
Yvalue = value;
}
}
public float Yvalue
{
get
{
if (!worldSpace)
{
return cachedTransform.localPosition.y;
}
return cachedTransform.position.y;
}
set
{
if (mRect == null || !mRect.isAnchored || worldSpace)
{
if (worldSpace)
{
cachedTransform.position = new Vector3(cachedTransform.position.x, value, cachedTransform.position.z);
}
else
{
cachedTransform.localPosition = new Vector3(cachedTransform.localPosition.x, value, cachedTransform.localPosition.z);
}
}
else
{
value -= cachedTransform.localPosition.y;
NGUIMath.MoveRect(mRect, 0f, value);
}
}
}
private void Awake()
{
mRect = GetComponent<UIRect>();
}
protected override void OnUpdate(float factor, bool isFinished)
{
Yvalue = from * (1f - factor) + to * factor;
}
public static TweenPosition Begin(GameObject go, float duration, Vector3 pos)
{
TweenPosition tweenPosition = UITweener.Begin<TweenPosition>(go, duration);
tweenPosition.from = tweenPosition.value;
tweenPosition.to = pos;
if (duration <= 0f)
{
tweenPosition.Sample(1f, isFinished: true);
tweenPosition.enabled = false;
}
return tweenPosition;
}
public static TweenPosition Begin(GameObject go, float duration, Vector3 pos, bool worldSpace)
{
TweenPosition tweenPosition = UITweener.Begin<TweenPosition>(go, duration);
tweenPosition.worldSpace = worldSpace;
tweenPosition.from = tweenPosition.value;
tweenPosition.to = pos;
if (duration <= 0f)
{
tweenPosition.Sample(1f, isFinished: true);
tweenPosition.enabled = false;
}
return tweenPosition;
}
[ContextMenu("Set 'From' to current value")]
public override void SetStartToCurrentValue()
{
from = Yvalue;
}
[ContextMenu("Set 'To' to current value")]
public override void SetEndToCurrentValue()
{
to = Yvalue;
}
[ContextMenu("Assume value of 'From'")]
private void SetCurrentValueToStart()
{
Yvalue = from;
}
[ContextMenu("Assume value of 'To'")]
private void SetCurrentValueToEnd()
{
Yvalue = to;
}
}