using System.Collections.Generic; using System.Linq; using Cysharp.Threading.Tasks; using DG.Tweening; using UnityEngine; public static class ArrayUtils { // const List<> public static List UIEasing = new List() { Ease.InBack, Ease.InSine, Ease.InQuad, Ease.InCirc, Ease.InExpo }; public static T RandomPick(this List pickedArray) { int rnd = Random.Range(0, pickedArray.Count); return pickedArray[rnd]; } public static T WeightPick(this List pickedArray, List weight = null) { if (weight == null || weight.Count == 0) { weight = (from t in pickedArray select 1).ToList(); } var totalWeight = weight.Sum(); int rnd = Random.Range(0, totalWeight); for (int i = 0; i < pickedArray.Count; i++) { rnd -= weight[i]; if (rnd < 0) { return pickedArray[i]; } } return pickedArray[^1]; } }