// using UnityEngine;
|
// using System.Collections.Generic;
|
// using System;
|
|
// public class UI3DModelFactory
|
// {
|
// static UI3DModelFactory()
|
// {
|
// GlobalTimeEvent.Instance.minuteEvent += OnPerMinute;
|
// }
|
|
// public static GameObject LoadUINPC(int id)
|
// {
|
// if (!NPCConfig.Has(id))
|
// {
|
// return null;
|
// }
|
|
// try
|
// {
|
// var config = NPCConfig.Get(id);
|
// var model = GameObjectPoolManager.Instance.RequestNpcGameObject(id);
|
|
// if (!model && config.NPCType == (int)E_NpcType.Func)
|
// {
|
// model = GameObjectPoolManager.Instance.RequestDefaultFuncNpc();
|
// }
|
|
// if (!model)
|
// {
|
// return null;
|
// }
|
|
// var animator = model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// var suffix = AnimatorControllerLoader.controllerUISuffix;
|
// var _modeName = config.MODE;
|
// if (config.MODE.StartsWith("A_Zs"))
|
// {
|
// _modeName = "A_Zs";
|
// }
|
// else if (config.MODE.StartsWith("A_Fs"))
|
// {
|
// _modeName = "A_Fs";
|
// }
|
// var animatorController = AnimatorControllerLoader.LoadMobController(suffix, _modeName);
|
// if (animatorController != null)
|
// {
|
// animator.runtimeAnimatorController = animatorController;
|
// }
|
|
// var isDance = false;
|
// if (config.NPCType == (int)E_NpcType.Func)
|
// {
|
// var clipInfos = animator.runtimeAnimatorController.animationClips;
|
// foreach (var item in clipInfos)
|
// {
|
// if (item.name == "Idle2")
|
// {
|
// isDance = true;
|
// break;
|
// }
|
// }
|
// }
|
|
// animator.enabled = true;
|
// if (isDance)
|
// {
|
// animator.Play(GAStaticDefine.State_Dance);
|
// }
|
// else
|
// {
|
// animator.SetInteger(GAStaticDefine.Param_Action, GAStaticDefine.Act_Idle);
|
// animator.Play(GAStaticDefine.State_IdleHash);
|
// }
|
// }
|
|
// LayerUtility.SetLayer(model, LayerUtility.Monster, true);
|
// return model;
|
// }
|
// catch (Exception e)
|
// {
|
// Debug.Log("LoadUINPC Error: " + e.Message);
|
// return null;
|
// }
|
// }
|
|
// public static void ReleaseUINPC(int id, GameObject model)
|
// {
|
// var animator = model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// ResetRealmBossAnimator(id, animator);
|
// animator.enabled = false;
|
// }
|
|
// if (model)
|
// {
|
// model.transform.localScale = Vector3.one;
|
// }
|
|
// var prefab = InstanceResourcesLoader.LoadNpcPrefab(id);
|
// if (prefab)
|
// {
|
// GameObjectPoolManager.Instance.ReleaseGameObject(prefab, model);
|
// }
|
// else
|
// {
|
// GameObjectPoolManager.Instance.ReleaseDefaultFuncNPC(model);
|
// }
|
// }
|
|
// private static void ResetRealmBossAnimator(int _id, Animator animator)
|
// {
|
// if (RealmLVUPTaskConfig.IsRealmBoss(_id))
|
// {
|
// var npcConfig = NPCConfig.Get(_id);
|
// if (npcConfig != null)
|
// {
|
// var runtimeController = AnimatorControllerLoader.LoadMobController(AnimatorControllerLoader.controllerSuffix, npcConfig.MODE);
|
// if (runtimeController != null)
|
// {
|
// animator.runtimeAnimatorController = runtimeController;
|
// }
|
// }
|
// }
|
// }
|
|
// public static GameObject LoadUIHorse(int id)
|
// {
|
// var prefab = InstanceResourcesLoader.LoadModelRes(id, false);
|
// if (prefab == null)
|
// {
|
// return null;
|
// }
|
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
// var model = pool.Request();
|
|
// var animator = model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// var config = ModelResConfig.Get(id);
|
// var suffix = AnimatorControllerLoader.controllerUISuffix;
|
// var animatorController = AnimatorControllerLoader.LoadMobController(suffix, config.ResourcesName);
|
// if (animatorController != null)
|
// {
|
// animator.runtimeAnimatorController = animatorController;
|
// }
|
|
// animator.enabled = true;
|
// animator.SetInteger(GAStaticDefine.Param_Action, GAStaticDefine.Act_Idle);
|
// animator.Play(GAStaticDefine.State_IdleHash);
|
// }
|
|
// return model;
|
// }
|
|
// public static void ReleaseUIHourse(int id, GameObject model)
|
// {
|
// var prefab = InstanceResourcesLoader.LoadModelRes(id, false);
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
|
// var animator = model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = false;
|
// }
|
|
// pool.Release(model);
|
// }
|
|
// static Dictionary<int, GameObject> treasureModels = new Dictionary<int, GameObject>();
|
// static Dictionary<int, DateTime> treasureModelReleaseTimes = new Dictionary<int, DateTime>();
|
|
// public static GameObject LoadUITreasure(int _id)
|
// {
|
// GameObject instance = null;
|
// if (treasureModels.ContainsKey(_id))
|
// {
|
// instance = treasureModels[_id];
|
// if (instance == null)
|
// {
|
// treasureModels.Remove(_id);
|
// }
|
// }
|
|
// if (instance == null)
|
// {
|
// var config = TreasureConfig.Get(_id);
|
// var folder = string.Empty;
|
// switch ((TreasureCategory)config.Category)
|
// {
|
// case TreasureCategory.Human:
|
// folder = "RenZu";
|
// break;
|
// case TreasureCategory.Demon:
|
// folder = "MoZu";
|
// break;
|
// case TreasureCategory.Fairy:
|
// folder = "XianZu";
|
// break;
|
// case TreasureCategory.King:
|
// folder = "WangZhe";
|
// break;
|
// default:
|
// break;
|
// }
|
|
// var prefab = UILoader.LoadTreasure(folder, config.Model);
|
// instance = GameObject.Instantiate(prefab);
|
// treasureModels[_id] = instance;
|
|
// UILoader.UnLoadTreasure(folder, config.Model);
|
// }
|
|
// var animator = instance.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = true;
|
// }
|
|
// LayerUtility.SetLayer(instance, LayerUtility.UILayer, true);
|
// if (treasureModelReleaseTimes.ContainsKey(_id))
|
// {
|
// treasureModelReleaseTimes.Remove(_id);
|
// }
|
// return instance;
|
// }
|
|
// public static void ReleaseUITreasure(int _id, GameObject _model)
|
// {
|
// treasureModelReleaseTimes[_id] = DateTime.Now;
|
// var animator = _model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = false;
|
// }
|
|
// _model.SetActive(false);
|
// }
|
|
// private static void OnPerMinute()
|
// {
|
// var keys = new List<int>(treasureModelReleaseTimes.Keys);
|
// for (int i = 0; i < keys.Count; i++)
|
// {
|
// var key = keys[i];
|
// var releaseTime = treasureModelReleaseTimes[key];
|
// if ((DateTime.Now - releaseTime).TotalSeconds > Constants.UnUsedRes_Unload_Delay)
|
// {
|
// if (treasureModels.ContainsKey(key))
|
// {
|
// var model = treasureModels[key];
|
// treasureModels.Remove(key);
|
// if (model != null)
|
// {
|
// GameObject.Destroy(model);
|
// }
|
// }
|
// }
|
// }
|
// }
|
|
// //法器
|
// public static GameObject LoadUIFaqi(string pathName, string modelName)
|
// {
|
// var prefab = UILoader.LoadFaqi(pathName, modelName);
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
// var model = pool.Request();
|
|
// var animator = model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = true;
|
// }
|
|
// LayerUtility.SetLayer(model, LayerUtility.UILayer, true);
|
// return model;
|
// }
|
|
// public static GameObject LoadUIGodWeapon(int _type)
|
// {
|
// var prefab = UILoader.LoadGodWeapon(GeneralDefine.godWeaponMobs[_type]);
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
// var model = pool.Request();
|
|
// var animator = model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = true;
|
// }
|
|
// LayerUtility.SetLayer(model, LayerUtility.UILayer, true);
|
// return model;
|
// }
|
|
// public static void ReleaseUIGodWeapon(int _type, GameObject _model)
|
// {
|
// if (!GameObjectPoolManager.IsValid())
|
// {
|
// return;
|
// }
|
// if (!GeneralDefine.godWeaponMobs.ContainsKey(_type))
|
// {
|
// return;
|
// }
|
// var prefab = UILoader.LoadGodWeapon(GeneralDefine.godWeaponMobs[_type]);
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
|
// var animator = _model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = false;
|
// }
|
|
// pool.Release(_model);
|
// }
|
|
// public static void ReleaseUIFaqi(string pathName, string modelName, GameObject _model)
|
// {
|
// if (!GameObjectPoolManager.IsValid())
|
// {
|
// return;
|
// }
|
|
// var prefab = UILoader.LoadFaqi(pathName, modelName);
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
|
// var animator = _model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = false;
|
// }
|
|
// pool.Release(_model);
|
// }
|
|
|
|
// public static GameObject LoadUIWing(int _id)
|
// {
|
// var prefab = InstanceResourcesLoader.LoadModelRes(_id, false);
|
// if (prefab == null)
|
// {
|
// return null;
|
// }
|
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
// var model = pool.Request();
|
// var animator = model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = true;
|
// }
|
// return model;
|
// }
|
|
// public static void ReleaseUIWing(int _id, GameObject _model)
|
// {
|
// var prefab = InstanceResourcesLoader.LoadModelRes(_id, false);
|
// var pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
// var animator = _model.GetComponent<Animator>();
|
// if (animator != null)
|
// {
|
// animator.enabled = false;
|
// }
|
|
// pool.Release(_model);
|
// }
|
// }
|