Ver.0.3.0.33

This commit is contained in:
2025-07-08 08:32:46 +00:00
parent 99f4dd67c2
commit 0ad5e29917
6831 changed files with 695623 additions and 234455 deletions
-63
View File
@@ -1,63 +0,0 @@
using System.Collections;
using AibisDream.Framework;
using UnityEngine;
namespace AibisDream.Utility
{
public class AutoFlipBool
{
private readonly float _delayTime;
private readonly bool _initValue;
private bool _value;
private bool _isActive;
private Coroutine _flipCoroutine;
public bool Value
{
get => _value;
set
{
if (value == _initValue)
{
// 如果与初始value相同,直接变化即可
_value = value;
}
else
{
// 如果与初始Value不同,则一段时间后需要翻回来
_value = value;
if (_flipCoroutine != null)
{
MonoCenter.Mono.StopCoroutine(_flipCoroutine);
}
_flipCoroutine = MonoCenter.Mono.StartCoroutine(Flip());
}
}
}
private IEnumerator Flip()
{
yield return new WaitForSeconds(_delayTime);
_value = _initValue;
// 协程置空标识已完成
_flipCoroutine = null;
}
/// <summary>
/// 改变后隔一段时间自动翻转回来
/// </summary>
/// <param name="delayTime">延迟时间/秒</param>
/// <param name="initValue">初始值</param>
public AutoFlipBool(float delayTime, bool initValue = false)
{
_delayTime = delayTime;
_initValue = initValue;
_value = initValue;
}
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 9bcd5b1d15f64d70a655fa6e59f93e94
timeCreated: 1732613970
+89 -11
View File
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
@@ -69,17 +70,37 @@ namespace AibisDream.Utility
}
/// <summary>
/// 获取鼠标在世界中的位置
/// 步进循环
/// </summary>
/// <param name="mousePoint">鼠标界面位置</param>
/// <param name="transform">物体形状</param>
/// <returns>世界位置</returns>
public static Vector3 GetMouseWorldPos(Vector3 mousePoint, Transform transform)
/// <param name="target">操作数</param>
/// <param name="min">最小值</param>
/// <param name="max">最大值</param>
/// <param name="step">步进</param>
/// <returns></returns>
/// <exception cref="ArgumentException">范围错误</exception>
public static int LoopStep(int target, int min, int max, int step = 1)
{
if (!_mainCam) _mainCam = Camera.main;
if (min > max)
{
throw new ArgumentException("min should be less than or equal to max.");
}
mousePoint.z = _mainCam.WorldToScreenPoint(transform.position).z;
return _mainCam.ScreenToWorldPoint(mousePoint);
var range = max - min + 1;
// 计算新的目标值
var newTarget = target + step;
// 计算结果在范围内的值
if (newTarget > max)
{
newTarget = min + (newTarget - max - 1) % range;
}
else if (newTarget < min)
{
newTarget = max - (min - newTarget - 1) % range;
}
return newTarget;
}
/// <summary>
@@ -95,7 +116,7 @@ namespace AibisDream.Utility
foreach (var sourceField in sourceFields)
{
if (sourceField.IsStatic) return;
var targetField = targetFields.FirstOrDefault(p =>
p.Name == sourceField.Name && p.FieldType == sourceField.FieldType);
if (targetField != null && !targetField.IsStatic())
@@ -105,6 +126,16 @@ namespace AibisDream.Utility
}
}
/// <summary>
/// 角度转换
/// </summary>
/// <param name="angle">180度角</param>
/// <returns>360度角</returns>
public static float Angle360(float angle)
{
return angle < 0 ? angle + 360 : angle;
}
#region
public static T As<T>(this object selfObj) where T : class
@@ -135,7 +166,18 @@ namespace AibisDream.Utility
}
#endregion
///<summary>
/// 去除原始对话中名称部分
/// </summary>
/// <param name="lineText">对话原文</param>
/// <returns>去除名称后结果</returns>
public static string RemoveName(string lineText)
{
var textArr = lineText.Split(":");
return textArr.Length > 1 ? textArr[1].Trim() : lineText;
}
/// <summary>
/// 拆分字符串为若干行
/// </summary>
@@ -159,7 +201,21 @@ namespace AibisDream.Utility
while (currentIndex < line.Length)
{
var length = Math.Min(maxCharsPerLine, line.Length - currentIndex);
result.Append(line.Substring(currentIndex, length));
var substring = line.Substring(currentIndex, length);
// 检查是否需要调整长度以避免在单词中间断开
if (currentIndex + length < line.Length && !char.IsWhiteSpace(line[currentIndex + length]) &&
!char.IsPunctuation(line[currentIndex + length]))
{
var lastSpace = substring.LastIndexOf(' ');
if (lastSpace > 0)
{
length = lastSpace;
substring = line.Substring(currentIndex, length);
}
}
result.Append(substring.TrimStart());
currentIndex += length;
if (currentIndex < line.Length)
@@ -179,5 +235,27 @@ namespace AibisDream.Utility
return result.ToString();
}
public static Vector2 GetPivotByType(PivotType pivotType)
{
return pivotType switch
{
PivotType.Top => new Vector2(0.5f, 1),
PivotType.Bottom => new Vector2(0.5f, 0),
PivotType.Left => new Vector2(0, 0.5f),
PivotType.Right => new Vector2(1, 0.5f),
PivotType.TopLeft => new Vector2(0, 1),
PivotType.TopRight => new Vector2(1, 1),
PivotType.BottomLeft => new Vector2(0, 0),
PivotType.BottomRight => new Vector2(1, 0),
PivotType.Center => new Vector2(0.5f, 0.5f),
_ => Vector2.zero
};
}
public static string Escape(string rawText)
{
return rawText.Replace("^", "#").Replace("[[", "{").Replace("]]", "}");
}
}
}
+55
View File
@@ -0,0 +1,55 @@
using UnityEngine;
namespace AibisDream.Utility
{
public static class ConstRef
{
public const string QQURL = "https://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=XQFpOqRb1_zqkCdR2bLT3kHb11XzZ54T" +
"&authKey=w8G8qxzecnATXDOec1Ybv8LA%2FTTN8gQkyegvbK%2FUZ9m90WxggTjXy2U6%2FJes" +
"WJF3&noverify=0&group_code=325268983";
public const string BugSurveyURL = "https://wj.qq.com/s2/18309384/e356/";
public const string SurveyURL = "https://wj.qq.com/s2/15348910/3c8c/";
public static readonly string TestSaveFilePath = Application.streamingAssetsPath + "/TestSaveFiles";
#region
public const string UITextTable = "UIText";
public const string ActorNameTable = "ActorName";
#endregion
#region
public const string CutLinePrefabName = "CutLine";
public const string TaskItemName = "Task Item Temp";
public const string GearFollowerPrefabName = "GearFollower";
public const string ScreenTextName = "Screen Text";
public const string ActorPrefabName = "ActorAnima";
public const string SpriteActorPrefabName = "SpriteActor";
public const string MobileAnima = "AnimaMobileObject";
public const string MobileSprite = "SpriteMobileObject";
public const string MobileObject = "PrefabMobileObject";
public const string BubblePrefab = "NormalBubble";
#endregion
#region
public const float TweenEndY = -10;
public const float FallSpeed = 10;
#endregion
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b7d5dc10d6784924a322b8968a6488d6
timeCreated: 1744355327
-89
View File
@@ -1,89 +0,0 @@
using System.Collections;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
namespace AibisDream
{
public class FadeImage : IFadeObject
{
private readonly Image _image;
public FadeImage(Image rawImage)
{
_image = rawImage;
}
#region
public void Show()
{
_image.gameObject.SetActive(true);
_image.color = Color.white;
}
public void Hide()
{
_image.gameObject.SetActive(false);
_image.color = Color.clear;
}
public void SwitchImage(string imagePath)
{
_image.sprite = Resources.Load<Sprite>(imagePath);
}
#endregion
#region
public void FadeIn(float duration)
{
_image.gameObject.SetActive(true);
_image.DOBlendableColor(Color.white, duration);
}
public IEnumerator FadeInSync(float duration)
{
_image.gameObject.SetActive(true);
var tweener = _image.DOBlendableColor(Color.white, duration);
while (tweener.active && !tweener.IsComplete())
{
yield return null;
}
}
#endregion
#region
public void FadeOut(float duration)
{
_image.gameObject.SetActive(true);
_image.DOBlendableColor(Color.clear, duration).onComplete += () =>
{
_image.gameObject.SetActive(false);
};
}
public IEnumerator FadeOutSync(float duration)
{
_image.gameObject.SetActive(true);
var tweener = _image.DOBlendableColor(Color.clear, duration);
while (tweener.active && !tweener.IsComplete())
{
yield return null;
}
_image.gameObject.SetActive(false);
}
#endregion
public IEnumerator MoveTo(Vector3 targetPos, float duration)
{
Debug.Log("Image 不能移动");
yield return null;
}
}
}
-11
View File
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ce86e728ca463254688faafec721fd9f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
-74
View File
@@ -1,74 +0,0 @@
using System.Collections;
using DG.Tweening;
using UnityEngine;
namespace AibisDream
{
public class FadeSprite : IFadeObject
{
private readonly SpriteRenderer _spriteRenderer;
public FadeSprite(SpriteRenderer spriteRenderer)
{
_spriteRenderer = spriteRenderer;
}
public void FadeIn(float duration)
{
_spriteRenderer.gameObject.SetActive(true);
_spriteRenderer.DOFade(1, duration);
}
public void FadeOut(float duration)
{
_spriteRenderer.DOFade(0, duration).onComplete += () => { _spriteRenderer.gameObject.SetActive(false); };
}
public IEnumerator FadeInSync(float duration)
{
_spriteRenderer.gameObject.SetActive(true);
var tweener = _spriteRenderer.DOFade(1, duration);
while (tweener.active && !tweener.IsComplete())
{
yield return null;
}
}
public IEnumerator FadeOutSync(float duration)
{
var tweener = _spriteRenderer.DOFade(0, duration);
while (tweener.active && !tweener.IsComplete())
{
yield return null;
}
_spriteRenderer.gameObject.SetActive(false);
}
public void Show()
{
_spriteRenderer.gameObject.SetActive(true);
_spriteRenderer.color = Color.white;
}
public void Hide()
{
_spriteRenderer.color = Color.clear;
_spriteRenderer.gameObject.SetActive(false);
}
public void SwitchImage(string imagePath)
{
_spriteRenderer.sprite = Resources.Load<Sprite>("Art/Character/" + imagePath);
}
public IEnumerator MoveTo(Vector3 targetPos, float duration)
{
var tweenerCore = _spriteRenderer.transform.DOMove(targetPos, duration);
if (!tweenerCore.IsComplete())
{
yield return null;
}
}
}
}
-11
View File
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e8c049bfbc820124489ebe2a0e3ff11b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
namespace AibisDream.Utility
{
public static class GlobalVariableKit
{
public static bool IsPlugHighLight
{
get => !(StorageSystem.Instance.TryGetValue("$global.IsPlugHighLight", out bool res) && res);
set => StorageSystem.Instance.SetValue("$global.IsPlugHighLight", !value);
}
public static bool IsCordHighLight
{
get => !(StorageSystem.Instance.TryGetValue("$global.IsCurdHighLight", out bool res) && res);
set => StorageSystem.Instance.SetValue("$global.IsCurdHighLight", !value);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b6a872bd61bd49a3b4ee49f42549ac00
timeCreated: 1743581640
-24
View File
@@ -1,24 +0,0 @@
using System.Collections;
using UnityEngine;
namespace AibisDream
{
public interface IFadeObject
{
public void FadeIn(float duration);
public void FadeOut(float duration);
public IEnumerator FadeInSync(float duration);
public IEnumerator FadeOutSync(float duration);
public void Show();
public void Hide();
public IEnumerator MoveTo(Vector3 targetPos, float duration);
public void SwitchImage(string imagePath);
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: a061d00e22f608d46a3f97b1ee02632a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -44,6 +44,15 @@ namespace AibisDream.Utility
return JsonConvert.DeserializeObject<T>(json);
}
public static T ReadBeanByText<T>(string text)
{
if (!text.StartsWith("{"))
{
text = "{" + text + "}";
}
return JsonConvert.DeserializeObject<T>(text);
}
/// <summary>
/// 按路径加载Json
/// </summary>
@@ -0,0 +1,7 @@
namespace AibisDream.Utility
{
public static class StaticResourceKit
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c0eb947b5fbb4c7ea256e2cb19a9ee96
timeCreated: 1743581623