2023-12-13 16:20:41 +08:00
|
|
|
|
using cfg.VihecleCultivateCfg;
|
2023-11-15 15:23:27 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
2023-11-09 14:59:56 +08:00
|
|
|
|
using Framework;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using Gameplay.Character.Utils;
|
2023-11-09 14:59:56 +08:00
|
|
|
|
using Gameplay.Level;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using NLDPB;
|
|
|
|
|
|
using PhxhSDK;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using System;
|
2023-11-09 14:59:56 +08:00
|
|
|
|
using System.Collections.Generic;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using System.Collections.Specialized;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
using System.IO;
|
2024-01-11 18:32:08 +08:00
|
|
|
|
using System.Linq;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
2023-12-12 13:35:56 +08:00
|
|
|
|
using cfg.CharacterCfg;
|
2023-12-13 16:20:41 +08:00
|
|
|
|
using Gameplay.Unit;
|
2023-11-09 14:59:56 +08:00
|
|
|
|
using UnityEngine;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using UnityEngine.Networking;
|
2023-11-09 14:59:56 +08:00
|
|
|
|
using UnityEngine.UI;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using Constants = Framework.Constants;
|
2023-12-21 15:47:46 +08:00
|
|
|
|
using Object = UnityEngine.Object;
|
2023-12-27 16:28:40 +08:00
|
|
|
|
using cfg.ActorCfg;
|
2024-01-11 18:32:08 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
using Random = UnityEngine.Random;
|
2024-01-16 14:10:09 +08:00
|
|
|
|
using cfg.ErrorCfg;
|
2024-02-22 19:47:38 +08:00
|
|
|
|
using cfg.FightCfg;
|
|
|
|
|
|
using cfg.LevelCfg;
|
2024-01-17 16:49:32 +08:00
|
|
|
|
using Gameplay.SubSystems;
|
2024-02-21 17:54:08 +08:00
|
|
|
|
using PhxhSDK.Res;
|
2024-04-30 14:12:20 +08:00
|
|
|
|
using Gameplay.Performance;
|
2024-03-26 19:28:14 +08:00
|
|
|
|
using Gameplay.Utils;
|
2024-05-06 16:46:00 +08:00
|
|
|
|
using static MapData;
|
|
|
|
|
|
using static Gameplay.Level.LevelData;
|
2024-05-29 16:36:30 +08:00
|
|
|
|
using Gameplay.Guide;
|
2024-06-25 18:53:27 +08:00
|
|
|
|
using Gameplay.Common;
|
2024-09-24 19:44:37 +08:00
|
|
|
|
using System.Runtime.Remoting.Metadata.W3cXsd2001;
|
2024-12-11 19:30:20 +08:00
|
|
|
|
using cfg.SkillCfg;
|
2025-01-03 13:25:22 +08:00
|
|
|
|
using cfg.StringCfg;
|
|
|
|
|
|
using Gameplay.Net;
|
2025-01-03 14:54:25 +08:00
|
|
|
|
using Gameplay.Skill;
|
|
|
|
|
|
using Gameplay.Vehicle.Impl;
|
2024-12-25 12:40:51 +08:00
|
|
|
|
using UnityEditor;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
2023-12-05 12:49:29 +08:00
|
|
|
|
namespace Gameplay
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
public partial class CommonUtils
|
|
|
|
|
|
{
|
2024-08-15 13:31:51 +08:00
|
|
|
|
private static RenderTexture screenTexture;
|
2024-08-13 14:29:50 +08:00
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
private static readonly int MainTex = Shader.PropertyToID("_MainTex");
|
|
|
|
|
|
private static readonly int BlurSize = Shader.PropertyToID("_BlurSize");
|
|
|
|
|
|
private static readonly int ForceGray = Shader.PropertyToID("_ForceGray");
|
2023-10-26 20:20:11 +08:00
|
|
|
|
private const string ICON_WEATHER_PREFIX = "Icon_Weather_";
|
|
|
|
|
|
private const string ICON_ENVIRONMENT_PREFIX = "Icon_Environment_";
|
|
|
|
|
|
private const string ICON_DAYNIGHT_PREFIX = "Icon_Daynight_";
|
2024-02-23 16:13:25 +08:00
|
|
|
|
private const string SCREEN_SNAPSHOT = "ScreenSnapshot";
|
2024-08-15 13:31:51 +08:00
|
|
|
|
|
|
|
|
|
|
public static Texture2D GetScreenTexture2D()
|
|
|
|
|
|
{
|
|
|
|
|
|
Texture2D texture2D = new(screenTexture.width, screenTexture.height);
|
|
|
|
|
|
RenderTexture.active = screenTexture;
|
|
|
|
|
|
texture2D.ReadPixels(new Rect(0f, 0f, screenTexture.width, screenTexture.height), 0, 0);
|
|
|
|
|
|
texture2D.Apply();
|
|
|
|
|
|
RenderTexture.active = null;
|
|
|
|
|
|
|
|
|
|
|
|
return texture2D;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public static void DestoryGameObjectImmediate(ref GameObject obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (null != obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject.DestroyImmediate(obj);
|
|
|
|
|
|
obj = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
public static string GetInternaitionalStr(int strId, string str)
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
return str;
|
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
|
|
public static GameObject GetGameObject(GameObject gameObject, string path)
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform tra = gameObject.transform.Find(path);
|
|
|
|
|
|
return null != tra ? tra.gameObject : null;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static T GetComponent<T>(GameObject gameObject, string path = null) where T : Component
|
|
|
|
|
|
{
|
|
|
|
|
|
T result = null;
|
|
|
|
|
|
if (null == gameObject)
|
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
DebugUtil.LogWarning("ParentObjectisNUll: {0}", path);
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (null != path)
|
|
|
|
|
|
result = gameObject.transform.Find(path).gameObject.GetComponent<T>();
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
|
|
result = gameObject.GetComponent<T>();
|
|
|
|
|
|
if (result == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log(path);
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
//获取对象子节点中最上层的那个组件
|
|
|
|
|
|
public static T GetChildComponent<T>(GameObject go) where T : Component
|
|
|
|
|
|
{
|
|
|
|
|
|
T result = null;
|
|
|
|
|
|
if (!go)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogWarning("ParentObjectisNUll: {0}", go.name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var trans = go.transform;
|
|
|
|
|
|
for (int i = 0; i < trans.childCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var child = trans.GetChild(i);
|
|
|
|
|
|
var cmp = child.GetComponent<T>();
|
|
|
|
|
|
if (cmp)
|
|
|
|
|
|
{
|
|
|
|
|
|
result = cmp;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
//递归搜索子节点的子节点,返回最上层那个
|
|
|
|
|
|
result = GetChildComponent<T>(child.gameObject);
|
|
|
|
|
|
if (result)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2023-11-09 14:59:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public static void DestoryAllChildGameObject(GameObject parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parent != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
int count = parent.transform.childCount;
|
|
|
|
|
|
List<Transform> childs = new List<Transform>();
|
|
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
childs.Add(parent.transform.GetChild(i));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject.DestroyImmediate(childs[i].gameObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
//???????????
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public static string GetWholeHeadPath(string name)
|
|
|
|
|
|
{
|
2023-12-19 12:25:19 +08:00
|
|
|
|
return TableManager.Instance.Tables.GlobalConfig.HeadPicFrontPath + name + ".png";
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-10-23 15:08:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 默认头像路径(建议使用GetCharacterPicPath方法)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="uid"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2023-12-11 15:12:43 +08:00
|
|
|
|
public static string GetDefaultHeadPathByUid(uint uid)
|
|
|
|
|
|
{
|
2024-10-23 15:08:29 +08:00
|
|
|
|
DebugUtil.Log("获取默认头像路径!如需按选中皮肤显示头像,点击这里查看建议更新方法");
|
|
|
|
|
|
|
|
|
|
|
|
//如需更新代码可以参考这段代码
|
|
|
|
|
|
//var characterInfo = CharacterDataInfoManager.Instance.GetCharacterInfo(uid);
|
|
|
|
|
|
//var spritePath = CommonUtils.GetCharacterPicPath((int)uid, CommonUtils.ECharacterPicPathType.HeadPic, (int)characterInfo.SkinID);
|
|
|
|
|
|
|
2023-12-11 15:12:43 +08:00
|
|
|
|
var cfg = TableManager.Instance.Tables.CharacterAttri.GetOrDefault((int)uid);
|
|
|
|
|
|
if (cfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("--- 无法获取UID对应的配置 ---");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
2024-06-25 18:53:27 +08:00
|
|
|
|
var skinIdx = GLConfig.Inst.data.DEFAULTSKINID;
|
2023-12-11 15:12:43 +08:00
|
|
|
|
var dataSkin = TableManager.Instance.Tables.SkinCfg.Get(skinIdx, cfg.RoleID);
|
|
|
|
|
|
return GetWholeHeadPath(dataSkin.PIcHeadPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-03 16:09:24 +08:00
|
|
|
|
public static string GetDefaultVehicleHeadPath(uint uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
var cfg = TableManager.Instance.Tables.VehicleConfig.GetOrDefault((int)uid);
|
|
|
|
|
|
if (cfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("--- 无法获取UID对应的配置 ---");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-31 14:30:54 +08:00
|
|
|
|
return "Assets/Art/UI/Texture/Icon/Vehicle/HeadPic/" + cfg.UIHeadPath;
|
2024-01-03 16:09:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-12 16:47:23 +08:00
|
|
|
|
public static string GetCharacterName(int RoleId)
|
|
|
|
|
|
{
|
|
|
|
|
|
var str = "character_name" + RoleId;
|
|
|
|
|
|
return GetLocalizeText(str);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-14 14:35:15 +08:00
|
|
|
|
public static Army GetArmyByCfg(DataCharacterAttri cfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
var FactionDetail = cfg.FacDetail;
|
|
|
|
|
|
var facCfg = TableManager.Instance.Tables.FactionAttri.GetOrDefault(FactionDetail);
|
|
|
|
|
|
if (facCfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("--- 无法获取阵营对应的配置 ---");
|
|
|
|
|
|
return default;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return facCfg.Amy;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static Efaction GetEfactionByCfg(DataCharacterAttri cfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
var FactionDetail = cfg.FacDetail;
|
|
|
|
|
|
var facCfg = TableManager.Instance.Tables.FactionAttri.GetOrDefault(FactionDetail);
|
|
|
|
|
|
if (facCfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("--- 无法获取阵营对应的配置 ---");
|
|
|
|
|
|
return default;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return facCfg.FactionEnum;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-12-12 13:35:56 +08:00
|
|
|
|
public static Ejob GetProfessionByUid(uint uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
var cfg = TableManager.Instance.Tables.CharacterAttri.GetOrDefault((int)uid);
|
|
|
|
|
|
if (cfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("--- 无法获取UID对应的配置 ---");
|
|
|
|
|
|
return default;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return cfg.Job;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
//????????
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public static string GetWholeLiHuiPath(string name)
|
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
return Constants.UI_POSTER_DEFAULT_PATH + name + ".png";
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
public static string GetVehicleHeadPath(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return name + ".png";
|
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public enum ECharacterPicPathType
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-04-02 14:18:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 养成主界面用,大半身图
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Cultivate,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 好感度界面用,全身立绘
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Favorable,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 技能升级界面用,全身不同尺寸立绘
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
LevelUp,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 选择角色界面用,半身
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
SelectCharacter,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 立绘查看界面用,全身
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Poster,
|
2024-06-21 15:06:21 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 看板娘立绘,该立绘图片仅人物无背景
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
AssistantPoster,
|
2024-10-23 15:08:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 角色头像
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
HeadPic,
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-14 16:41:05 +08:00
|
|
|
|
public static string GetCharacterPicPath(int id, ECharacterPicPathType eCharacterPicPathType, int skinID = 1)
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
cfg.CharacterCfg.SkinCfg postCfg = TableManager.Instance.Tables.SkinCfg;
|
2024-03-14 16:41:05 +08:00
|
|
|
|
if (postCfg.Get(skinID, id) == null)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("该id的posterCfg尚未配置", id);
|
|
|
|
|
|
return @"Assets/Art/UI/Texture/UI_Pic_Main/UI_Poster/Cutivate/Poster_Cul_001.png";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-09-14 14:01:44 +08:00
|
|
|
|
string name;
|
|
|
|
|
|
string[] split;
|
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
|
switch (eCharacterPicPathType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case ECharacterPicPathType.Cultivate:
|
2024-09-14 15:01:28 +08:00
|
|
|
|
name = postCfg.Get(1, id).Cultivate;
|
|
|
|
|
|
split = name.Split('_');
|
2024-10-12 18:57:49 +08:00
|
|
|
|
if (split[1].Equals("Special"))
|
2024-09-14 15:01:28 +08:00
|
|
|
|
{
|
2024-10-16 14:46:41 +08:00
|
|
|
|
return @"Assets/Art/UI/Texture/UI_Pic_Main/UI_Poster/Special/" + postCfg.Get(skinID, id).Cultivate + ".png";
|
2024-09-14 15:01:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
return Constants.UI_POSTER_DEFAULT_PATH + postCfg.Get(1, id).Cultivate + ".png";
|
2023-08-22 19:08:45 +08:00
|
|
|
|
case ECharacterPicPathType.Favorable:
|
2024-09-14 15:01:28 +08:00
|
|
|
|
name = postCfg.Get(1, id).Favorable;
|
|
|
|
|
|
split = name.Split('_');
|
2024-10-12 18:57:49 +08:00
|
|
|
|
if (split[1].Equals("Special"))
|
2024-09-14 15:01:28 +08:00
|
|
|
|
{
|
2024-10-16 14:46:41 +08:00
|
|
|
|
return @"Assets/Art/UI/Texture/UI_Pic_Main/UI_Poster/Special/" + postCfg.Get(skinID, id).Favorable + ".png";
|
2024-09-14 15:01:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
return Constants.UI_POSTER_DEFAULT_PATH + postCfg.Get(1, id).Favorable + ".png";
|
2023-08-22 19:08:45 +08:00
|
|
|
|
case ECharacterPicPathType.LevelUp:
|
2024-09-14 14:16:19 +08:00
|
|
|
|
name = postCfg.Get(1, id).LevelUp;
|
2024-09-14 14:01:44 +08:00
|
|
|
|
split = name.Split('_');
|
|
|
|
|
|
if (split[1].Equals("Lu"))
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("该角色使用旧版立绘资源配置:" + id);
|
2024-10-16 14:46:41 +08:00
|
|
|
|
return @"Assets/Art/UI/Texture/UI_Pic_Main/UI_Poster/LevelUp/" + postCfg.Get(skinID, id).LevelUp + ".png";
|
2024-09-14 14:01:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-10-16 16:48:48 +08:00
|
|
|
|
return @"Assets/Art/UI/Texture/UI_Pic_Main/UI_Poster/Special/" + postCfg.Get(skinID, id).LevelUp + ".png";
|
2023-08-22 19:08:45 +08:00
|
|
|
|
case ECharacterPicPathType.SelectCharacter:
|
2024-09-14 14:01:44 +08:00
|
|
|
|
name = postCfg.Get(1, id).SelectCharacter;
|
|
|
|
|
|
split = name.Split('_');
|
2024-09-13 13:52:45 +08:00
|
|
|
|
if (split[1].Equals("SC"))
|
|
|
|
|
|
{
|
2024-10-23 15:08:29 +08:00
|
|
|
|
DebugUtil.Log("该角色使用旧版立绘资源配置:" + id);
|
2024-10-16 14:46:41 +08:00
|
|
|
|
return @"Assets/Art/UI/Texture/UI_Pic_Main/UI_Poster/Select/" + postCfg.Get(skinID, id).SelectCharacter + ".png";
|
2024-09-13 13:52:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-10-16 16:48:48 +08:00
|
|
|
|
return @"Assets/Art/UI/Texture/UI_Pic_Main/UI_Poster/Bust/" + postCfg.Get(skinID, id).SelectCharacter + ".png";
|
2023-08-22 19:08:45 +08:00
|
|
|
|
case ECharacterPicPathType.Poster:
|
2024-06-20 14:58:48 +08:00
|
|
|
|
return Constants.UI_POSTER_DEFAULT_PATH + postCfg.Get(skinID, id).Poster + ".png";
|
2024-10-23 15:08:29 +08:00
|
|
|
|
case ECharacterPicPathType.HeadPic:
|
|
|
|
|
|
return TableManager.Instance.Tables.GlobalConfig.HeadPicFrontPath + postCfg.Get(skinID, id).PIcHeadPath + ".png";
|
2024-06-21 15:06:21 +08:00
|
|
|
|
case ECharacterPicPathType.AssistantPoster:
|
|
|
|
|
|
return Constants.UI_POSTER_DEFAULT_PATH + postCfg.Get(1, id).AssistantPoster + ".png";
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-10-25 19:15:09 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取角色皮肤路径
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetCharacterSkinPath(CharacterDataInfo characterDataInfo)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataCharacterSkin dataSkin = TableManager.Instance.Tables.SkinCfg.Get((int)characterDataInfo.SkinID, (int)characterDataInfo.ID);
|
|
|
|
|
|
if (null == dataSkin)
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
return PathEx.GetCharacterDisplayModelPath(dataSkin.NameID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-14 16:41:05 +08:00
|
|
|
|
//获取同一角色的皮肤配置列表
|
|
|
|
|
|
public static List<DataCharacterSkin> GetCharacterSkinCfgList(int uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
var retList = new List<DataCharacterSkin>();
|
|
|
|
|
|
var cfg = TableManager.Instance.Tables.SkinCfg;
|
|
|
|
|
|
for (int i = 0; i < cfg.DataList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var dataCfg = cfg.DataList[i];
|
|
|
|
|
|
if (dataCfg.RoleID == uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
int curIdx = i;
|
|
|
|
|
|
while (curIdx < cfg.DataList.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
var curDataCfg = cfg.DataList[curIdx];
|
|
|
|
|
|
if (curDataCfg.RoleID != uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
retList.Add(cfg.DataList[curIdx]);
|
|
|
|
|
|
++curIdx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return retList;
|
|
|
|
|
|
}
|
2024-11-20 15:18:21 +08:00
|
|
|
|
|
|
|
|
|
|
public static string GetNPCHeadPicPath(int npcConfigID)
|
|
|
|
|
|
{
|
|
|
|
|
|
var npcData = TableManager.Instance.Tables.FightNPCConfig.GetOrDefault(npcConfigID);
|
|
|
|
|
|
if (npcData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format(Constants.UI_NPC_ICON_PATH, npcData.Icon);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DebugUtil.LogError($"无法通过ID获取配置表数据,NPCConfigID:{npcConfigID}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
2024-03-14 16:41:05 +08:00
|
|
|
|
|
2024-12-02 16:34:34 +08:00
|
|
|
|
public static string GetNPCPosterByID(int npcConfigID)
|
|
|
|
|
|
{
|
|
|
|
|
|
var npcData = TableManager.Instance.Tables.FightNPCConfig.GetOrDefault(npcConfigID);
|
|
|
|
|
|
if (npcData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Constants.UI_POSTER_DEFAULT_PATH + npcData.Poster + ".png";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DebugUtil.LogError($"无法通过ID获取配置表数据,NPCConfigID:{npcConfigID}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-11-09 15:05:51 +08:00
|
|
|
|
//}
|
2023-11-09 14:59:56 +08:00
|
|
|
|
//public static string GetVehiclePath(int id)
|
|
|
|
|
|
//{
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
2023-11-09 14:59:56 +08:00
|
|
|
|
//}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
//???????
|
|
|
|
|
|
|
2024-03-08 12:59:24 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取本地化文本
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public static string GetLocalizeText(string key)
|
|
|
|
|
|
{
|
2024-03-08 12:59:24 +08:00
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key);
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2025-01-06 19:03:07 +08:00
|
|
|
|
// public static string GetLocalizeText(string key, float val)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// return StringManager.Instance.GetLocalizeTextByKey(key, val);
|
|
|
|
|
|
// }
|
2025-01-02 14:48:03 +08:00
|
|
|
|
|
2025-01-03 13:25:22 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据养成数据读取角色技能描述文本
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="characterData"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetSkillDesc(CharacterDataInfo characterData)
|
|
|
|
|
|
{
|
|
|
|
|
|
var id = CharacterDataHelper.GetCharacterSkillId(characterData);
|
|
|
|
|
|
//characterData.GetAwakePassiveId()
|
|
|
|
|
|
var key= $"{E_LocalizePrefix.skill_desc}_{id}";
|
|
|
|
|
|
return GetLocalizeTextByKey(key, characterData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据养成数据读取载具技能描述文本
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="vehicleData"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetSkillDesc(VehicleCultivateData vehicleData)
|
|
|
|
|
|
{
|
|
|
|
|
|
var id = VehicleDataHelper.GetVehicleSkillId(vehicleData);
|
|
|
|
|
|
//characterData.GetAwakePassiveId()
|
|
|
|
|
|
var key= $"{E_LocalizePrefix.skill_desc}_{id}";
|
|
|
|
|
|
return GetLocalizeTextByKey(key, vehicleData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-03 14:54:25 +08:00
|
|
|
|
public static string GetSkillDescInBattle(GameUnit unit)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LevelManager.Instance.CurrentLevel != null && LevelManager.Instance.CurrentLevel.isInBattle)
|
|
|
|
|
|
{
|
|
|
|
|
|
int skillID = 0;
|
|
|
|
|
|
if (unit is Character.Character character)
|
|
|
|
|
|
{
|
|
|
|
|
|
skillID = character.runtimeData.configData.skillId;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (unit is NormalVehicle vehicle)
|
|
|
|
|
|
{
|
|
|
|
|
|
skillID = vehicle.runtimeData.configData.skillId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (skillID == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"技能ID为0!unitID:{unit.GetID()}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var key= $"{E_LocalizePrefix.skill_desc}_{skillID}";
|
|
|
|
|
|
return GetLocalizeTextByKey(key, unit);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-03 13:31:32 +08:00
|
|
|
|
//获取角色觉醒被动技能描述
|
|
|
|
|
|
public static string GetAwakePassiveSkillDesc(CharacterDataInfo characterData)
|
|
|
|
|
|
{
|
|
|
|
|
|
var awakePassiveSkillID = characterData.GetAwakePassiveId();
|
|
|
|
|
|
var key= $"{E_LocalizePrefix.PassiveSkillDesc}_{awakePassiveSkillID}";
|
|
|
|
|
|
return GetLocalizeTextByKey(key, characterData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取角色觉醒被动技能描述
|
|
|
|
|
|
public static string GetBreakPassiveSkillDesc(CharacterDataInfo characterData)
|
|
|
|
|
|
{
|
|
|
|
|
|
var breakPassiveSkillID = characterData.GetBreakPassiveId();
|
|
|
|
|
|
var key= $"{E_LocalizePrefix.PassiveSkillDesc}_{breakPassiveSkillID}";
|
|
|
|
|
|
return GetLocalizeTextByKey(key, characterData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-03 14:54:25 +08:00
|
|
|
|
public static string GetLocalizeTextByKey(string key, GameUnit unit)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (unit == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"传入的Unit数据为空!");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
var stringData = TableManager.Instance.Tables.StringConfig.GetOrDefault(key);
|
|
|
|
|
|
if (stringData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"无法获取文本,StringConfig不包含此key:{key}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (stringData.CalculateType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case DescCalculateType.None:
|
|
|
|
|
|
return GetLocalizeText(key);
|
|
|
|
|
|
case DescCalculateType.Attack:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, unit.fightData.attack);
|
|
|
|
|
|
case DescCalculateType.Defend:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, unit.fightData.defense);
|
|
|
|
|
|
case DescCalculateType.Hp:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, unit.aliveData.maxHp);
|
|
|
|
|
|
case DescCalculateType.Armor:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, unit.aliveData.maxShield);
|
|
|
|
|
|
default:
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-03 13:25:22 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取角色技能描述
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
|
/// <param name="characterData"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetLocalizeTextByKey(string key, CharacterDataInfo characterData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (characterData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"传入的角色数据为空!");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
var stringData = TableManager.Instance.Tables.StringConfig.GetOrDefault(key);
|
|
|
|
|
|
if (stringData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"无法获取文本,StringConfig不包含此key:{key}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (stringData.CalculateType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case DescCalculateType.None:
|
|
|
|
|
|
return GetLocalizeText(key);
|
|
|
|
|
|
case DescCalculateType.Attack:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, characterData.Attack());
|
|
|
|
|
|
case DescCalculateType.Defend:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, characterData.Defence());
|
|
|
|
|
|
case DescCalculateType.Hp:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, characterData.HP());
|
|
|
|
|
|
case DescCalculateType.Armor:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, characterData.Armor());
|
|
|
|
|
|
default:
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetLocalizeTextByKey(string key, VehicleCultivateData vehicleData)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (vehicleData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"传入的载具数据为空!");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
var stringData = TableManager.Instance.Tables.StringConfig.GetOrDefault(key);
|
|
|
|
|
|
if (stringData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"无法获取文本,StringConfig不包含此key:{key}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (stringData.CalculateType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case DescCalculateType.None:
|
|
|
|
|
|
return GetLocalizeText(key);
|
|
|
|
|
|
case DescCalculateType.Attack:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, vehicleData.Attack());
|
|
|
|
|
|
case DescCalculateType.Defend:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, vehicleData.Defense());
|
|
|
|
|
|
case DescCalculateType.Hp:
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey(key, vehicleData.Hp());
|
|
|
|
|
|
case DescCalculateType.Armor:
|
|
|
|
|
|
DebugUtil.LogError($"载具没有护甲值!!!StringKey:{key}");
|
|
|
|
|
|
return GetLocalizeText(key);
|
|
|
|
|
|
default:
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-10 16:34:43 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取本地化文本前缀+id
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="e_Direction"></param>
|
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-07-31 17:43:04 +08:00
|
|
|
|
public static string GetLocalizeText(E_LocalizePrefix localizePrefix, int id, bool isUnescape = false)
|
2024-07-10 16:34:43 +08:00
|
|
|
|
{
|
2024-07-31 17:43:04 +08:00
|
|
|
|
if (isUnescape)
|
|
|
|
|
|
return Regex.Unescape(StringManager.Instance.GetLocalizeTextByKey($"{localizePrefix}_{id}")); // 防止配置的文本中的字符被转义
|
|
|
|
|
|
else
|
|
|
|
|
|
return StringManager.Instance.GetLocalizeTextByKey($"{localizePrefix}_{id}");
|
2024-07-10 16:34:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public static string GetLocalizeText(string key, params object[] param)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = StringManager.Instance.GetLocalizeTextByKeyAndParams(key, param);
|
|
|
|
|
|
return str;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void SetScaleWithCameraOrgSize(GameObject go)
|
|
|
|
|
|
{
|
|
|
|
|
|
var camera = CameraManager.Instance.MainCamera;
|
|
|
|
|
|
var cameraCtrller = camera.gameObject.GetComponent<CameraController>();
|
2024-07-25 14:07:22 +08:00
|
|
|
|
var fov = camera.fieldOfView;
|
|
|
|
|
|
// int minSize = 6;
|
|
|
|
|
|
// if (cameraCtrller)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// minSize = (int)cameraCtrller.CameraMinSize;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// float curSize = camera.orthographicSize;
|
|
|
|
|
|
//float mul = minSize / curSize;
|
|
|
|
|
|
float mul = 0.5f;//30 / fov;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
go.transform.localScale = new Vector3(mul, mul, mul);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//图片灰显开启
|
|
|
|
|
|
public static async UniTask OpenImageGray(Image img)
|
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
var mat = await AssetManager.Instance.LoadAssetAsync<Material>("Assets/Art/UI/Material/mat_GrayUI.mat");
|
2023-08-22 19:08:45 +08:00
|
|
|
|
if (mat)
|
|
|
|
|
|
{
|
|
|
|
|
|
var material = UnityEngine.Object.Instantiate(mat);
|
|
|
|
|
|
img.material = material;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static async void SetImageGray(Image img, bool isGray)
|
|
|
|
|
|
{
|
|
|
|
|
|
int param = isGray ? 1 : 0;
|
|
|
|
|
|
bool dontHaveGrayMat = true;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
if (img.material)
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
if (img.material.shader.name == "NLD_URP/NLD_UI_Gray")
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
dontHaveGrayMat = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (dontHaveGrayMat)
|
|
|
|
|
|
{
|
|
|
|
|
|
await OpenImageGray(img);
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
img.material.SetInt(ForceGray, param);
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
public static void ConsoleOpResultError(uint o)
|
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
OpResult opResult = (OpResult)o;
|
2023-11-09 14:59:56 +08:00
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-01-16 14:10:09 +08:00
|
|
|
|
bool isShowForPlayer = false;
|
2024-07-09 13:23:49 +08:00
|
|
|
|
DataErrorCfg errorCfg = TableManager.Instance.Tables.ErrorLogCfg.Get((int)o);
|
2024-07-17 15:26:05 +08:00
|
|
|
|
|
|
|
|
|
|
Debug.LogError($"{GetLocalizeText(E_LocalizePrefix.OpResult, (int)o)}, {GetLocalizeText("errorIdDesc", opResult)}, {o}");
|
|
|
|
|
|
|
2024-07-09 13:23:49 +08:00
|
|
|
|
if (null != errorCfg)
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
2024-01-16 14:10:09 +08:00
|
|
|
|
isShowForPlayer = errorCfg.IsShowToPlayer;
|
|
|
|
|
|
//DebugUtil.LogError("请在errorLog中补上id为{0}的表",o);
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-16 14:10:09 +08:00
|
|
|
|
if (isShowForPlayer)
|
|
|
|
|
|
{
|
2024-07-09 13:23:49 +08:00
|
|
|
|
if (null != errorCfg)
|
2024-07-17 15:01:59 +08:00
|
|
|
|
{
|
2024-07-17 15:26:05 +08:00
|
|
|
|
ShowMessageTips(
|
|
|
|
|
|
$"{GetLocalizeText(E_LocalizePrefix.OpResult, (int)o)}"); //, {GetLocalizeText("errorIdDesc", (OpResult)o)}");
|
2024-07-17 15:01:59 +08:00
|
|
|
|
}
|
2024-01-16 14:10:09 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//DebugUtil.LogError("提供给用户显示的errorLog没有", o);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetRomanCode(int i)//获取1到6的罗马数字
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (i)
|
|
|
|
|
|
{
|
2023-11-21 15:18:32 +08:00
|
|
|
|
case 0:
|
|
|
|
|
|
return "0";
|
2023-10-19 15:00:19 +08:00
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
|
|
|
|
return "I";
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
return "II";
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
return "III";
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
return "IV";
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
return "V";
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
return "VI";
|
|
|
|
|
|
}
|
|
|
|
|
|
DebugUtil.LogError("你要的罗马数字还没有");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-18 17:04:45 +08:00
|
|
|
|
public static string GetCommonLevelStr(int lv)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool isHundred = lv / 100 > 0;
|
|
|
|
|
|
if (isHundred)
|
|
|
|
|
|
{
|
|
|
|
|
|
return lv.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var left = lv % 100;
|
|
|
|
|
|
if (left >= 10)
|
|
|
|
|
|
{
|
|
|
|
|
|
return "0" + left;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "00" + left;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-01-16 14:10:09 +08:00
|
|
|
|
public static string GetShootMode(EShootMode shootMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (shootMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case EShootMode.Rapidfire:
|
|
|
|
|
|
return GetLocalizeText("Rapidfire");
|
|
|
|
|
|
case EShootMode.Burstfire:
|
|
|
|
|
|
return GetLocalizeText("Burstfire");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
DebugUtil.LogError("射击模式{0}没有配本地化,请在stringConfig中配齐", shootMode);
|
|
|
|
|
|
return shootMode.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-09-18 16:03:02 +08:00
|
|
|
|
public const string BLUR_MAT_PATH = "Assets/Art/UI/Material/NLD_URP_UI_GaussianBlur_low.mat";
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-09-18 16:03:02 +08:00
|
|
|
|
public static void CaptureScreenshot(bool captureUI = true)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-08-13 14:29:50 +08:00
|
|
|
|
int width = PerformanceManager.instance.fullScreenWidth;
|
|
|
|
|
|
int height = PerformanceManager.instance.fullScreenHeight;
|
2024-10-21 19:41:56 +08:00
|
|
|
|
|
2024-08-13 14:29:50 +08:00
|
|
|
|
if (null == screenTexture)
|
2024-10-21 19:41:56 +08:00
|
|
|
|
screenTexture = RenderTexturePool.Instance.Create(PerformanceManager.instance.MainRt, width, height, RenderTexturePool.DEFAULT_DEPTH);
|
2024-08-13 14:29:50 +08:00
|
|
|
|
|
2024-09-18 16:03:02 +08:00
|
|
|
|
CameraManager.Instance.SetMainCameraActive(false);
|
2024-05-07 12:03:53 +08:00
|
|
|
|
// 先渲图
|
2024-08-23 13:11:56 +08:00
|
|
|
|
Camera usingCamera = captureUI ? CameraManager.Instance.UICamera : CameraManager.Instance.MainCamera;
|
|
|
|
|
|
usingCamera.targetTexture = screenTexture;
|
|
|
|
|
|
usingCamera.Render();
|
|
|
|
|
|
usingCamera.targetTexture = captureUI ? null: CameraManager.Instance.DefaultRenderTarget;
|
2024-08-13 14:29:50 +08:00
|
|
|
|
|
|
|
|
|
|
#region 高斯模糊处理
|
2024-09-18 16:03:02 +08:00
|
|
|
|
var material = AssetManager.Instance.GetPreLoadResult<Material>(BLUR_MAT_PATH);
|
2024-08-28 14:57:25 +08:00
|
|
|
|
|
2024-05-07 12:03:53 +08:00
|
|
|
|
// 需要用一个缓存的rt,不然移动平台会出现方块
|
2024-08-13 14:29:50 +08:00
|
|
|
|
RenderTexture cacheRt = CameraManager.Instance.DefaultRenderTarget;
|
2024-08-15 19:38:22 +08:00
|
|
|
|
Graphics.Blit(screenTexture, cacheRt, material);
|
2024-05-06 19:46:07 +08:00
|
|
|
|
Graphics.Blit(cacheRt, screenTexture);
|
2024-08-28 14:57:25 +08:00
|
|
|
|
|
2024-08-13 14:29:50 +08:00
|
|
|
|
#endregion
|
2024-04-25 16:36:07 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-08-08 12:19:32 +08:00
|
|
|
|
public static void ScreenshotReset()
|
|
|
|
|
|
{
|
|
|
|
|
|
CameraManager.Instance.SetMainCameraActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-08 17:04:37 +08:00
|
|
|
|
public static void RefreshCharacter2DPic(Image img, Sprite sprite)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
img.gameObject.SetActive(false);
|
2024-05-08 17:04:37 +08:00
|
|
|
|
//string imgPath = GetCharacterPicPath(roleId, eCharacterPicPathType);
|
2024-03-05 13:32:35 +08:00
|
|
|
|
//await AssetManager.Instance.LoadAssetAsync<Sprite>(imgPath, spr =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// img.sprite = spr;
|
|
|
|
|
|
// img.gameObject.SetActive(true);
|
|
|
|
|
|
// });
|
2024-05-08 17:04:37 +08:00
|
|
|
|
img.sprite = sprite;
|
|
|
|
|
|
img.gameObject.SetActive(true);
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int GetGameUnitUltraSkillID(GameUnit unit)
|
|
|
|
|
|
{
|
|
|
|
|
|
uint uid = unit.GetID();
|
|
|
|
|
|
return GetGameUnitUltraSkillID(uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int GetGameUnitUltraSkillID(uint uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
CharacterDataInfo characterDataInfo;
|
|
|
|
|
|
if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(uid, out characterDataInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
return CharacterDataHelper.GetCharacterSkillId(characterDataInfo);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DebugUtil.LogError("请检查传入的角色对象uid");
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-02 16:34:34 +08:00
|
|
|
|
public static string GetSkillTargetIcon(int skillID)
|
|
|
|
|
|
{
|
|
|
|
|
|
var iconName = "";
|
|
|
|
|
|
var skillData = TableManager.Instance.Tables.SkillConfig.GetOrDefault(skillID);
|
|
|
|
|
|
if (skillData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"无法获取技能表配置,ID:{skillID}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var areaID = skillData.InfluenceAreaId;
|
|
|
|
|
|
var influenceData = TableManager.Instance.Tables.AreaConfig.GetOrDefault(areaID);
|
|
|
|
|
|
if (influenceData == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"无法获取InfluenceArea表配置,ID:{areaID}");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
iconName = influenceData.Icon;
|
|
|
|
|
|
return string.IsNullOrEmpty(iconName)? iconName : Constants.UI_SKILL_TARGET_ICON + iconName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
public static string WWWLoadText(string fileName)
|
|
|
|
|
|
{
|
|
|
|
|
|
UnityWebRequest www = UnityWebRequest.Get(fileName);//WWW会自动开始读取文件
|
|
|
|
|
|
while (!www.isDone) { }//WWW是异步读取,所以要用循环来等待
|
|
|
|
|
|
return www.downloadHandler.text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string FormatNumber(long num)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0:N0}", num);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string FormatNumber(float num)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0:N0}", num);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string FormatMoney(float num)
|
|
|
|
|
|
{
|
|
|
|
|
|
return num.ToString("C2");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string FormatSize(float fBytes)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fBytes <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return "0K";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (fBytes < 102.4f)
|
|
|
|
|
|
{
|
|
|
|
|
|
return "0.1K";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (fBytes < 1024 * 1024)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0:F1}K", (fBytes / 1024));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0:F1}M", (fBytes / (1024 * 1024)));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string Validate(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
//https://msdn.microsoft.com/en-us/library/20bw873z(v=vs.110).aspx
|
|
|
|
|
|
text = RemoveEmoji(text, @"\p{C}");
|
|
|
|
|
|
return text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static string ValidateEx(string text)
|
|
|
|
|
|
{
|
|
|
|
|
|
//https://en.wikipedia.org/wiki/Emoji#Emoji_in_the_Unicode_standard
|
|
|
|
|
|
// 635 of the 766 codepoints in the Miscellaneous Symbols and Pictographs block are considered emoji.
|
|
|
|
|
|
string pattern = @"[^\u1F300-\u1F5FF]";
|
|
|
|
|
|
text = RemoveEmoji(text, pattern);
|
|
|
|
|
|
|
|
|
|
|
|
// All of the 15 codepoints in the Supplemental Symbols and Pictographs block are considered emoji.
|
|
|
|
|
|
pattern = @"[^\u1F910-\u1F918\u1F980-\u1F984\u1F9C0]";
|
|
|
|
|
|
text = RemoveEmoji(text, pattern);
|
|
|
|
|
|
|
|
|
|
|
|
// All of the 80 codepoints in the Emoticons block are considered emoji.
|
|
|
|
|
|
// pattern = @"[^\u1F60-\u1F64]";
|
|
|
|
|
|
// text = RemoveEmoji (text, pattern);
|
|
|
|
|
|
|
|
|
|
|
|
// 87 of the 98 codepoints in the Transport and Map Symbols block are considered emoji.
|
|
|
|
|
|
// pattern = @"[^\u1F68-\u1F6F]";
|
|
|
|
|
|
// text = RemoveEmoji (text, pattern);
|
|
|
|
|
|
|
|
|
|
|
|
// 77 of the 256 codepoints in the Miscellaneous Symbols block are considered emoji.
|
|
|
|
|
|
// pattern = @"[^\u260-\u26F]";
|
|
|
|
|
|
// text = RemoveEmoji (text, pattern);
|
|
|
|
|
|
|
|
|
|
|
|
// 77 of the 256 codepoints in the Miscellaneous Symbols block are considered emoji.
|
|
|
|
|
|
// pattern = @"[^\u270-\u27B]";
|
|
|
|
|
|
// text = RemoveEmoji (text, pattern);
|
|
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static string RemoveEmoji(string text, string pattern)
|
|
|
|
|
|
{
|
|
|
|
|
|
return System.Text.RegularExpressions.Regex.Replace(text, pattern, string.Empty);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void AmendBuildingRotation(Transform building)
|
|
|
|
|
|
{
|
|
|
|
|
|
var vr = building.localEulerAngles;
|
|
|
|
|
|
vr.y %= 360;
|
|
|
|
|
|
if (vr.y < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
vr.y += 360;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (vr.y <= 45)
|
|
|
|
|
|
{
|
|
|
|
|
|
vr.y = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (vr.y <= 135)
|
|
|
|
|
|
{
|
|
|
|
|
|
vr.y = 90;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (vr.y <= 225)
|
|
|
|
|
|
{
|
|
|
|
|
|
vr.y = 180;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (vr.y <= 315)
|
|
|
|
|
|
{
|
|
|
|
|
|
vr.y = 270;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
vr.y = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
building.localRotation = Quaternion.Euler(vr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static long TotalSeconds()
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));
|
|
|
|
|
|
return Convert.ToInt64(ts.TotalSeconds);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static long TotalMilliseconds()
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));
|
|
|
|
|
|
return Convert.ToInt64(ts.TotalMilliseconds);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static double Countdown(DateTime dt)
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeSpan ts = (dt - DateTime.UtcNow);
|
|
|
|
|
|
return ts.TotalSeconds;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static double Countdown(long seconds)
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));
|
|
|
|
|
|
return seconds - ts.TotalSeconds;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static DateTime ParseTimeFromNow(long countdown)
|
|
|
|
|
|
{
|
|
|
|
|
|
return DateTime.UtcNow.AddSeconds(countdown);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static double PastTime(DateTime pastTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
TimeSpan ts = (DateTime.UtcNow - pastTime);
|
|
|
|
|
|
return ts.TotalSeconds;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int GetDayBySeconds(long seconds)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (int)Mathf.Floor(seconds / (3600 * 24));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool IsSameDay(long seconds1, long seconds2)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetDayInterval(seconds1, seconds2) == 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int GetDayInterval(long seconds1, long seconds2)
|
|
|
|
|
|
{
|
|
|
|
|
|
int day1 = GetDayBySeconds(seconds1);
|
|
|
|
|
|
int day2 = GetDayBySeconds(seconds2);
|
|
|
|
|
|
return Mathf.Abs(day1 - day2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取第二天凌晨时间戳
|
|
|
|
|
|
public static long GetTomorrowTimestamp()
|
|
|
|
|
|
{
|
|
|
|
|
|
DateTime tomorrow = DateTime.UtcNow.AddDays(1);
|
|
|
|
|
|
DateTime tomorrowMidnight = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, 0, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
|
|
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
|
|
|
|
|
TimeSpan diff = tomorrowMidnight.ToUniversalTime() - origin;
|
|
|
|
|
|
return (long)Math.Floor(diff.TotalSeconds);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetDateString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return DateTime.Now.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-14 16:50:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取一个随机列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="beginInt"></param>
|
|
|
|
|
|
/// <param name="endInt"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static IList<int> GetRandomList(int beginInt, int endInt)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-03-14 16:50:31 +08:00
|
|
|
|
int count = endInt - beginInt + 1;
|
|
|
|
|
|
IList<int> arr = new int[count];
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-03-14 16:50:31 +08:00
|
|
|
|
arr[i] = beginInt + i;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
2024-03-14 16:50:31 +08:00
|
|
|
|
|
2024-03-18 14:29:03 +08:00
|
|
|
|
Shuffle(arr);
|
2024-03-14 16:50:31 +08:00
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
return arr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Array to string. split with ,
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>formatted string.</returns>
|
|
|
|
|
|
/// <param name="array">Array.</param>
|
|
|
|
|
|
/// <typeparam name="T">The 1st type parameter.</typeparam>
|
|
|
|
|
|
public static string ArrayToString<T>(T[] array)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
|
|
|
|
if (array != null && array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (i != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
sb.Append(',');
|
|
|
|
|
|
}
|
|
|
|
|
|
sb.Append(array[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取当前时间戳(毫秒)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static long GetTimeStamp()
|
|
|
|
|
|
{
|
|
|
|
|
|
// DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
|
|
|
|
|
DateTime startTime = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1), TimeZoneInfo.Local);// 当地时区
|
|
|
|
|
|
return (long)(DateTime.Now - startTime).TotalMilliseconds;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取指定时间的时间戳(毫秒)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static long GetTimeStamp(DateTime date)
|
|
|
|
|
|
{
|
|
|
|
|
|
DateTime startTime = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1),
|
|
|
|
|
|
date.Kind == DateTimeKind.Utc ? TimeZoneInfo.Utc : TimeZoneInfo.Local);
|
|
|
|
|
|
return (long)(date - startTime).TotalMilliseconds;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取当前时间戳(秒)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static long GetTimeStampSeconds()
|
|
|
|
|
|
{
|
|
|
|
|
|
DateTime startTime = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1), TimeZoneInfo.Local);// 当地时区
|
|
|
|
|
|
return (long)(DateTime.Now - startTime).TotalSeconds;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetTimeString(string format, int seconds)
|
|
|
|
|
|
{
|
|
|
|
|
|
string label = format;
|
|
|
|
|
|
int ms = seconds * 1000;
|
|
|
|
|
|
int s = seconds;
|
|
|
|
|
|
int m = s / 60;
|
|
|
|
|
|
int h = m / 60;
|
|
|
|
|
|
int d = h / 24;
|
|
|
|
|
|
|
|
|
|
|
|
string t = "";
|
|
|
|
|
|
//处理天
|
|
|
|
|
|
if (label.Contains("%dd"))
|
|
|
|
|
|
{
|
|
|
|
|
|
t = d >= 10 ? d.ToString() : ("0" + d.ToString());
|
|
|
|
|
|
label = label.Replace("%dd", t);
|
|
|
|
|
|
h = h % 24;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (label.Contains("%d"))
|
|
|
|
|
|
{
|
|
|
|
|
|
label = label.Replace("%d", d.ToString());
|
|
|
|
|
|
h = h % 24;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//处理小时
|
|
|
|
|
|
if (label.Contains("%hh"))
|
|
|
|
|
|
{
|
|
|
|
|
|
t = h >= 10 ? h.ToString() : ("0" + h.ToString());
|
|
|
|
|
|
label = label.Replace("%hh", t);
|
|
|
|
|
|
m = m % 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (label.Contains("%h"))
|
|
|
|
|
|
{
|
|
|
|
|
|
label = label.Replace("%h", h.ToString());
|
|
|
|
|
|
m = m % 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//处理分
|
|
|
|
|
|
if (label.Contains("%mm"))
|
|
|
|
|
|
{
|
|
|
|
|
|
t = m >= 10 ? m.ToString() : ("0" + m.ToString());
|
|
|
|
|
|
label = label.Replace("%mm", t);
|
|
|
|
|
|
s = s % 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (label.Contains("%m"))
|
|
|
|
|
|
{
|
|
|
|
|
|
label = label.Replace("%m", m.ToString());
|
|
|
|
|
|
s = s % 60;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//处理秒
|
|
|
|
|
|
if (label.Contains("%ss"))
|
|
|
|
|
|
{
|
|
|
|
|
|
t = s >= 10 ? s.ToString() : ("0" + s.ToString());
|
|
|
|
|
|
label = label.Replace("%ss", t);
|
|
|
|
|
|
ms = ms % 1000;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (label.Contains("%s"))
|
|
|
|
|
|
{
|
|
|
|
|
|
label = label.Replace("%s", s.ToString());
|
|
|
|
|
|
ms = ms % 1000;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//处理毫秒
|
|
|
|
|
|
if (label.Contains("ms"))
|
|
|
|
|
|
{
|
|
|
|
|
|
t = ms.ToString();
|
|
|
|
|
|
label = label.Replace("%ms", t);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return label;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 把一个记录的时间戳转换成日期显示(毫秒)
|
|
|
|
|
|
public static string GetTimeStampDateString(double timeStamp, string format = "yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
|
{
|
|
|
|
|
|
// var offset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
|
|
|
|
|
|
var offset = TimeZoneInfo.Local.GetUtcOffset(DateTime.Now);
|
|
|
|
|
|
var dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Add(offset).AddMilliseconds(timeStamp);
|
|
|
|
|
|
return dt.ToString(format);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static T ArrayFind<T>(T[] array, Predicate<T> condition)
|
|
|
|
|
|
{
|
|
|
|
|
|
T item = default(T);
|
|
|
|
|
|
if (array != null && array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (condition(array[i]))
|
|
|
|
|
|
{
|
|
|
|
|
|
item = array[i];
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return item;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int ArrayFindIndex<T>(T[] array, Predicate<T> condition)
|
|
|
|
|
|
{
|
|
|
|
|
|
int index = -1;
|
|
|
|
|
|
if (array != null && array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (condition(array[i]))
|
|
|
|
|
|
{
|
|
|
|
|
|
index = i;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return index;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static T[] ArrayAdd<T>(T[] array, T item)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<T> newArray = new List<T>();
|
|
|
|
|
|
if (array != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
newArray.AddRange(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
newArray.Add(item);
|
|
|
|
|
|
return newArray.ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int RandomByWeight(Dictionary<int, int> idWeights)
|
|
|
|
|
|
{
|
|
|
|
|
|
int weights = 0;
|
|
|
|
|
|
int id = 0;
|
|
|
|
|
|
foreach (var kv in idWeights)
|
|
|
|
|
|
{
|
|
|
|
|
|
weights += kv.Value;
|
|
|
|
|
|
id = kv.Key;
|
|
|
|
|
|
}
|
|
|
|
|
|
int pos = UnityEngine.Random.Range(0, weights);
|
|
|
|
|
|
weights = 0;
|
|
|
|
|
|
foreach (var kv in idWeights)
|
|
|
|
|
|
{
|
|
|
|
|
|
weights += kv.Value;
|
|
|
|
|
|
if (pos < weights)
|
|
|
|
|
|
{
|
|
|
|
|
|
id = kv.Key;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
break;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return id;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int RandomByWeight(List<int> weightList)
|
|
|
|
|
|
{
|
|
|
|
|
|
int weights = 0;
|
|
|
|
|
|
int idx = 0;
|
|
|
|
|
|
for (int i = 0; i < weightList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
weights += weightList[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
int pos = UnityEngine.Random.Range(0, weights);
|
|
|
|
|
|
weights = 0;
|
|
|
|
|
|
for (int i = 0; i < weightList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
weights += weightList[i];
|
|
|
|
|
|
if (pos < weights)
|
|
|
|
|
|
{
|
|
|
|
|
|
idx = i;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
break;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return idx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int RandomByWeight(int[] weightList)
|
|
|
|
|
|
{
|
|
|
|
|
|
int weights = 0;
|
|
|
|
|
|
int idx = 0;
|
|
|
|
|
|
for (int i = 0; i < weightList.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
weights += weightList[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
int pos = UnityEngine.Random.Range(0, weights);
|
|
|
|
|
|
weights = 0;
|
|
|
|
|
|
for (int i = 0; i < weightList.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
weights += weightList[i];
|
|
|
|
|
|
if (pos < weights)
|
|
|
|
|
|
{
|
|
|
|
|
|
idx = i;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
break;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return idx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-30 15:37:11 +08:00
|
|
|
|
/// <summary>
|
2024-11-14 14:35:15 +08:00
|
|
|
|
/// 用K、M、G等单位表示数字,不包含小数点,英文计数法
|
2024-08-30 15:37:11 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="number"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string ToMetricNotation(double number)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (number >= 1_000_000_000)
|
2024-10-10 17:05:45 +08:00
|
|
|
|
return (number / 1_000_000_000).ToString("0") + "G";
|
2024-08-30 15:37:11 +08:00
|
|
|
|
else if (number >= 1_000_000)
|
2024-10-10 17:05:45 +08:00
|
|
|
|
return (number / 1_000_000).ToString("0") + "M";
|
2024-08-30 15:37:11 +08:00
|
|
|
|
else if (number >= 1_000)
|
2024-10-10 17:05:45 +08:00
|
|
|
|
return (number / 1_000).ToString("0") + "K";
|
2024-08-30 15:37:11 +08:00
|
|
|
|
else
|
|
|
|
|
|
return number.ToString();
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
public static void JumpToAnimation(Animator animator, string stateName, float normalizedTime, int layer = -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
animator.Play(stateName, layer, normalizedTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetLevelDisplay(int levelId)
|
|
|
|
|
|
{
|
|
|
|
|
|
//潜规则,策划修改为301 - 但需要显示为1
|
|
|
|
|
|
int lv = levelId % 100;
|
|
|
|
|
|
return lv.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the ADIDB y platform async.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="callback">Application.AdvertisingIdentifierCallback回调参数一共有三:string adid, bool 是否成功 , string error.</param>
|
|
|
|
|
|
public static void GetADIDByPlatformAsync(Application.AdvertisingIdentifierCallback callback)
|
|
|
|
|
|
{
|
|
|
|
|
|
Application.RequestAdvertisingIdentifierAsync(callback);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string PlayerIdToString(ulong playerId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (playerId + 0xb2c3d4).ToString("x");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static ulong StringToPlayerId(string str)
|
|
|
|
|
|
{
|
|
|
|
|
|
ulong playerId = Convert.ToUInt64(str, 16);
|
|
|
|
|
|
playerId -= 0xb2c3d4;
|
|
|
|
|
|
return playerId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void SaveToLocal(string key, string data)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] encryptData = RijndaelManager.Instance.EncryptStringToBytes(data);
|
|
|
|
|
|
PlayerPrefs.SetString(key, System.Convert.ToBase64String(encryptData));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string ReadFromLocal(string key, string defaultData = "")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (PlayerPrefs.HasKey(key))
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] encryptData = System.Convert.FromBase64String(PlayerPrefs.GetString(key));
|
|
|
|
|
|
defaultData = RijndaelManager.Instance.DecryptStringFromBytes(encryptData);
|
|
|
|
|
|
}
|
|
|
|
|
|
return defaultData;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static NameValueCollection ParseQueryString(string s)
|
|
|
|
|
|
{
|
|
|
|
|
|
NameValueCollection nvc = new NameValueCollection();
|
|
|
|
|
|
|
|
|
|
|
|
// remove anything other than query string from url
|
|
|
|
|
|
if (s.Contains("?"))
|
|
|
|
|
|
{
|
|
|
|
|
|
s = s.Substring(s.IndexOf('?') + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string vp in Regex.Split(s, "&"))
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("vp = {0}", vp);
|
|
|
|
|
|
string[] singlePair = Regex.Split(vp, "=");
|
|
|
|
|
|
if (singlePair.Length == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("key = {0} value = {1}", singlePair[0], singlePair[1]);
|
|
|
|
|
|
nvc.Add(singlePair[0], singlePair[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("key = {0} value = null", singlePair[0]);
|
|
|
|
|
|
// only one key with no value specified in query string
|
|
|
|
|
|
nvc.Add(singlePair[0], string.Empty);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nvc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetMD5Hash(string input)
|
|
|
|
|
|
{
|
|
|
|
|
|
// step 1, calculate MD5 hash from input
|
|
|
|
|
|
MD5 md5 = System.Security.Cryptography.MD5.Create();
|
|
|
|
|
|
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
|
|
|
|
|
|
byte[] hash = md5.ComputeHash(inputBytes);
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
// step 2, convert byte array to hex string
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (int i = 0; i < hash.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
sb.Append(hash[i].ToString("X2"));
|
|
|
|
|
|
}
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 判断是否是磁盘空间已满异常
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ex"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static bool IsDiskFull(Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ex == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
const int HR_ERROR_HANDLE_DISK_FULL = unchecked((int)0x80070027);
|
|
|
|
|
|
const int HR_ERROR_DISK_FULL = unchecked((int)0x80070070);
|
|
|
|
|
|
|
|
|
|
|
|
return ex.HResult == HR_ERROR_HANDLE_DISK_FULL
|
|
|
|
|
|
|| ex.HResult == HR_ERROR_DISK_FULL;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-19 15:00:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 格式化json
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="str"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string ConvertJsonString(string str)
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
JsonSerializer serializer = new JsonSerializer();
|
|
|
|
|
|
TextReader tr = new StringReader(str);
|
|
|
|
|
|
JsonTextReader jtr = new JsonTextReader(tr);
|
|
|
|
|
|
object obj = serializer.Deserialize(jtr);
|
|
|
|
|
|
if (obj != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
StringWriter textWriter = new StringWriter();
|
|
|
|
|
|
JsonTextWriter jsonWriter = new JsonTextWriter(textWriter)
|
|
|
|
|
|
{
|
|
|
|
|
|
Formatting = Formatting.Indented,
|
|
|
|
|
|
Indentation = 4,
|
|
|
|
|
|
IndentChar = ' '
|
|
|
|
|
|
};
|
|
|
|
|
|
serializer.Serialize(jsonWriter, obj);
|
|
|
|
|
|
return textWriter.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return str;
|
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 将秒转化为x小时x分x秒格式
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="seconds"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetTimeDescStr(int seconds)
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
string retStr = "";
|
|
|
|
|
|
int h = seconds / 3600;
|
|
|
|
|
|
int m = (seconds - h * 3600) / 60;
|
|
|
|
|
|
int s = seconds - h * 3600 - m * 60;
|
|
|
|
|
|
if (h > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (s > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
retStr = GetLocalizeText("time_hour_min_sec", h, m, s);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (m > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
retStr = GetLocalizeText("time_hour_min", h, m);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
retStr = GetLocalizeText("time_hour", h);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (s > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
retStr = GetLocalizeText("time_min_sec", m, s);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
retStr = GetLocalizeText("time_min", m);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
retStr = GetLocalizeText("time_sec", s);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return retStr;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
//转换为英文缩写
|
|
|
|
|
|
public static string NumToEnglish(uint value)
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
if (value > 10000 && value <= 10000000)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0}K", (value / 1000).ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (value > 10000000)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0}M", (value / 1000000).ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return value.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2023-10-21 11:55:23 +08:00
|
|
|
|
public static float CheckAngle(float value)
|
|
|
|
|
|
{
|
|
|
|
|
|
float angle = value - 180;
|
|
|
|
|
|
|
|
|
|
|
|
if (angle > 0)
|
|
|
|
|
|
return angle - 180;
|
|
|
|
|
|
|
|
|
|
|
|
return angle + 180;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-10-26 20:20:11 +08:00
|
|
|
|
public static int GetTransformIndex(Transform transform)
|
|
|
|
|
|
{
|
|
|
|
|
|
var parent = transform.parent;
|
|
|
|
|
|
if (parent != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var childCount = parent.childCount;
|
|
|
|
|
|
for (int i = 0; i < childCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var child = parent.GetChild(i);
|
|
|
|
|
|
if (child == transform)
|
|
|
|
|
|
return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-06 16:46:00 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 预加载或卸载环境天气图标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="loadOrUnload"></param>
|
2024-08-28 14:53:39 +08:00
|
|
|
|
public static void PreLoadOrUnloadEnvironmentWeatherDayNightIcon(bool loadOrUnload)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-02-22 19:47:38 +08:00
|
|
|
|
List<string> paths = new();
|
2024-11-20 19:55:55 +08:00
|
|
|
|
foreach (ELevelTerrainType value in Enum.GetValues(typeof(ELevelTerrainType)))
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-11-20 19:55:55 +08:00
|
|
|
|
ELevelTerrainType enumValue = value;
|
2024-05-06 16:46:00 +08:00
|
|
|
|
DataEnviorment config = GetEnvironmentConfig(enumValue);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
paths.Add(config.Icon);
|
|
|
|
|
|
}
|
2024-05-06 16:46:00 +08:00
|
|
|
|
|
2024-08-28 12:17:53 +08:00
|
|
|
|
foreach (WeatherType value in Enum.GetValues(typeof(WeatherType)))
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-08-28 12:17:53 +08:00
|
|
|
|
WeatherType enumValue = value;
|
2024-05-06 16:46:00 +08:00
|
|
|
|
DataEnWeather config = GetWeatherConfig(enumValue);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
paths.Add(config.Icon);
|
|
|
|
|
|
}
|
2024-05-06 16:46:00 +08:00
|
|
|
|
|
2024-08-28 12:17:53 +08:00
|
|
|
|
foreach (DayNightType value in Enum.GetValues(typeof(DayNightType)))
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-08-28 12:17:53 +08:00
|
|
|
|
DayNightType enumValue = value;
|
2024-05-06 16:46:00 +08:00
|
|
|
|
DataDayNightProp config = GetDayNightConfig(enumValue);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
paths.Add(config.Icon);
|
|
|
|
|
|
}
|
2023-11-09 14:59:56 +08:00
|
|
|
|
|
2024-05-06 16:46:00 +08:00
|
|
|
|
foreach (string iconPath in paths)
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
2024-08-28 14:53:39 +08:00
|
|
|
|
if (loadOrUnload)
|
|
|
|
|
|
AssetManager.Instance.PostPreload<Sprite>(iconPath).Forget();
|
2024-02-22 19:47:38 +08:00
|
|
|
|
else
|
|
|
|
|
|
AssetManager.Instance.Unload(iconPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-05 15:48:15 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 预加载或卸载战役评级图标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="loadOrUnload"></param>
|
|
|
|
|
|
public static void PreLoadOrUnloadWarRatingIcon(bool loadOrUnload)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (E_WarRating value in Enum.GetValues(typeof(E_WarRating)))
|
|
|
|
|
|
{
|
|
|
|
|
|
E_WarRating enumValue = value;
|
2024-10-28 18:29:32 +08:00
|
|
|
|
if (loadOrUnload)
|
|
|
|
|
|
{
|
2024-09-05 15:48:15 +08:00
|
|
|
|
AssetManager.Instance.PostPreload<Sprite>(GetWarRatingIconPath(enumValue)).Forget();
|
2024-10-28 18:29:32 +08:00
|
|
|
|
AssetManager.Instance.PostPreload<Sprite>(GetReachedWarRatingIconPath(enumValue)).Forget();
|
|
|
|
|
|
}
|
2024-09-05 15:48:15 +08:00
|
|
|
|
else
|
2024-10-28 18:29:32 +08:00
|
|
|
|
{
|
2024-09-05 15:48:15 +08:00
|
|
|
|
AssetManager.Instance.Unload(GetWarRatingIconPath(enumValue));
|
2024-10-28 18:29:32 +08:00
|
|
|
|
AssetManager.Instance.Unload(GetReachedWarRatingIconPath(enumValue));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-05 15:48:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取战役评级图标路径
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="warRating"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetWarRatingIconPath(E_WarRating warRating)
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"Assets/Art/UI/Texture/LevelSelectNew/War/UI_{warRating}.png";
|
|
|
|
|
|
}
|
2024-10-28 16:54:49 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-10-28 18:29:32 +08:00
|
|
|
|
/// 获取战役已达到的评级图标路径
|
2024-10-28 16:54:49 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static string GetReachedWarRatingIconPath(E_WarRating warRating)
|
|
|
|
|
|
{
|
2024-10-28 18:29:32 +08:00
|
|
|
|
return $"Assets/Art/UI/Texture/LevelSelectNew/War/UI_{warRating}_On.png";
|
2024-10-28 16:54:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-05 15:48:15 +08:00
|
|
|
|
|
2024-08-28 12:17:53 +08:00
|
|
|
|
public static DataEnWeather GetWeatherConfig(WeatherType weatherType)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-02-22 19:47:38 +08:00
|
|
|
|
var result = TableManager.Instance.Tables.WeatherConfig.Get((int)weatherType);
|
|
|
|
|
|
return result;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
2023-11-09 14:59:56 +08:00
|
|
|
|
|
2024-11-20 19:55:55 +08:00
|
|
|
|
public static DataEnviorment GetEnvironmentConfig(ELevelTerrainType eLevelTerrainType)
|
2023-10-26 20:20:11 +08:00
|
|
|
|
{
|
2024-11-20 19:55:55 +08:00
|
|
|
|
var result = TableManager.Instance.Tables.EnviormentConfig.Get((int)eLevelTerrainType);
|
2024-02-22 19:47:38 +08:00
|
|
|
|
return result;
|
2023-10-26 20:20:11 +08:00
|
|
|
|
}
|
2023-11-09 14:59:56 +08:00
|
|
|
|
|
2024-08-28 12:17:53 +08:00
|
|
|
|
public static DataDayNightProp GetDayNightConfig(DayNightType dayNightType)
|
2024-02-22 19:47:38 +08:00
|
|
|
|
{
|
|
|
|
|
|
var result = TableManager.Instance.Tables.DayNightProp.Get((int)dayNightType);
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2023-12-01 13:35:33 +08:00
|
|
|
|
|
2023-11-15 15:23:27 +08:00
|
|
|
|
public static void AddItem(ref List<cfg.item.ItemCounts> sumItem, cfg.item.ItemCounts item1)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < sumItem.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sumItem[i].Id==item1.Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
sumItem[i]=new cfg.item.ItemCounts(sumItem[i].Id, sumItem[i].Count+item1.Count);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
sumItem.Add(item1);
|
|
|
|
|
|
}
|
|
|
|
|
|
public static cfg.item.ItemCounts ItemXNumber(cfg.item.ItemCounts item,int number)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new cfg.item.ItemCounts(item.Id, item.Count * number);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public static string GetVehicleBonusStr(BonusType btype)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
switch (btype)
|
|
|
|
|
|
{
|
|
|
|
|
|
case BonusType.Hp:
|
|
|
|
|
|
return GetLocalizeText("cultivate_Hp");
|
|
|
|
|
|
case BonusType.SkillLv:
|
|
|
|
|
|
return GetLocalizeText("vehicleCultivate_skillLv");
|
|
|
|
|
|
case BonusType.MoveSpeed:
|
2023-11-17 15:50:35 +08:00
|
|
|
|
return GetLocalizeText("cultivate_Speed");
|
2023-11-15 15:23:27 +08:00
|
|
|
|
case BonusType.SeatCount:
|
2023-11-17 15:50:35 +08:00
|
|
|
|
return GetLocalizeText("vehicleCultivate_PersonNum");
|
2024-06-25 18:53:27 +08:00
|
|
|
|
case BonusType.AttackPercent:
|
|
|
|
|
|
return GetLocalizeText("vehicleCultivate_AttackPercent");
|
2024-06-25 19:53:10 +08:00
|
|
|
|
case BonusType.AttackShiledScale:
|
|
|
|
|
|
return GetLocalizeText("vehicleCultivate_AttackShiledScale");
|
|
|
|
|
|
case BonusType.HpPercent:
|
|
|
|
|
|
return GetLocalizeText("cultivate_Hp");
|
|
|
|
|
|
case BonusType.AttackHpScale:
|
|
|
|
|
|
return GetLocalizeText("vehicleCultivate_AttackHpScale");
|
2024-06-25 18:53:27 +08:00
|
|
|
|
default:
|
|
|
|
|
|
DebugUtil.LogError("没有这个类型的奖励文本: "+btype+",请在此处配置");
|
|
|
|
|
|
return string.Empty;
|
2023-11-15 15:23:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-11-24 12:48:57 +08:00
|
|
|
|
|
2023-12-11 18:55:42 +08:00
|
|
|
|
public static void ShowMessageTips(string TipsMsg)
|
2023-11-24 12:48:57 +08:00
|
|
|
|
{
|
2023-12-21 15:59:18 +08:00
|
|
|
|
UITipsManager.ShowTips(TipsMsg);
|
2023-11-24 12:48:57 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2023-12-11 18:55:42 +08:00
|
|
|
|
public static void SetActive(GameObject obj,bool isActive)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(isActive)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.transform.localScale = Vector3.one;
|
|
|
|
|
|
}else
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.transform.localScale = Vector3.zero;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-15 13:44:42 +08:00
|
|
|
|
|
2023-12-20 12:47:57 +08:00
|
|
|
|
// /// <summary>
|
|
|
|
|
|
// /// 要保证所有网格能对齐,需要调整网格的列数和行数,规则是column必须是偶数,row必须是偶数且必须是奇数的两倍
|
|
|
|
|
|
// /// 这样能保证网格一定对齐
|
|
|
|
|
|
// /// </summary>
|
|
|
|
|
|
// /// <param name="columnAndRow"></param>
|
|
|
|
|
|
// /// <returns></returns>
|
|
|
|
|
|
// public static void CorrectTGSColumnAndRow(ref int column, ref int row)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (column % 2 != 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// column--;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// var halfRow = row / 2;
|
|
|
|
|
|
// if (halfRow % 2 == 0)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// halfRow++;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// row = halfRow * 2;
|
|
|
|
|
|
// }
|
2023-12-15 13:44:42 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得Tgs中长度对应的六边形数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="totalLength">总长度</param>
|
|
|
|
|
|
/// <param name="hexDiagonalLength">六边形对角线长度</param>
|
|
|
|
|
|
/// <param name="isDiagonal">是否对角线朝向排列</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static int GetHexCount(float totalLength, float hexDiagonalLength, bool isDiagonal)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isDiagonal)
|
|
|
|
|
|
return Mathf.FloorToInt((4 * totalLength) / (3 * hexDiagonalLength) - 1 / 3f);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var sqrt3 = Mathf.Sqrt(3);
|
|
|
|
|
|
var countInFloat = (totalLength - (sqrt3 / 4 * hexDiagonalLength)) /
|
|
|
|
|
|
(Mathf.Sqrt(3) / 2 * hexDiagonalLength);
|
|
|
|
|
|
return Mathf.FloorToInt(countInFloat);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-21 15:47:46 +08:00
|
|
|
|
|
|
|
|
|
|
public static bool IsInGame()
|
|
|
|
|
|
{
|
2024-11-06 13:33:47 +08:00
|
|
|
|
return Application.isPlaying && Main.Instance.isInited;
|
2023-12-21 15:47:46 +08:00
|
|
|
|
}
|
2023-12-25 18:51:23 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置uint的某一位,返回int
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="data">被设置的数据</param>
|
|
|
|
|
|
/// <param name="idx">第idx位</param>
|
|
|
|
|
|
/// <param name="flag">true为0, false为1</param>
|
|
|
|
|
|
public static int GetIntBitByIndex(uint data, int idx, bool flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (idx > 31 || idx < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (int)data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!flag)
|
|
|
|
|
|
{
|
|
|
|
|
|
data |= (uint)(1 << idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
data &= ~(uint)(1 << idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (int)data;
|
|
|
|
|
|
}
|
2023-12-27 16:28:40 +08:00
|
|
|
|
public static string GetItemDisPlayName(int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataItem itemcfg = TableManager.Instance.Tables.Item.Get(id);
|
|
|
|
|
|
if(itemcfg==null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("该物体不存在:" + id);
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
return "";//等配置,延后
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-01-11 18:32:08 +08:00
|
|
|
|
|
2024-03-14 16:50:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 随机抽取
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
|
/// <param name="removeItem"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static T GetRandomItem<T>(IList<T> list, bool removeItem = false)
|
2024-01-11 18:32:08 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (list == null || list.Count == 0)
|
|
|
|
|
|
return default;
|
2024-03-14 16:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
int randomIndex = Random.Range(0, list.Count);
|
|
|
|
|
|
T result = list[randomIndex];
|
|
|
|
|
|
if (removeItem)
|
2024-01-11 18:32:08 +08:00
|
|
|
|
list.RemoveAt(randomIndex);
|
2024-03-14 16:50:31 +08:00
|
|
|
|
|
2024-01-11 18:32:08 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-14 16:50:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 随机不重复的取一定数量的物体
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
/// <param name="list">全部物体序列</param>
|
|
|
|
|
|
/// <param name="count">要取的数量</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static T[] GetRandomItems<T>(IList<T> list, int count)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (list == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("空数据");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (list.Count < count)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("数量错误");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (count <= 0)
|
|
|
|
|
|
return new T[0];
|
|
|
|
|
|
|
|
|
|
|
|
IList<T> listValue = new T[count];
|
|
|
|
|
|
|
2024-03-18 14:29:03 +08:00
|
|
|
|
Shuffle(list);
|
2024-03-14 16:50:31 +08:00
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < listValue.Count; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
listValue[i] = list[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (T[])listValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 洗牌算法打乱顺序
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-03-18 14:29:03 +08:00
|
|
|
|
public static void Shuffle<T>(IList<T> list)
|
2024-03-14 16:50:31 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (list == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("空数据");
|
2024-03-18 14:29:03 +08:00
|
|
|
|
return;
|
2024-03-14 16:50:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = list.Count - 1; i >= 0; --i)
|
|
|
|
|
|
{
|
|
|
|
|
|
int index = Random.Range(0, i + 1);
|
|
|
|
|
|
if (index == i)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
(list[index], list[i]) = (list[i], list[index]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-11 18:32:08 +08:00
|
|
|
|
public static T GetSceneRootComponent<T>(Scene scene) where T : Component
|
|
|
|
|
|
{
|
|
|
|
|
|
return scene.GetRootGameObjects().FirstOrDefault(root => root.GetComponent<T>() != null)?.GetComponent<T>();
|
|
|
|
|
|
}
|
2024-01-17 16:49:32 +08:00
|
|
|
|
|
2024-05-20 13:57:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据性能获取视频路径
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static void GetVideoPathByPerformance(ref string path)
|
|
|
|
|
|
{
|
2024-10-30 15:10:44 +08:00
|
|
|
|
if (!PerformanceManager.instance.data.useLowVideo)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (path.Contains("_Low"))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int dotIndex = path.LastIndexOf('.');
|
|
|
|
|
|
path = path.Insert(dotIndex, "_Low");
|
|
|
|
|
|
|
2024-05-20 13:57:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-17 16:49:32 +08:00
|
|
|
|
public class UISceneResult
|
|
|
|
|
|
{
|
|
|
|
|
|
public UIWindow uiWindow { get; private set; }
|
|
|
|
|
|
|
2024-02-21 17:54:08 +08:00
|
|
|
|
public SceneHandle sceneHandle{ get; private set; }
|
2024-01-17 16:49:32 +08:00
|
|
|
|
|
2024-02-21 17:54:08 +08:00
|
|
|
|
public UISceneResult(UIWindow uiWindow, SceneHandle sceneHandle)
|
2024-01-17 16:49:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.uiWindow = uiWindow;
|
|
|
|
|
|
this.sceneHandle = sceneHandle;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-17 17:22:12 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开带场景的UI,此函数会处理多场景渲染和主相机逻辑
|
|
|
|
|
|
/// 必须和CloseUIWithScene成对使用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="uiName"></param>
|
|
|
|
|
|
/// <param name="scenePath"></param>
|
|
|
|
|
|
/// <param name="uiParam"></param>
|
|
|
|
|
|
/// <param name="openLoadingUI">是否先打开加载UI</param>
|
|
|
|
|
|
/// <param name="loadSceneFinish">加载场景结束后,加载UI前的回调</param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-04-22 16:52:21 +08:00
|
|
|
|
public static async UniTask<UISceneResult> OpenUIWithScene(string uiName,
|
|
|
|
|
|
string scenePath,
|
|
|
|
|
|
LoadSceneMode loadSceneMode = LoadSceneMode.Additive,
|
2024-02-21 17:54:08 +08:00
|
|
|
|
Action<SceneHandle> loadSceneFinish = null)
|
2024-01-17 16:49:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
//隐藏上层UI
|
2024-08-30 15:58:29 +08:00
|
|
|
|
//UIManager.Instance.HideAllUI(UINameConst.UI_LoadingInterface, UINameConst.UI_LoadingProgressInterface);
|
2024-01-17 16:49:32 +08:00
|
|
|
|
|
2024-04-22 16:52:21 +08:00
|
|
|
|
SceneHandle sceneHandle = await GameSceneHelper.Instance.LoadSceneForUIView(scenePath, loadSceneMode);
|
2024-01-17 17:22:12 +08:00
|
|
|
|
if (sceneHandle == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"加载场景失败!scenePath:{scenePath}");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2024-01-19 17:03:07 +08:00
|
|
|
|
|
2024-01-17 16:49:32 +08:00
|
|
|
|
loadSceneFinish?.Invoke(sceneHandle);
|
|
|
|
|
|
//加载UI
|
2024-05-16 12:40:15 +08:00
|
|
|
|
UIWindow window = await UIManager.Instance.CreateAndOpenWindow(uiName);
|
2024-04-22 16:52:21 +08:00
|
|
|
|
|
2024-01-17 16:49:32 +08:00
|
|
|
|
return new UISceneResult(window, sceneHandle);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//关闭带场景的UI
|
|
|
|
|
|
//必须和OpenUIWithScene成对使用
|
|
|
|
|
|
public static async UniTask CloseUIWithScene(string uiName)
|
|
|
|
|
|
{
|
|
|
|
|
|
await GameSceneHelper.Instance.UnloadSceneForUIView();
|
|
|
|
|
|
UIManager.Instance.CloseWindow(uiName);
|
|
|
|
|
|
UIManager.Instance.ShowAllUI();
|
|
|
|
|
|
}
|
2024-02-21 17:15:24 +08:00
|
|
|
|
|
2024-04-03 14:23:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 切换场景
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="path"></param>
|
|
|
|
|
|
public static void ChangeUIScene(string path)
|
2024-03-19 19:23:42 +08:00
|
|
|
|
{
|
2024-04-03 14:23:41 +08:00
|
|
|
|
GameSceneHelper.Instance.ChangeSceneForUIView(path);
|
2024-03-19 19:23:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-22 15:41:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通用按钮监听绑定
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="button"></param>
|
|
|
|
|
|
/// <param name="action"></param>
|
|
|
|
|
|
/// <param name="playAudio"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static GameObject BindButton(Button button, Action action, bool playAudio = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (null == button)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("传入按钮为空,请检查按钮绑定参数!!!");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
button.onClick.AddListener(() =>
|
|
|
|
|
|
{
|
2024-08-29 13:11:40 +08:00
|
|
|
|
if (UIManager.IsClickDisabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
UIManager.Instance.OnClick();
|
2024-05-22 15:41:05 +08:00
|
|
|
|
if (playAudio)
|
|
|
|
|
|
{
|
2024-10-08 16:59:48 +08:00
|
|
|
|
var clickAudio = button.GetComponent<ClickAudio>();
|
|
|
|
|
|
if (clickAudio)
|
|
|
|
|
|
{
|
|
|
|
|
|
AudioManager.Instance.PlayAudio(clickAudio.AudioKey);
|
|
|
|
|
|
}
|
2024-05-22 15:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (GuideManager.Instance.IsGuiding)
|
|
|
|
|
|
{
|
2024-05-22 16:31:29 +08:00
|
|
|
|
// TODO 是否是引导按钮校验
|
2024-05-22 15:41:05 +08:00
|
|
|
|
action?.Invoke();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
action?.Invoke();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return button.gameObject;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-19 15:43:59 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 按概率随机一个布尔值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="probability">随机到true的概率,0f~1f</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static bool RandomBool(float probability)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Random.Range(0f, 1f) <= probability;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-02-21 17:15:24 +08:00
|
|
|
|
public static void SetImageGrayByChangeColor(Image image,bool isGray)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(isGray)
|
|
|
|
|
|
{
|
|
|
|
|
|
image.color = new Color((float)156 / (float)255, (float)156 / (float)255, (float)155 / (float)255);
|
|
|
|
|
|
}else
|
|
|
|
|
|
{
|
|
|
|
|
|
image.color = new Color(1, 1, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-26 19:28:14 +08:00
|
|
|
|
|
|
|
|
|
|
public static string GetCharacterShowModelPath(uint uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
var dic = CharacterDataInfoManager.Instance.DataDic;
|
|
|
|
|
|
if (dic.TryGetValue(uid, out var data))
|
|
|
|
|
|
{
|
|
|
|
|
|
var skinID = data.SkinID > 0 ? (int)data.SkinID : Constants.DEFULT_SKINID;
|
|
|
|
|
|
var skinCfg = TableManager.Instance.Tables.SkinCfg.Get(skinID, data.Cfg.RoleID);
|
|
|
|
|
|
if (skinCfg != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var prefabPath = PathEx.GetCharacterDisplayModelPath(skinCfg.NameID);
|
|
|
|
|
|
return prefabPath;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetVehicleShowModelPath(uint uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
var vehicleDataDic = VehicleCultivateDataManager.Instance.DataDic;
|
|
|
|
|
|
if (vehicleDataDic.TryGetValue(uid, out var vehicleData))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (vehicleData != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var prefabPath = PathEx.GetVehicleGameModelPath(vehicleData.Cfg.ID);
|
|
|
|
|
|
return prefabPath;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2024-04-12 18:57:02 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取技能图标路径
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="skillID"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetSkillIconByID(int skillID)
|
|
|
|
|
|
{
|
|
|
|
|
|
var table = TableManager.Instance.Tables.SkillConfig?.Get(skillID);
|
|
|
|
|
|
if (table == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("SkillConfig表找不到对应ID配置,ID: " + skillID);
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Constants.UI_Cultivata_skillIconFolder + table.IconPath;
|
|
|
|
|
|
}
|
2024-06-11 20:01:38 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置主场景相机机位
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="CameraIndex"></param>
|
|
|
|
|
|
public static void SetCurMainSceneCameraStand(int CameraIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<CameraStand> _allCameraStand = new();
|
|
|
|
|
|
var mainSceneHandle = GameSceneHelper.Instance.GetCurrentUIViewScene();
|
|
|
|
|
|
if (mainSceneHandle == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("mainsceneHandle is null");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var cameraStands = mainSceneHandle.Scene.GetRootGameObjects()
|
|
|
|
|
|
.FirstOrDefault(go => go.name == "CameraStands");
|
|
|
|
|
|
if (cameraStands == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("cameraStands is null");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_allCameraStand.AddRange(cameraStands.GetComponentsInChildren<CameraStand>());
|
|
|
|
|
|
if (CameraIndex > _allCameraStand.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("Index out of List CameraStands count: " + CameraIndex);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_allCameraStand[CameraIndex].Apply();
|
|
|
|
|
|
DebugUtil.Log("已设置主场景相机机位,请注意更新运镜动画timeline");
|
|
|
|
|
|
}
|
2024-07-03 19:05:46 +08:00
|
|
|
|
|
2024-07-04 13:49:45 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 判断是否客户端显示的道具
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="itemID"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-07-03 19:05:46 +08:00
|
|
|
|
public static bool CheckItemIsClientDisplay(int itemID)
|
|
|
|
|
|
{
|
|
|
|
|
|
var itemCfg = TableManager.Instance.Tables.Item.Get(itemID);
|
|
|
|
|
|
if (itemCfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("检测客户端是否显示,道具表无法找到配置,id:" + itemID);
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return itemCfg.Type == ItemType.Character || itemCfg.Type == ItemType.Normal ||
|
2024-10-30 18:02:52 +08:00
|
|
|
|
itemCfg.Type == ItemType.Useable || itemCfg.Type == ItemType.Vehicle;
|
2024-07-03 19:05:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 过滤奖励道具列表,取出不显示的列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="itemList"></param>
|
|
|
|
|
|
public static RewardItemList GetFilterRewardItemList(Reward reward)
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = new RewardItemList(reward.ID);
|
|
|
|
|
|
var itemList = reward.ItemList.Get();
|
|
|
|
|
|
for (int i = 0; i < itemList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = itemList[i];
|
|
|
|
|
|
if (CheckItemIsClientDisplay(item.ID))
|
|
|
|
|
|
{
|
|
|
|
|
|
list.AddItem(item.ID, item.Count);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
2024-07-04 13:49:45 +08:00
|
|
|
|
|
2024-08-06 13:40:53 +08:00
|
|
|
|
|
|
|
|
|
|
public static List<RewardItem> GetFilterRewardItemList(List<int> rewardIDList)
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = new List<RewardItem>();
|
|
|
|
|
|
for (int i = 0; i < rewardIDList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var reward = RewardManager.Instance.Get(rewardIDList[i]);
|
|
|
|
|
|
var itemList = reward.ItemList.Get();
|
|
|
|
|
|
for (int j = 0; j < itemList.Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = itemList[i];
|
|
|
|
|
|
if (CheckItemIsClientDisplay(item.ID))
|
|
|
|
|
|
{
|
|
|
|
|
|
var it = list.Find(t => t.ID == item.ID);
|
|
|
|
|
|
if (it == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
list.Add(new(item.ID, item.Count));
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
it.Count += item.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-04 13:49:45 +08:00
|
|
|
|
public static List<Item> GetFilterRewardItemList(List<Item> itemList)
|
|
|
|
|
|
{
|
|
|
|
|
|
var retItemList = new List<Item>();
|
|
|
|
|
|
for (int i = 0; i < itemList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = itemList[i];
|
|
|
|
|
|
if (CheckItemIsClientDisplay(item.ID))
|
|
|
|
|
|
{
|
|
|
|
|
|
retItemList.Add(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return retItemList;
|
|
|
|
|
|
}
|
2024-07-31 16:52:31 +08:00
|
|
|
|
|
|
|
|
|
|
public static void FilterListItem(ListItem listItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = listItem.Length - 1; i >= 0; i--)
|
|
|
|
|
|
{
|
|
|
|
|
|
var item = listItem.List[i];
|
|
|
|
|
|
if (!CheckItemIsClientDisplay(item.ID))
|
|
|
|
|
|
{
|
|
|
|
|
|
listItem.List.RemoveAt(i);
|
|
|
|
|
|
listItem.Ids.RemoveAt(i);
|
|
|
|
|
|
listItem.Counts.RemoveAt(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-05 20:05:12 +08:00
|
|
|
|
|
2024-08-14 15:00:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取关卡奖励
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="itemList"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static ItemList GetLevelRewardFilterItemList(ItemList itemList)
|
|
|
|
|
|
{
|
|
|
|
|
|
var retItemList = new ItemList();
|
|
|
|
|
|
for (int i = 0; i < itemList.Lists.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var itemCounts = itemList.Lists[i];
|
|
|
|
|
|
if (i == (int)ItemSource.LevelPassFirst || i == (int)ItemSource.LevelPassNormal ||
|
|
|
|
|
|
i == (int)ItemSource.LevelPassStar1 || i == (int)ItemSource.LevelPassStar2 ||
|
|
|
|
|
|
i == (int)ItemSource.LevelPassStar3)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int j = 0; j < itemCounts.Ids.Count;j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var id = itemCounts.Ids[j];
|
|
|
|
|
|
var count = itemCounts.Counts[j];
|
|
|
|
|
|
retItemList.Set((uint)i, id, count);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return retItemList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-28 16:16:09 +08:00
|
|
|
|
public static bool CheckIsCharacterMaxLevel(uint uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(uid, out var characterDataInfo))
|
|
|
|
|
|
{
|
|
|
|
|
|
var level = characterDataInfo.Level;
|
2024-10-29 15:34:45 +08:00
|
|
|
|
var breakCfg = TableManager.Instance.Tables.CharacterBreak;
|
|
|
|
|
|
var dataBreak = breakCfg.Get((int)characterDataInfo.Cfg.RoleID, (int)characterDataInfo.BreakLevel);
|
|
|
|
|
|
var maxLevel = dataBreak.LevelLimit;
|
|
|
|
|
|
//var cfg = TableManager.Instance.Tables.CharacterLevelExp.DataList;
|
|
|
|
|
|
if (level >= maxLevel)
|
2024-10-28 16:16:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-05 20:05:12 +08:00
|
|
|
|
public static string GetCurLevelTypeStr()
|
|
|
|
|
|
{
|
2024-09-20 19:00:18 +08:00
|
|
|
|
var levelInfo = LevelManager.Instance.CurrLevel;
|
2024-09-02 14:55:43 +08:00
|
|
|
|
var levelGroup = levelInfo.GroupInfo;
|
2024-08-05 20:05:12 +08:00
|
|
|
|
string lvTypeStr = "";
|
2024-09-02 18:51:47 +08:00
|
|
|
|
switch (levelGroup.Cfg.LevelDifficulty)
|
2024-08-05 20:05:12 +08:00
|
|
|
|
{
|
2024-09-02 14:28:13 +08:00
|
|
|
|
case E_LevelDifficulty.Easy:
|
2024-08-05 20:05:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
lvTypeStr = GetLocalizeText("level_type_easy");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2024-09-02 14:28:13 +08:00
|
|
|
|
case E_LevelDifficulty.Hard:
|
2024-08-05 20:05:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
lvTypeStr = GetLocalizeText("level_type_hard");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2024-09-02 14:28:13 +08:00
|
|
|
|
/*case E_LevelDifficulty.Plot:
|
2024-08-05 20:05:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
lvTypeStr = GetLocalizeText("level_type_plot");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2024-09-02 14:28:13 +08:00
|
|
|
|
case E_LevelDifficulty.Resource:
|
2024-08-05 20:05:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
lvTypeStr = GetLocalizeText("level_type_resource");
|
|
|
|
|
|
break;
|
2024-09-02 14:28:13 +08:00
|
|
|
|
}*/
|
2024-08-05 20:05:12 +08:00
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return lvTypeStr;
|
|
|
|
|
|
}
|
2024-09-18 13:03:35 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-09-24 19:44:37 +08:00
|
|
|
|
/// 新手引导阶段完成专属事件打点
|
2024-09-18 13:03:35 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="stepName"></param>
|
|
|
|
|
|
public static void GuideStepBiEvent(string stepName)
|
|
|
|
|
|
{
|
2024-09-20 12:38:48 +08:00
|
|
|
|
#if SDK_TALKINGDATA
|
2024-09-24 19:44:37 +08:00
|
|
|
|
//BIManager.Instance.TrackEvent(BIManager.BI_Guide, new Dictionary<string, object>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// {stepName, 1 }
|
|
|
|
|
|
//});
|
2024-09-24 13:48:50 +08:00
|
|
|
|
|
|
|
|
|
|
//TD 引导专属事件打点
|
|
|
|
|
|
BIManager.Instance.TrackEvent(TalkingDataEventName.GuideFinish, param1: stepName);
|
2024-09-20 12:38:48 +08:00
|
|
|
|
#endif
|
2024-09-18 13:03:35 +08:00
|
|
|
|
}
|
2024-09-24 19:44:37 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 新手引导打点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="GuideID">引导ID</param>
|
2024-09-27 12:12:34 +08:00
|
|
|
|
/// <param name="step">标识引导开始(0)或结束(1)</param>
|
|
|
|
|
|
public static void GuideStepBiEvent(int GuideID, int step)
|
2024-09-24 19:44:37 +08:00
|
|
|
|
{
|
|
|
|
|
|
#if SDK_TALKINGDATA
|
2024-09-30 13:06:07 +08:00
|
|
|
|
BIManager.Instance.TrackEvent("guide_step", new Dictionary<string, object>
|
2024-09-24 19:44:37 +08:00
|
|
|
|
{
|
2024-09-27 12:12:34 +08:00
|
|
|
|
{"guide_id",GuideID },
|
|
|
|
|
|
{"guide_event",step }
|
2024-09-24 19:44:37 +08:00
|
|
|
|
});
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
2024-09-20 11:38:07 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 主线关卡埋点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="levelName">story/battle/event/res(关卡类别)_easy/hard(难度类别)_xx(关卡ID)</param>
|
|
|
|
|
|
/// <param name="eventName">start/pass/fail等</param>
|
|
|
|
|
|
public static void MainLevelBIEvent(string levelName, string eventName)
|
|
|
|
|
|
{
|
2024-09-20 12:38:48 +08:00
|
|
|
|
#if SDK_TALKINGDATA
|
2024-09-20 11:38:07 +08:00
|
|
|
|
BIManager.Instance.TrackEvent(BIManager.BI_MainLevel, new Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"level",levelName },
|
|
|
|
|
|
{"event",eventName }
|
|
|
|
|
|
});
|
2024-09-20 12:38:48 +08:00
|
|
|
|
#endif
|
2024-09-20 11:38:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 记录关卡掉落
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ItemID"></param>
|
|
|
|
|
|
/// <param name="itemCount"></param>
|
|
|
|
|
|
public static void MainLevelRewardEvent(string ItemID,int itemCount)
|
|
|
|
|
|
{
|
2024-09-20 12:38:48 +08:00
|
|
|
|
#if SDK_TALKINGDATA
|
2024-09-20 11:38:07 +08:00
|
|
|
|
BIManager.Instance.TrackEvent(BIManager.BI_LevelDrop, new Dictionary<string, object>
|
|
|
|
|
|
{
|
|
|
|
|
|
{"ItemID",ItemID },
|
|
|
|
|
|
{"Count",itemCount }
|
|
|
|
|
|
});
|
2024-09-20 12:38:48 +08:00
|
|
|
|
#endif
|
2024-09-23 12:34:04 +08:00
|
|
|
|
}
|
2024-12-11 17:24:58 +08:00
|
|
|
|
|
2024-12-11 19:30:20 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 世界坐标转UI坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="worldPos"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-12-11 17:24:58 +08:00
|
|
|
|
public static Vector2 World2UIPos(Vector3 worldPos)
|
|
|
|
|
|
{
|
|
|
|
|
|
var viewPortPos = CameraManager.Instance.MainCamera.WorldToViewportPoint(worldPos);
|
|
|
|
|
|
var posX = viewPortPos.x * UIManager.Instance.Size.x;
|
|
|
|
|
|
var posY = viewPortPos.y * UIManager.Instance.Size.y;
|
|
|
|
|
|
var uiPos = new Vector3(posX, posY, 0);
|
|
|
|
|
|
return uiPos;
|
|
|
|
|
|
}
|
2024-12-11 19:30:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetCommandSkillIcon(int skillID)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataPlayerSkill dataPlayerSkill = TableManager.Instance.Tables.PlayerSkillConfig.Get(skillID);
|
|
|
|
|
|
if (dataPlayerSkill == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"指挥官技能表ID:{skillID}不存在!");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
string iconPath = $"{Framework.Constants.UI_PlaySkill_IconPathFolder}{dataPlayerSkill.IconPath}.png";
|
|
|
|
|
|
return iconPath;
|
|
|
|
|
|
}
|
2024-12-25 12:40:51 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 这是一个临时的方法,用于获取材质球
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="paintPath"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static async UniTask<Material> GetVehiclePaintMaterial(string paintPath)
|
|
|
|
|
|
{
|
|
|
|
|
|
Material ret = null;
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
ret = AssetDatabase.LoadAssetAtPath<Material>(paintPath);
|
|
|
|
|
|
#else
|
|
|
|
|
|
ret = await AssetManager.Instance.LoadAssetAsync<Material>(paintPath);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
//ret = await AssetManager.Instance.LoadAssetAsync<Material>(paintPath);
|
|
|
|
|
|
if (ret == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("找不到材质球:" + paintPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|