234 lines
8.3 KiB
C#
234 lines
8.3 KiB
C#
using System.Collections.Generic;
|
|
using Thousandto.Cfg.Data;
|
|
using Thousandto.Code.Center;
|
|
using Thousandto.Core.Asset;
|
|
using Thousandto.Core.Base;
|
|
using FLogger = UnityEngine.Gonbest.MagicCube.FLogger;
|
|
|
|
namespace Thousandto.Code.Logic
|
|
{
|
|
/// <summary>
|
|
/// 不会被清理的资源设定
|
|
/// </summary>
|
|
public class ImmortalResSystem
|
|
{
|
|
#region//私有变量
|
|
//预加载的总数
|
|
private int _preLoadSum = 0;
|
|
#endregion
|
|
|
|
#region //公共接口
|
|
|
|
/// <summary>
|
|
/// 清理
|
|
/// </summary>
|
|
public void ClearImmortalAll()
|
|
{
|
|
GameCenter.PrefabManager.ClearAllLock();
|
|
GameCenter.TextureManager.ClearAllLock();
|
|
GameCenter.AnimManager.ClearAllLock();
|
|
GameCenter.AudioManager.ClearAllLock();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置不会被删除的资源
|
|
/// </summary>
|
|
/// <param name="bClear"></param>
|
|
public void SetImmortalResouce()
|
|
{
|
|
var lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
|
FLogger.DebugAssert(lp != null, "GetLocalPlayer()==null!");
|
|
if (lp != null && lp.Skin != null)
|
|
{
|
|
|
|
//自身模型,坐骑,武器,披风,以及关联特效
|
|
List<string> vfxList = new List<string>();
|
|
|
|
var ModelID = lp.Skin.GetSkinPartCfgID(FSkinPartCode.Body);
|
|
var cfg = FSkinModelConfig.GetConfigData(ModelID);
|
|
|
|
if (cfg != null)
|
|
{
|
|
GameCenter.PrefabManager.LockAsset(cfg.GetModelPath(ref vfxList));
|
|
//动作的处理
|
|
var boneIdx = AssetUtils.GetPlayerBoneIndex(cfg.ModelID);
|
|
Dictionary<string, bool> anims = FPlayerAnimRelation.SceneAnims;
|
|
var iterAnim = anims.GetEnumerator();
|
|
try
|
|
{
|
|
while (iterAnim.MoveNext())
|
|
{
|
|
if (iterAnim.Current.Value)
|
|
{
|
|
//分离的资源需要载入两个动画
|
|
GameCenter.AnimManager.LockAsset(cfg.ModelType, boneIdx, iterAnim.Current.Key + AnimationPlayer.UpBodySuffix);
|
|
GameCenter.AnimManager.LockAsset(cfg.ModelType, boneIdx, iterAnim.Current.Key + AnimationPlayer.LowerBodySuffix);
|
|
}
|
|
else
|
|
{
|
|
GameCenter.AnimManager.LockAsset(cfg.ModelType, boneIdx, iterAnim.Current.Key);
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
iterAnim.Dispose();
|
|
}
|
|
}
|
|
|
|
ModelID = lp.Skin.GetSkinPartCfgID(FSkinPartCode.GodWeaponHead);
|
|
cfg = FSkinModelConfig.GetConfigData(ModelID);
|
|
if (cfg != null)
|
|
{
|
|
GameCenter.PrefabManager.LockAsset(cfg.GetModelPath(ref vfxList));
|
|
}
|
|
ModelID = lp.Skin.GetSkinPartCfgID(FSkinPartCode.GodWeaponBody);
|
|
cfg = FSkinModelConfig.GetConfigData(ModelID);
|
|
if (cfg != null)
|
|
{
|
|
GameCenter.PrefabManager.LockAsset(cfg.GetModelPath(ref vfxList));
|
|
}
|
|
ModelID = lp.Skin.GetSkinPartCfgID(FSkinPartCode.GodWeaponVfx);
|
|
cfg = FSkinModelConfig.GetConfigData(ModelID);
|
|
if (cfg != null)
|
|
{
|
|
GameCenter.PrefabManager.LockAsset(cfg.GetModelPath(ref vfxList));
|
|
}
|
|
|
|
ModelID = LocalPlayerRoot.CurMountId;
|
|
cfg = FSkinModelConfig.GetConfigData(ModelID);
|
|
if (cfg != null)
|
|
{
|
|
GameCenter.PrefabManager.LockAsset(cfg.GetModelPath(ref vfxList));
|
|
}
|
|
|
|
//角色关联的特效列表
|
|
for (int i = 0; i < vfxList.Count; i++)
|
|
{
|
|
GameCenter.PrefabManager.LockAsset(vfxList[i]);
|
|
}
|
|
|
|
//设置技能的关联资源
|
|
SetImmortalResourceSkill((int)lp.Occ);
|
|
|
|
FLogger.DebugLog("设置持续性资源成功!!");
|
|
}
|
|
else
|
|
{
|
|
FLogger.DebugLogError("设置持续性资源失败,本地玩家的skin为null");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择角色后
|
|
/// </summary>
|
|
/// <param name="roleInfo"></param>
|
|
public void SetImmortalResourceFirst(int occ)
|
|
{
|
|
|
|
//技能关联特效
|
|
SetImmortalResourceSkill(occ);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 持久化资源的预加载
|
|
/// </summary>
|
|
public void StartPreLoadImmort()
|
|
{
|
|
_preLoadSum = 0;
|
|
if (AssetsCleaner.CheckedMoreFast())
|
|
{
|
|
return;
|
|
}
|
|
GameCenter.TextureManager.PreLoadLockAsset(null/*() => {
|
|
FLogger.LogTime("图片资源加载完毕");
|
|
}*/);
|
|
|
|
GameCenter.AnimManager.PreLoadLockAsset(null/*()=>{
|
|
FLogger.LogTime("动作资源加载完毕");
|
|
}*/);
|
|
|
|
GameCenter.AudioManager.PreLoadLockAsset(null/*() => {
|
|
FLogger.LogTime("声音资源加载完毕");
|
|
}*/);
|
|
|
|
GameCenter.PrefabManager.PreLoadLockAsset(null/*() => {
|
|
FLogger.LogTime("模型资源加载完毕");
|
|
}*/);
|
|
|
|
_preLoadSum = GetPreLoadCurrentCount();
|
|
//FLogger.LogTime("持久资源的加载!!" + _preLoadSum);
|
|
}
|
|
|
|
//获取正在下载总数
|
|
public int GetPreLoadSum()
|
|
{
|
|
return _preLoadSum;
|
|
}
|
|
//获取正在加载的当前数
|
|
public int GetPreLoadCurrentCount()
|
|
{
|
|
return GameCenter.TextureManager.LockLoadRemainCount
|
|
+GameCenter.AnimManager.LockLoadRemainCount
|
|
+ GameCenter.AudioManager.LockLoadRemainCount
|
|
+ GameCenter.PrefabManager.LockLoadRemainCount;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region //私有化方法
|
|
//设置持续化特效技能
|
|
private void SetImmortalResourceSkill(int career)
|
|
{
|
|
var em = DeclareSkill.CacheData.GetEnumerator();
|
|
try
|
|
{
|
|
while (em.MoveNext())
|
|
{
|
|
if (em.Current.Value.UserType == career)
|
|
{
|
|
var cfg = em.Current.Value;
|
|
var visaulInfo = GameCenter.SkillVisualManager.Find(cfg.VisualDef);
|
|
if (visaulInfo != null)
|
|
{
|
|
for (int i = 0; i < visaulInfo.DataList.Count; ++i)
|
|
{
|
|
var eventData = visaulInfo.DataList[i];
|
|
//特效
|
|
if (eventData.EventType == SkillEventDefine.PlayVfx)
|
|
{
|
|
var vfxData = eventData as PlayVfxEventInfo;
|
|
GameCenter.PrefabManager.LockAsset(AssetUtils.GetModelAssetPath(ModelTypeCode.SkillVFX, vfxData.VfxID));
|
|
}
|
|
|
|
//声音
|
|
if (eventData.EventType == SkillEventDefine.PlaySfx)
|
|
{
|
|
var sfxData = eventData as PlaySfxEventInfo;
|
|
GameCenter.AudioManager.LockAsset(sfxData.Sound, AudioTypeCode.Sfx);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
em.Dispose();
|
|
}
|
|
}
|
|
|
|
//设置场景的的资源持续化
|
|
private void SetImmortalResourceScene(int mapID)
|
|
{
|
|
DeclareMapsetting cfg = DeclareMapsetting.Get(mapID);
|
|
GameCenter.AudioManager.LockAsset(cfg.Music, AudioTypeCode.Music);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|