Archived
添加了一些用于名称切换数据,可以满足随机名称的要求
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓动步进库
|
||||
/// </summary>
|
||||
public static class MacroInching
|
||||
{
|
||||
/// <summary>
|
||||
/// 线性步进
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static double LinearTowards(double from, double to, double maxStepDelta)
|
||||
{
|
||||
return from + Math.Clamp(to - from, -maxStepDelta, maxStepDelta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 线性步进
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static float LinearTowards(float from, float to, float maxStepDelta)
|
||||
{
|
||||
return (float)LinearTowards((double)from, (double)to, (double)maxStepDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dde2a3b263805b34db3b546fd5922f43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,5 @@
|
||||
using Codice.CM.Triggers;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -129,7 +131,7 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
#endregion
|
||||
|
||||
#region 应用算法
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取列表中随机顺序的对象
|
||||
/// </summary>
|
||||
@@ -144,6 +146,24 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
yield return list[index[i]];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对列表中的成员按组进行划分,并读取特定组中特定索引下的成员
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> GetListGroupMember<T>(this List<T> list, int group, int target)
|
||||
{
|
||||
if(list.Count % group != 0)
|
||||
throw new Exception("在进行列组成员获取时,组不能刚好整除列表总数");
|
||||
|
||||
for(int i = 0; i < list.Count; i++)
|
||||
if((i % group) == target)
|
||||
yield return list[i];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// 矢量宏库
|
||||
/// </summary>
|
||||
[Obsolete("与扩展库放在一起,不要单独出现")]
|
||||
public static class MacroVector3
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取与世界正交轴最近的一条轴线
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static Vector3 GetWorldNormalAxis(Vector3 vector)
|
||||
{
|
||||
Vector3[] axes = { Vector3.right, Vector3.up, Vector3.forward };
|
||||
float minAngle = float.MaxValue;
|
||||
Vector3 minAngleAxis = Vector3.zero;
|
||||
|
||||
foreach(Vector3 axis in axes)
|
||||
{
|
||||
float dot = Vector3.Dot(vector, axis);
|
||||
float angle = Mathf.Abs(dot);
|
||||
if(angle < minAngle)
|
||||
{
|
||||
minAngle = angle;
|
||||
minAngleAxis = axis * Mathf.Sign(dot);
|
||||
}
|
||||
}
|
||||
|
||||
return minAngleAxis;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
{
|
||||
public static class Vector2Extend
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector2 OneMinus(this Vector2 a)
|
||||
=> new Vector2(1 - a.x, 1 - a.y);
|
||||
|
||||
[Obsolete("unfinished")]
|
||||
public static Vector2 Projection(this Vector2 point, Vector3 start, Vector3 end)
|
||||
{
|
||||
|
||||
@@ -107,6 +107,10 @@ namespace XericLibrary.Runtime.MacroLibrary
|
||||
a.z / b
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 OneMinus(this Vector3 a)
|
||||
=> new Vector3(1 - a.x, 1 - a.y, 1 - a.z);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展运算
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 332399c09755e3f41936f1931f08654f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.Type
|
||||
{
|
||||
/// <summary>
|
||||
/// 矢量方位
|
||||
/// </summary>
|
||||
public enum Vector3Orientation
|
||||
{
|
||||
Front,
|
||||
Back,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
/// <summary>
|
||||
/// 矢量方位
|
||||
/// </summary>
|
||||
public enum Vector2Orientation
|
||||
{
|
||||
UpFront,
|
||||
DownBack,
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ namespace XericLibrary.Runtime.Type
|
||||
/// <summary>
|
||||
/// 梯度列表,默认其中的元素都是从小到大的,且数量不小于1
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private List<GradientPoint<T>> gradientList;
|
||||
|
||||
public int Count => gradientList.Count;
|
||||
@@ -184,6 +185,25 @@ namespace XericLibrary.Runtime.Type
|
||||
return gradientList.Count - 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个可以随权重变化的调整率
|
||||
/// </summary>
|
||||
/// <param name="edge0"></param>
|
||||
/// <param name="edge1"></param>
|
||||
/// <param name="x"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSmoothstep(float edge0, float edge1, float x, float k)
|
||||
{
|
||||
x = Mathf.Clamp01((x - edge0) / (edge1 - edge0));
|
||||
//return x * x * (3f - 2f * x);
|
||||
return Mathf.Pow(x, k);
|
||||
}
|
||||
|
||||
public float GetSmoothstep(float x, float k)
|
||||
{
|
||||
return GetSmoothstep(0, 1, x, k);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -200,21 +220,25 @@ namespace XericLibrary.Runtime.Type
|
||||
/// <summary>
|
||||
/// 横轴坐标
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public float x;
|
||||
|
||||
/// <summary>
|
||||
/// 纵轴取值
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public K y;
|
||||
|
||||
/// <summary>
|
||||
/// 与上一个项目的权重
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public float WeightPrev;
|
||||
|
||||
/// <summary>
|
||||
/// 与下一个项目的权重
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public float WeightNext;
|
||||
|
||||
#endregion
|
||||
@@ -274,6 +298,11 @@ namespace XericLibrary.Runtime.Type
|
||||
return thisWeight;
|
||||
}
|
||||
|
||||
public float GetAdjacentRarioSimpleWeight(GradientPoint<K> next, out float nextWeight)
|
||||
{
|
||||
nextWeight = next.WeightPrev / Mathf.Max(this.WeightNext + next.WeightPrev, float.MinValue);
|
||||
return 1 - nextWeight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -338,8 +367,8 @@ namespace XericLibrary.Runtime.Type
|
||||
{
|
||||
protected internal override Color GetAdjacentGradientMixWithWeight(GradientPoint<Color> point1, GradientPoint<Color> point2, float value)
|
||||
{
|
||||
var weight1 = point1.GetAdjacentRatioWeight(point2, out var weight2);
|
||||
return Color.Lerp(point1.y * weight1, point2.y * weight2, value);
|
||||
var weight1 = point1.GetAdjacentRarioSimpleWeight(point2, out var weight2);
|
||||
return Color.Lerp(point1.y, point2.y, GetSmoothstep(value, weight1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2ba6a3dd88427d4e8ae8dc465957ffa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
using XericLibrary.Runtime.MacroLibrary;
|
||||
|
||||
namespace XericLibrary.Runtime.Type
|
||||
{
|
||||
public static class GreekLetteList
|
||||
{
|
||||
private readonly static List<string> GreekLettes = new List<string>()
|
||||
{
|
||||
"Α", "Alpha", "阿尔法",
|
||||
"Β", "Beta", "贝塔",
|
||||
"Γ", "Gamma", "伽玛",
|
||||
"Δ", "Delta", "德尔塔",
|
||||
"Ε", "Epsilon", "伊普西隆",
|
||||
"Ζ", "Zeta", "戈塔",
|
||||
"Η", "Eta", "伊塔",
|
||||
"Θ", "Theta", "西塔",
|
||||
"Ι", "Iota", "约塔",
|
||||
"Κ", "Kappa", "卡帕",
|
||||
"Λ", "Lambda", "兰布达",
|
||||
"Μ", "Mu", "缪",
|
||||
"Ν", "Nu", "纽",
|
||||
"Ξ", "Xi", "克西",
|
||||
"Ο", "Omicron", "奥米克戎",
|
||||
"Π", "Pi", "派",
|
||||
"Ρ", "Rho", "肉",
|
||||
"Σ", "Sigma", "西格玛",
|
||||
"Τ", "Tau", "陶",
|
||||
"Υ", "Upsilon", "豫普西隆",
|
||||
"Φ", "Phi", "斐",
|
||||
"Χ", "Chi", "喜",
|
||||
"Ψ", "Psi", "普赛",
|
||||
"Ω", "Omega", "欧米伽",
|
||||
};
|
||||
|
||||
private static int FeatureGroup = 3;
|
||||
|
||||
/// <summary>
|
||||
/// 获取希腊字母
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> GreekLetteCharacters()
|
||||
=> GreekLettes.GetListGroupMember(FeatureGroup, 0);
|
||||
|
||||
/// <summary>
|
||||
/// 获取希腊字母全拼
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> GreekLetteEnglishNames()
|
||||
=> GreekLettes.GetListGroupMember(FeatureGroup, 1);
|
||||
|
||||
/// <summary>
|
||||
/// 获取希腊字母读音
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> GreekLetteChineseNames()
|
||||
=> GreekLettes.GetListGroupMember(FeatureGroup, 2);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad5f4cc8676b1ac42b5535a3e3ee0a9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XericLibrary.Runtime.Type
|
||||
{
|
||||
public static class TalosLetteList
|
||||
{
|
||||
private readonly static List<string> GreekLettes = new List<string>()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e256a1300ce9c4409524c457629262a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.lrss3.xericlibrary",
|
||||
"displayName": "Xeric Library",
|
||||
"version": "0.2.410",
|
||||
"version": "0.2.412",
|
||||
"unity": "2021.3",
|
||||
"description": "\u901a\u7528\u5e93\u63d2\u4ef6\u3002"
|
||||
}
|
||||
Reference in New Issue
Block a user