bingo 项目提交

This commit is contained in:
2026-04-20 13:49:36 +08:00
commit ad5920ac6a
5585 changed files with 1216243 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
using System;
using FairyGUI;
using UnityEngine;
using BingoBrain.Asset;
using BingoBrain;
using UnityEngine.Events;
using System.Collections.Generic;
public class EyesHarmony
{
private static Dictionary<string, NTexture> nTexturesDic = new();
public static void GetPicture(string path, string name, UnityAction<NTexture> action)
{
if (!nTexturesDic.TryGetValue(path + name, out NTexture spr))
{
try
{
BetKit.Instance.LoadSprite(path, name, sprite =>
{
if (sprite != null)
{
spr = new NTexture(sprite);
action?.Invoke(spr);
nTexturesDic.TryAdd(path + name, spr);
}
});
}
catch (Exception e)
{
Debug.LogError(e);
}
}
else
{
action?.Invoke(spr);
}
}
public static void SetAvatarToLoader(int avatarId, GLoader _GLoader, bool IsNeedDefAvatar = true)
{
Sprite sprite = null;
BetKit.Instance.LoadSprite("Atlas.Avatar", avatarId.ToString(), (spr) =>
{
sprite = spr;
var spr1 = new NTexture(sprite);
_GLoader.texture = spr1;
// nTexturesDic.Add(avatarId.ToString(), spr1);
});
}
public static void GetItem(int itemId, UnityAction<NTexture> action)
{
var itemIconPath = "Atlas.Item";
string name = itemId.ToString();
if (GameHelper.IsGiftSwitch())
{
if (name == "102") name = "106";
}
// else
// {
// // if (itemId is 102 or 106)
// // {
// // name += "_normal";
// // }
// }
GetPicture(itemIconPath, name, action);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9fd5ef95c27f44cc8b171cbc1bfc7f7f
timeCreated: 1681806348
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 389d5ae709869439791f7004522f9a32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+347
View File
@@ -0,0 +1,347 @@
using System;
using FairyGUI;
using System.Text;
using UnityEngine;
using System.Collections.Generic;
using Application = UnityEngine.Application;
using Random = UnityEngine.Random;
namespace BingoBrain
{
public static class GlobalHarmony
{
public static bool IsChance(float chance)
{
var value = Random.Range(0, 1f);
return value <= chance;
}
public static void Active(this Component component, bool isActive)
{
component.gameObject.SetActive(isActive);
}
public static string GetAppSavePath()
{
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
return Application.streamingAssetsPath;
#elif UNITY_IOS
return Application.persistentDataPath;
#endif
}
public static GTweener In(GObject obj, float duration = 0.3f, float delay = 0)
{
if (obj == null) return null;
obj.alpha = 0.5f;
return obj.TweenFade(1, duration).SetDelay(delay);
}
public static GTweener Out(GObject obj, float duration = 0.3f, float delay = 0)
{
if (obj == null) return null;
obj.alpha = 1;
return obj.TweenFade(0f, duration).SetDelay(delay);
}
private static float clickTime;
public static bool NoQuick()
{
if (Time.time < clickTime)
{
clickTime = Time.time + 0.1f;
return false;
}
clickTime = Time.time + 0.3f;
return true;
}
public static void CheckClick(GObject button, Action action, bool isNetworkCheck = false,
bool isQuickClickCheck = true)
{
button?.onClick.Set(() =>
{
if (isQuickClickCheck && !NoQuick())
{
return;
}
action?.Invoke();
});
}
public static string FormatDate(int second, CountDownType countDownType = CountDownType.Second,
string dayFormat = "")
{
var result = new StringBuilder();
if (second < 0)
{
second = 0;
}
if (countDownType == CountDownType.Second)
{
result.Append(second);
return result.ToString();
}
int tmpSecond;
if (second >= 60)
{
tmpSecond = second % 60;
}
else
{
tmpSecond = second;
}
result.Append(tmpSecond);
if (tmpSecond < 10)
{
result.Insert(0, 0);
}
int tmpMin = second / 60;
if (countDownType == CountDownType.Minute)
{
result.Insert(0, ":");
result.Insert(0, tmpMin);
return result.ToString();
}
int tmpHour = tmpMin / 60;
if (countDownType == CountDownType.Hour)
{
if (tmpMin >= 60)
{
tmpMin %= 60;
}
result.Insert(0, ":");
result.Insert(0, tmpMin);
if (tmpMin < 10)
{
result.Insert(0, 0);
}
result.Insert(0, ":");
result.Insert(0, tmpHour);
if (tmpHour < 10)
{
result.Insert(0, 0);
}
return result.ToString();
}
int tmpDay = tmpHour / 24;
if (countDownType == CountDownType.Day)
{
if (tmpMin >= 60)
{
tmpMin %= 60;
}
result.Insert(0, ":");
result.Insert(0, tmpMin);
if (tmpMin < 10)
{
result.Insert(0, 0);
}
if (tmpHour >= 24)
{
tmpHour %= 24;
}
result.Insert(0, ":");
result.Insert(0, tmpHour);
if (tmpHour < 10)
{
result.Insert(0, 0);
}
if (string.IsNullOrEmpty(dayFormat))
{
dayFormat = "Days";
}
result.Insert(0, $" {dayFormat} ");
result.Insert(0, tmpDay);
}
return result.ToString();
}
public static T GetRandomList<T>(IList<T> list)
{
if (list.Count == 0)
{
return default(T);
}
int index = UnityEngine.Random.Range(0, list.Count);
return list[index];
}
public static List<int> tmpIndexList = new List<int>();
public static List<T> GetRandomList<T>(List<T> list, int num, bool returnMax = true)
{
if (list.Count < num)
{
if (returnMax)
{
num = list.Count;
}
else
{
return null;
}
}
tmpIndexList.Clear();
List<T> tempList = new List<T>();
for (int i = 0; i < num; i++)
{
int index = UnityEngine.Random.Range(0, list.Count);
while (tmpIndexList.Contains(index))
{
index = UnityEngine.Random.Range(0, list.Count);
}
tmpIndexList.Add(index);
}
foreach (var index in tmpIndexList)
{
tempList.Add(list[index]);
}
return tempList;
}
public static int RandomWeight(int[] weights)
{
int val = UnityEngine.Random.Range(1, 101);
int temp = 0;
for (int i = 0; i < weights.Length; i++)
{
int tar = weights[i];
temp += tar;
if (val <= temp)
{
return i;
}
}
return -1;
}
public static int GetChanceList(List<float> chanceList)
{
float total = 0;
for (int i = 0; i < chanceList.Count; i++)
{
total += chanceList[i];
}
float result = Random.Range(0, total);
float tmpTotal = 0;
for (int i = 0; i < chanceList.Count; i++)
{
float chance = chanceList[i];
tmpTotal += chance;
if (result < tmpTotal)
{
return i;
}
}
if (chanceList.Count > 0)
{
return chanceList.Count - 1;
}
return -1;
}
public static string FormatJson(string sourceJson)
{
sourceJson += " ";
var index = 0;
var newJson = new StringBuilder();
for (int i = 0; i < sourceJson.Length - 1; i++)
{
if (sourceJson[i] == '{' || sourceJson[i] == '[')
{
index++;
newJson.Append(sourceJson[i]);
newJson.Append("\n");
for (var a = 0; a < index; a++)
{
newJson.Append("\t");
}
}
else if ((sourceJson[i] == '}' || sourceJson[i] == ']'))
{
index--;
newJson.Append("\n");
for (var a = 0; a < index; a++)
{
newJson.Append("\t");
}
newJson.Append(sourceJson[i]);
newJson.Append(sourceJson[i + 1] == ',' ? "," : "");
newJson.Append("\n");
if (sourceJson[i + 1] == ',') i++;
for (int a = 0; a < index; a++)
{
newJson.Append("\t");
}
}
else if (sourceJson[i] != '}' && sourceJson[i] != ']' && sourceJson[i + 1] == ',')
{
newJson.Append(sourceJson[i]);
newJson.Append(sourceJson[i + 1]);
newJson.Append("\n");
i++;
for (var a = 0; a < index; a++)
{
newJson.Append("\t");
}
}
else
{
newJson.Append(sourceJson[i]);
}
}
return newJson.ToString();
}
public static void ForEachSafe<TK, TV>(this Dictionary<TK, TV> dict, Action<TK, TV> action)
{
var keys = new List<TK>(dict.Keys);
for (var i = 0; i < dict.Count; i++)
{
var temp = dict[keys[i]];
action?.Invoke(keys[i],temp);
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 503da24caec74f59a9df8b84a7635133
timeCreated: 1681803914