|
@@ -3,6 +3,7 @@ using CommonAI.Zone.ZoneEditor;
|
|
|
using CommonLang;
|
|
|
using FairyGUI;
|
|
|
using Sirenix.Utilities;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using UnityEngine;
|
|
@@ -42,6 +43,15 @@ namespace ET.Client
|
|
|
private readonly HashMap<string, AudioClip> audioPool = new();
|
|
|
private readonly List<GComponent>headBarPool = new();
|
|
|
|
|
|
+ public async ETTask CachePrefab(string name)
|
|
|
+ {
|
|
|
+ var handle = await YooAssetProxy.LoadAssetAsync<GameObject>(name);
|
|
|
+ var prefab = handle.GetAssetObject<GameObject>();
|
|
|
+ var gameobj = UnityEngine.Object.Instantiate(prefab, GlobalViewComponent.Instance.RecycleNode, true);
|
|
|
+ gameobj.name = name;
|
|
|
+ RecycleObject(gameobj);
|
|
|
+ }
|
|
|
+
|
|
|
//TODO: 选取当前场景的单位、技能(事件触发等等)
|
|
|
//TODO: BUFF
|
|
|
public async ETTask CacheSceneObject(int scnId)
|
|
@@ -64,16 +74,42 @@ namespace ET.Client
|
|
|
var units = templates.getUnits();
|
|
|
foreach(var unit in units.Values)
|
|
|
{
|
|
|
- var name = $"Unit_{unit.FileName}";
|
|
|
- var handle = await YooAssetProxy.LoadAssetAsync<GameObject>(name);
|
|
|
- var prefab = handle.GetAssetObject<GameObject>();
|
|
|
- var gameobj = UnityEngine.Object.Instantiate(prefab, GlobalViewComponent.Instance.RecycleNode, true);
|
|
|
- gameobj.name = name;
|
|
|
- RecycleObject(gameobj);
|
|
|
+ await CachePrefab($"Unit_{unit.FileName}");
|
|
|
|
|
|
if(unit.FootCircleEffect != null) CacheLaunchEffect(unit.FootCircleEffect, ref effectlist, ref soundlist);
|
|
|
if (unit.SpawnEffect != null) CacheLaunchEffect(unit.SpawnEffect, ref effectlist, ref soundlist);
|
|
|
if (unit.DeadActionEffect != null) CacheLaunchEffect(unit.DeadActionEffect, ref effectlist, ref soundlist);
|
|
|
+ if (unit.DeadEffect != null) CacheLaunchEffect(unit.DeadEffect, ref effectlist, ref soundlist);
|
|
|
+ if (unit.HitBreakEffect != null) CacheLaunchEffect(unit.HitBreakEffect, ref effectlist, ref soundlist);
|
|
|
+
|
|
|
+ if (!unit.PreloadResources.IsNullOrWhitespace() )
|
|
|
+ {
|
|
|
+ var split = unit.PreloadResources.Split(';');
|
|
|
+ foreach(var res in split)
|
|
|
+ {
|
|
|
+ var realres = res;
|
|
|
+ var cns = res.Split('|');
|
|
|
+ var cnt = 1;
|
|
|
+ if (cns.Length > 1)
|
|
|
+ {
|
|
|
+ realres = cns[0];
|
|
|
+ try
|
|
|
+ {
|
|
|
+ cnt = Convert.ToInt32(cns[1]);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ Log.Error($"PreloadResources illegal: {unit.PreloadResources}");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var i = 0; i < cnt; i++)
|
|
|
+ {
|
|
|
+ await CachePrefab(realres);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var skills = templates.getAllSkillData();
|
|
@@ -101,12 +137,7 @@ namespace ET.Client
|
|
|
|
|
|
foreach (var ef in effectlist)
|
|
|
{
|
|
|
- var name = $"Effect_{ef}";
|
|
|
- var handle = await YooAssetProxy.LoadAssetAsync<GameObject>(name);
|
|
|
- var prefab = handle.GetAssetObject<GameObject>();
|
|
|
- var gameobj = UnityEngine.Object.Instantiate(prefab, GlobalViewComponent.Instance.RecycleNode, true);
|
|
|
- gameobj.name = name;
|
|
|
- RecycleObject(gameobj);
|
|
|
+ await CachePrefab($"Effect_{ef}");
|
|
|
}
|
|
|
|
|
|
foreach(var sound in soundlist)
|