| | |
| | | return null;
|
| | | }
|
| | |
|
| | | var config = NPCConfig.Get(id);
|
| | | var model = GameObjectPoolManager.Instance.RequestNpcGameObject(id);
|
| | | 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"))
|
| | | if (!model && config.NPCType == (int)E_NpcType.Func)
|
| | | {
|
| | | _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;
|
| | | model = GameObjectPoolManager.Instance.RequestDefaultFuncNpc();
|
| | | }
|
| | |
|
| | | var isDance = false;
|
| | | if (config.NPCType == (int)E_NpcType.Func)
|
| | | if (!model)
|
| | | {
|
| | | var clipInfos = animator.runtimeAnimatorController.animationClips;
|
| | | foreach (var item in clipInfos)
|
| | | return null;
|
| | | }
|
| | |
|
| | | var animator = model.GetComponent<Animator>();
|
| | | if (animator != null)
|
| | | {
|
| | | var suffix = AnimatorControllerLoader.controllerUISuffix;
|
| | | var _modeName = config.MODE;
|
| | | if (config.MODE.StartsWith("A_Zs"))
|
| | | {
|
| | | if (item.name == "Idle2")
|
| | | _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)
|
| | | {
|
| | | isDance = true;
|
| | | break;
|
| | | 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);
|
| | | }
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | 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)
|