void StartTween(TransitionItem item, float delay)
{
TransitionValue startValue;
TransitionValue endValue;
if (_reversed)
{
startValue = item.endValue;
endValue = item.startValue;
}
else
{
startValue = item.startValue;
endValue = item.endValue;
}
switch (item.type)
{
case TransitionActionType.XY:
case TransitionActionType.Size:
{
if (item.type == TransitionActionType.XY)
{
if (item.target == _owner)
{
if (!startValue.b1)
startValue.f1 = 0;
if (!startValue.b2)
startValue.f2 = 0;
}
else
{
if (!startValue.b1)
startValue.f1 = item.target.x;
if (!startValue.b2)
startValue.f2 = item.target.y;
}
}
else
{
if (!startValue.b1)
startValue.f1 = item.target.width;
if (!startValue.b2)
startValue.f2 = item.target.height;
}
item.value.f1 = startValue.f1;
item.value.f2 = startValue.f2;
if (!endValue.b1)
endValue.f1 = item.value.f1;
if (!endValue.b2)
endValue.f2 = item.value.f2;
item.value.b1 = startValue.b1 || endValue.b1;
item.value.b2 = startValue.b2 || endValue.b2;
item.tweener = DOTween.To(() => new Vector2(startValue.f1, startValue.f2),
val =>
{
item.value.f1 = val.x;
item.value.f2 = val.y;
}, new Vector2(endValue.f1, endValue.f2), item.duration);
}
break;
case TransitionActionType.Scale:
case TransitionActionType.Skew:
{
item.value.f1 = startValue.f1;
item.value.f2 = startValue.f2;
item.tweener = DOTween.To(() => new Vector2(startValue.f1, startValue.f2),
val =>
{
item.value.f1 = val.x;
item.value.f2 = val.y;
}, new Vector2(endValue.f1, endValue.f2), item.duration);
break;
}
case TransitionActionType.Alpha:
case TransitionActionType.Rotation:
{
item.value.f1 = startValue.f1;
item.tweener = DOTween.To(() => startValue.f1, v => item.value.f1 = v, endValue.f1, item.duration);
break;
}
case TransitionActionType.Color:
{
item.value.c = startValue.c;
item.tweener = DOTween.To(() => startValue.c, v => item.value.c = v, endValue.c, item.duration);
break;
}
case TransitionActionType.ColorFilter:
{
item.value.f1 = startValue.f1;
item.value.f2 = startValue.f2;
item.value.f3 = startValue.f3;
item.value.f4 = startValue.f4;
item.tweener = DOTween.To(() => new Vector4(startValue.f1, startValue.f2, startValue.f3, startValue.f4),
v =>
{
item.value.f1 = v.x;
item.value.f2 = v.y;
item.value.f3 = v.z;
item.value.f4 = v.w;
},
new Vector4(endValue.f1, endValue.f2, endValue.f3, endValue.f4), item.duration);
break;
}
}
item.tweener.SetEase(item.easeType)
.SetUpdate(true)
.OnStart(() => { if (item.hook != null) item.hook(); })
.OnUpdate(() => { ApplyValue(item, item.value); })
.OnComplete(() => { tweenComplete(item); });
if (delay > 0)
item.tweener.SetDelay(delay);
else
ApplyValue(item, item.value);
if (item.repeat != 0)
item.tweener.SetLoops(item.repeat == -1 ? int.MaxValue : (item.repeat + 1), item.yoyo ? LoopType.Yoyo : LoopType.Restart);
if (_timeScale != 1)
item.tweener.timeScale = _timeScale;
_totalTasks++;
item.completed = false;
}