@@ -118,12 +118,13 @@ namespace Ichni.Story
|
||||
/// <summary>点击 Helper 的统一入口:播放反馈后创建一条新的专属气泡。</summary>
|
||||
private void HandleHelperClicked()
|
||||
{
|
||||
if (Time.unscaledTime < _nextClickTime)
|
||||
return;
|
||||
if (Time.unscaledTime > _nextClickTime)
|
||||
{
|
||||
_nextClickTime = Time.unscaledTime + clickCooldown;
|
||||
TryCreateRandomTalk();
|
||||
|
||||
_nextClickTime = Time.unscaledTime + clickCooldown;
|
||||
}
|
||||
PlayClickAnimation();
|
||||
TryCreateRandomTalk();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -10,15 +10,15 @@ namespace Ichni.UI
|
||||
{
|
||||
public ValueModifier valueModifier;
|
||||
public RectTransform sliderBackground;
|
||||
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
valueModifier.SetValue(valueModifier.GetNearestValue(GetPercentage(eventData.position)));
|
||||
valueModifier.SetValue(valueModifier.GetNearestValue(GetPercentage(eventData.position)), true);
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
valueModifier.SetValue(valueModifier.GetNearestValue(GetPercentage(eventData.position)));
|
||||
valueModifier.SetValue(valueModifier.GetNearestValue(GetPercentage(eventData.position)), true);
|
||||
}
|
||||
|
||||
private float GetPercentage(Vector2 inputPosition)
|
||||
@@ -46,7 +46,7 @@ namespace Ichni.UI
|
||||
|
||||
return percentage;
|
||||
}
|
||||
|
||||
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using I2.Loc;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -15,17 +16,17 @@ namespace Ichni.UI
|
||||
public int intStep;
|
||||
public int intMin;
|
||||
public int intMax;
|
||||
|
||||
|
||||
public ModifyValueButton increaseButton;
|
||||
public ModifyValueButton decreaseButton;
|
||||
public TMP_Text valueText;
|
||||
|
||||
public Image barImage;
|
||||
|
||||
|
||||
public string prefix;
|
||||
public string suffix;
|
||||
public bool showPositiveMark;
|
||||
|
||||
|
||||
public void SetUp(int initialValue, int step, string title = "")
|
||||
{
|
||||
intStep = step;
|
||||
@@ -33,19 +34,21 @@ namespace Ichni.UI
|
||||
intMax = int.MaxValue;
|
||||
|
||||
base.SetUp(title);
|
||||
|
||||
|
||||
increaseButton.SetUpButton(IncreaseValue, IncreaseValue);
|
||||
decreaseButton.SetUpButton(DecreaseValue, DecreaseValue);
|
||||
SetValue(initialValue);
|
||||
UpdateValueText();
|
||||
}
|
||||
|
||||
|
||||
public void SetMinMax(int min, int max)
|
||||
{
|
||||
intMin = Convert.ToInt32(min);
|
||||
intMax = Convert.ToInt32(max);
|
||||
UpdateValueText();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void SetPrefixAndSuffix(string prefix, string suffix, bool showPositiveMark)
|
||||
{
|
||||
this.showPositiveMark = showPositiveMark;
|
||||
@@ -62,42 +65,50 @@ namespace Ichni.UI
|
||||
int valueRange = intMax - intMin;
|
||||
int stepCount = Mathf.RoundToInt(percentage * valueRange / intStep);
|
||||
int nearestValue = intMin + stepCount * intStep;
|
||||
|
||||
|
||||
return nearestValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public partial class ValueModifier
|
||||
{
|
||||
public void SetValue(int value)
|
||||
public void SetValue(int value, bool usingAnimation = false)
|
||||
{
|
||||
intValue = Convert.ToInt32(value);
|
||||
intValue = Mathf.Clamp(intValue, intMin, intMax);
|
||||
|
||||
UpdateValueText();
|
||||
|
||||
if (usingAnimation) UpdateValueTextTween(); else UpdateValueText();
|
||||
}
|
||||
|
||||
|
||||
public void IncreaseValue()
|
||||
{
|
||||
intValue += intStep;
|
||||
intValue = Mathf.Clamp(intValue, intMin, intMax);
|
||||
|
||||
UpdateValueText();
|
||||
SetValue(intValue + 1, true);
|
||||
}
|
||||
|
||||
|
||||
public void DecreaseValue()
|
||||
{
|
||||
intValue -= intStep;
|
||||
intValue = Mathf.Clamp(intValue, intMin, intMax);
|
||||
|
||||
UpdateValueText();
|
||||
SetValue(intValue - 1, true);
|
||||
}
|
||||
|
||||
|
||||
public void UpdateValueText()
|
||||
{
|
||||
|
||||
valueText.text = prefix + (showPositiveMark && intValue > 0 ? "+" : "") + intValue.ToString() + suffix;
|
||||
barImage.rectTransform.sizeDelta = new Vector2((float)(intValue - intMin) / (intMax - intMin) * 660, 20);
|
||||
|
||||
var target = new Vector2((float)(intValue - intMin) / (intMax - intMin) * 660, 20);
|
||||
barImage.rectTransform.sizeDelta = target;
|
||||
updateValueAction?.Invoke();
|
||||
}
|
||||
|
||||
private Tween tween;
|
||||
private int LastValue = -1;
|
||||
public void UpdateValueTextTween()
|
||||
{
|
||||
if (LastValue == intValue) return;
|
||||
tween?.Complete();
|
||||
valueText.text = prefix + (showPositiveMark && intValue > 0 ? "+" : "") + intValue.ToString() + suffix;
|
||||
var target = new Vector2((float)(intValue - intMin) / (intMax - intMin) * 660, 20);
|
||||
tween = barImage.rectTransform.DOSizeDelta(target, 0.2f).SetEase(Ease.OutExpo).Play();
|
||||
LastValue = intValue;
|
||||
updateValueAction?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
@@ -171,22 +171,22 @@ namespace Ichni.UI
|
||||
expansionBackground.gameObject.SetActive(true);
|
||||
}));
|
||||
expandSequence.Join(DOTween.To(() => layoutElement.preferredWidth,
|
||||
x => layoutElement.preferredWidth = x, 1147, 0.3f));
|
||||
expandSequence.Join(avatarMask.rectTransform.DOSizeDelta(new Vector2(1147, 826), 0.3f));
|
||||
expandSequence.Join(titleRect.DOSizeDelta(new Vector2(0, 100), 0.3f));
|
||||
expandSequence.Append(expansionInfos.GetComponent<CanvasGroup>().DOFade(1, 0.3f)
|
||||
x => layoutElement.preferredWidth = x, 1147, 0.3f).SetEase(Ease.OutExpo));
|
||||
expandSequence.Join(avatarMask.rectTransform.DOSizeDelta(new Vector2(1147, 826), 0.3f).SetEase(Ease.OutExpo));
|
||||
expandSequence.Join(titleRect.DOSizeDelta(new Vector2(0, 100), 0.3f).SetEase(Ease.OutExpo));
|
||||
expandSequence.Append(expansionInfos.GetComponent<CanvasGroup>().DOFade(1, 0.3f).SetEase(Ease.OutExpo)
|
||||
.OnStart(() =>
|
||||
{
|
||||
expansionInfos.gameObject.SetActive(true);
|
||||
}));
|
||||
expandSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(1, 0.3f)
|
||||
expandSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(1, 0.3f).SetEase(Ease.OutExpo)
|
||||
.OnStart(() =>
|
||||
{
|
||||
expansionFunctions.gameObject.SetActive(true);
|
||||
}));
|
||||
|
||||
expandSequence.Join(bottomTip.DOFade(1f, 0.3f));
|
||||
expandSequence.Join(upperTip.DOFade(1f, 0.3f));
|
||||
expandSequence.Join(bottomTip.DOFade(1f, 0.3f).SetEase(Ease.OutExpo));
|
||||
expandSequence.Join(upperTip.DOFade(1f, 0.3f).SetEase(Ease.OutExpo));
|
||||
|
||||
expandSequence.OnStart(() => isDuringAnimation = true);
|
||||
expandSequence.OnComplete(() =>
|
||||
@@ -194,8 +194,8 @@ namespace Ichni.UI
|
||||
isDuringAnimation = false;
|
||||
expansionRipple.material.SetFloat("_RippleTime", 0f);
|
||||
rippleSequence = DOTween.Sequence();
|
||||
rippleSequence.AppendInterval(5f);
|
||||
rippleSequence.Append(expansionRipple.material.DOFloat(1, "_RippleTime", 2f));
|
||||
rippleSequence.AppendInterval(5f);
|
||||
rippleSequence.SetLoops(-1);
|
||||
rippleSequence.Play();
|
||||
});
|
||||
@@ -211,31 +211,31 @@ namespace Ichni.UI
|
||||
|
||||
Sequence shrinkSequence = DOTween.Sequence();
|
||||
|
||||
shrinkSequence.Append(bottomTip.DOFade(0f, 0.3f));
|
||||
shrinkSequence.Join(upperTip.DOFade(0f, 0.3f));
|
||||
shrinkSequence.Append(bottomTip.DOFade(0f, 0.3f).SetEase(Ease.OutExpo));
|
||||
shrinkSequence.Join(upperTip.DOFade(0f, 0.3f).SetEase(Ease.OutExpo));
|
||||
|
||||
shrinkSequence.Join(expansionInfos.GetComponent<CanvasGroup>().DOFade(0, 0.3f)
|
||||
shrinkSequence.Join(expansionInfos.GetComponent<CanvasGroup>().DOFade(0, 0.3f).SetEase(Ease.OutExpo)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
expansionInfos.gameObject.SetActive(false);
|
||||
}));
|
||||
shrinkSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(0, 0.3f)
|
||||
shrinkSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(0, 0.3f).SetEase(Ease.OutExpo)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
expansionFunctions.gameObject.SetActive(false);
|
||||
}));
|
||||
|
||||
shrinkSequence.Join(titleRect.DOSizeDelta(new Vector2(322, 100), 0.3f));
|
||||
shrinkSequence.Join(titleRect.DOSizeDelta(new Vector2(322, 100), 0.3f).SetEase(Ease.OutExpo));
|
||||
|
||||
shrinkSequence.Append(expansionBackground.DOSizeDelta(new Vector2(322, 826), 0.3f)
|
||||
shrinkSequence.Append(expansionBackground.DOSizeDelta(new Vector2(322, 826), 0.3f).SetEase(Ease.OutExpo)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
expansionBackground.gameObject.SetActive(false);
|
||||
}));
|
||||
|
||||
shrinkSequence.Join(DOTween.To(() => layoutElement.preferredWidth,
|
||||
x => layoutElement.preferredWidth = x, 322, 0.3f));
|
||||
shrinkSequence.Join(avatarMask.rectTransform.DOSizeDelta(new Vector2(322, 826), 0.3f));
|
||||
x => layoutElement.preferredWidth = x, 322, 0.3f).SetEase(Ease.OutExpo));
|
||||
shrinkSequence.Join(avatarMask.rectTransform.DOSizeDelta(new Vector2(322, 826), 0.3f).SetEase(Ease.OutExpo));
|
||||
|
||||
shrinkSequence.OnStart(() => isDuringAnimation = true);
|
||||
shrinkSequence.OnComplete(() => isDuringAnimation = false);
|
||||
|
||||
Reference in New Issue
Block a user