// //-------------------------------------------------------- // // [Author]: 第二世界 // // [ Date ]: Friday, September 22, 2017 // //-------------------------------------------------------- // using UnityEngine; // using System.Collections.Generic; // using LitJson; // namespace vnxbqy.UI // { // public class UI3DShowHero // { // int weaponId; // int clothesId; // int wingsId; // int secondaryId; // int extraSecondaryId; // int job; // GameObject weaponModel; // GameObject clothesModel; // GameObject wingsModel; // GameObject secondaryModel; // GameObject extraSecondaryModel; // Animator wingsAnimator; // Animator clothesAnimator; // RuntimeAnimatorController cacheClothedAC; // Transform showPoint; // List godWeaponSFXList = new List(); // GameObject reikiRootShowPoint = null; // SFXController reikiRootEffect = null; //强化大师特效 // SFXController titleRootEffect = null; //称号全身特效 // bool isSuit = false; // public GameObject Show(UI3DPlayerExhibitionData data, Transform showPoint) // { // this.showPoint = showPoint; // this.job = data.job; // var clothes = data.fashionClothesId > 0 ? data.fashionClothesId : data.clothesId; // isSuit = data.suitLevel > 0; // var weaponId = data.fashionWeaponId > 0 ? data.fashionWeaponId : data.weaponId; // var wingsId = data.wingsId; // var secondaryId = data.fashionSecondaryId > 0 ? data.fashionSecondaryId : data.secondaryId; // var jobConfig = JobSetupConfig.Get(job); // var clothesResId = 0; // if (clothes == 0) // { // clothesResId = jobConfig.BaseEquip[0]; // } // else // { // var item = ItemConfig.Get(clothes); // clothesResId = item == null ? clothesResId = jobConfig.BaseEquip[0] : item.ChangeOrd; // } // PutOnClothes(job, clothesResId); // var weaponResId = 0; // if (weaponId == 0) // { // weaponResId = jobConfig.BaseEquip[1]; // } // else // { // var item = ItemConfig.Get(weaponId); // weaponResId = item == null ? weaponResId = jobConfig.BaseEquip[1] : item.ChangeOrd; // } // PutOnWeapon(job, weaponResId); // var secondaryResId = 0; // if (secondaryId == 0) // { // if (data.fashionClothesId == 0) // { // if (this.job == 1) // { // secondaryResId = ModelResConfig.GetHandByClothesID(clothesId); // } // else if (this.job == 2) // { // secondaryResId = jobConfig.BaseEquip[2]; // } // } // } // else // { // var item = ItemConfig.Get(secondaryId); // if (item != null) // { // secondaryResId = item.ChangeOrd; // } // } // if (secondaryResId != 0) // { // PutOnSecondary(job, secondaryResId); // } // var extraSecondaryId = 0; // if (data.job == 1) // { // extraSecondaryId = ModelResConfig.GetHandByClothesID(0); // if (data.fashionClothesId > 0) // { // var _item = ItemConfig.Get(data.fashionClothesId); // if (_item != null) // { // extraSecondaryId = ModelResConfig.GetHandByClothesID(_item.ChangeOrd); // } // } // else if (data.clothesId > 0) // { // var _item = ItemConfig.Get(data.clothesId); // if (_item != null) // { // extraSecondaryId = ModelResConfig.GetHandByClothesID(_item.ChangeOrd); // } // } // if (secondaryResId == 0 // || (data.fashionClothesId != 0 && data.fashionSecondaryId > 0) // || (data.fashionClothesId == 0 && data.fashionSecondaryId > 0)) // { // PutOnExtraSecondary(job, extraSecondaryId); // } // } // var wingsResId = 0; // if (wingsId != 0) // { // var item = ItemConfig.Get(wingsId); // wingsResId = item == null ? 0 : item.ChangeOrd; // } // PutOnWing(wingsResId); // ShowBodyEffect(data); // LoadClothesEffect(); // return clothesModel; // } // public GameObject Show(GameObject clothesModel, int job, int weaponResId, int wingsResId, int secondaryResId, Transform showPoint) // { // this.showPoint = showPoint; // this.job = job; // this.clothesModel = clothesModel; // SwitchMaterial(false); // PutOnWeapon(job, weaponResId); // PutOnSecondary(job, secondaryResId); // PutOnWing(wingsResId); // LoadClothesEffect(); // return clothesModel; // } // public void Dispose() // { // GameObject prefab = null; // GameObjectPoolManager.GameObjectPool pool = null; // HideWeaponEffect(); // HideSecondaryEffect(); // HideSuitEffect(); // HideReikiRootEffect(); // HideTitleRootEffect(); // if (weaponId != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(weaponId); // if (prefab) // { // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(weaponModel); // } // weaponModel = null; // } // if (secondaryId != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(secondaryId); // if (prefab) // { // if (secondaryModel) // { // secondaryModel.SetActive(true); // } // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(secondaryModel); // } // secondaryModel = null; // } // if (extraSecondaryId != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(extraSecondaryId); // if (prefab) // { // if (extraSecondaryModel) // { // extraSecondaryModel.SetActive(true); // } // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(extraSecondaryModel); // } // extraSecondaryModel = null; // } // if (wingsId != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(wingsId); // if (prefab) // { // wingsModel.transform.localScale = Vector3.one; // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(wingsModel); // } // wingsModel = null; // wingsAnimator = null; // } // if (clothesId != 0) // { // if (clothesModel) // { // var smRenderer = clothesModel.GetComponentInChildren(); // if (smRenderer != null) // { // MaterialLoader.Release(smRenderer.material); // smRenderer.material = smRenderer.sharedMaterial = null; // smRenderer.materials = smRenderer.sharedMaterials = new Material[0]; // } // } // prefab = InstanceResourcesLoader.LoadModelRes(clothesId, true); // if (prefab) // { // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(clothesModel); // } // clothesModel = null; // if (clothesAnimator) // { // if (cacheClothedAC) // { // clothesAnimator.runtimeAnimatorController = cacheClothedAC; // cacheClothedAC = null; // } // clothesAnimator.enabled = false; // clothesAnimator = null; // } // } // clothesModel = null; // clothesId = 0; // weaponId = 0; // wingsId = 0; // secondaryId = 0; // extraSecondaryId = 0; // } // public void StandUp() // { // if (clothesModel != null) // { // var animator = clothesModel.GetComponent(); // if (animator) // { // animator.Play(GAStaticDefine.State_IdleHash); // animator.SetInteger(GAStaticDefine.Param_Action, GAStaticDefine.Act_Idle); // } // } // } // public void SitDown() // { // if (clothesModel != null) // { // var animator = clothesModel.GetComponent(); // if (animator) // { // animator.SetInteger(GAStaticDefine.Param_Action, GAStaticDefine.Act_Dazuo); // } // } // if (weaponModel != null) // { // GameObject prefab = InstanceResourcesLoader.LoadModelRes(weaponId, false); // if (prefab) // { // GameObjectPoolManager.Instance.ReleaseGameObject(prefab, weaponModel); // } // weaponModel = null; // } // if (job == 2) // { // if (secondaryModel) // { // secondaryModel.SetActive(false); // } // } // } // private void PutOnClothes(int _job, int clothesResId) // { // var config = JobSetupConfig.Get(_job); // if (clothesId == clothesResId) // { // return; // } // if (clothesId != 0) // { // UnloadClothes(); // } // var _prefab = InstanceResourcesLoader.LoadModelRes(clothesResId, true); // if (!_prefab) // { // clothesResId = config.BaseEquip[0]; // } // LoadClothes(clothesResId); // clothesId = clothesResId; // if (clothesModel) // { // if (weaponModel) // { // var parent = clothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WeaponBindBoneName); // weaponModel.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); // } // if (wingsModel) // { // var parent = clothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WingBindBoneName); // wingsModel.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); // } // if (secondaryModel) // { // var parent = clothesModel.transform.GetChildTransformDeeply(GAStaticDefine.SecondaryBindBoneName[job - 1]); // wingsModel.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); // } // } // } // private void LoadClothes(int resID) // { // var prefab = InstanceResourcesLoader.LoadModelRes(resID, true); // if (prefab) // { // var pool = GameObjectPoolManager.Instance.RequestPool(prefab); // clothesModel = pool.Request(); // LayerUtility.SetLayer(clothesModel, LayerUtility.Player, false); // var skinnedMeshRenderer = clothesModel.GetComponentInChildren(true); // LayerUtility.SetLayer(skinnedMeshRenderer.gameObject, LayerUtility.Player, false); // clothesModel.SetActive(true); // clothesModel.transform.SetParentEx(showPoint, Vector3.zero, Quaternion.identity, Vector3.one); // clothesAnimator = clothesModel.GetComponent(); // // 动画状态机修改 // if (clothesAnimator) // { // cacheClothedAC = clothesAnimator.runtimeAnimatorController; // RuntimeAnimatorController _controller = AnimatorControllerLoader.Load(AnimatorControllerLoader.controllerUISuffix, resID); // clothesAnimator.runtimeAnimatorController = _controller; // clothesAnimator.enabled = true; // } // else // { // Debug.LogErrorFormat("角色资源: {0} 没有动画控制器", resID); // } // } // } // private void UnloadClothes() // { // if (clothesModel == null) // { // return; // } // var smRenderer = clothesModel.GetComponentInChildren(); // if (smRenderer != null) // { // MaterialLoader.Release(smRenderer.material); // smRenderer.material = smRenderer.sharedMaterial = null; // smRenderer.materials = smRenderer.sharedMaterials = new Material[0]; // } // var prefab = InstanceResourcesLoader.LoadModelRes(clothesId, true); // var pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(clothesModel); // clothesModel = null; // if (clothesAnimator != null) // { // if (cacheClothedAC) // { // clothesAnimator.runtimeAnimatorController = cacheClothedAC; // cacheClothedAC = null; // } // clothesAnimator.enabled = false; // clothesAnimator = null; // } // } // private void PutOnWeapon(int _job, int resoureceId) // { // var config = JobSetupConfig.Get(_job); // var oldWeapon = weaponId; // if (oldWeapon == resoureceId) // { // return; // } // GameObject prefab = null; // GameObjectPoolManager.GameObjectPool pool = null; // if (oldWeapon != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(oldWeapon); // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(weaponModel); // weaponModel = null; // } // prefab = InstanceResourcesLoader.LoadModelRes(resoureceId); // if (!prefab) // { // resoureceId = config.BaseEquip[1]; // prefab = InstanceResourcesLoader.LoadModelRes(resoureceId); // } // if (prefab) // { // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // weaponModel = pool.Request(); // LayerUtility.SetLayer(weaponModel, LayerUtility.Player, false); // if (clothesModel) // { // var parent = clothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WeaponBindBoneName); // weaponModel.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); // } // var _resConfig = ModelResConfig.Get(resoureceId); // ShowSecondaryEffect(weaponModel.transform, _resConfig.ResourcesName); // } // weaponId = resoureceId; // } // private void PutOnExtraSecondary(int job, int extraSecondaryId) // { // var oldSecondary = this.extraSecondaryId; // if (oldSecondary == extraSecondaryId) // { // return; // } // GameObject prefab = null; // GameObjectPoolManager.GameObjectPool pool = null; // if (oldSecondary != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(oldSecondary); // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(extraSecondaryModel); // extraSecondaryModel = null; // } // if (extraSecondaryId != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(extraSecondaryId); // if (!prefab) // { // var config = JobSetupConfig.Get(job); // extraSecondaryId = config.BaseEquip[2]; // prefab = InstanceResourcesLoader.LoadModelRes(extraSecondaryId); // } // if (prefab) // { // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // extraSecondaryModel = pool.Request(); // var parent = this.clothesModel.transform.GetChildTransformDeeply(GAStaticDefine.SecondaryBindBoneName[this.job - 1]); // extraSecondaryModel.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); // } // } // this.extraSecondaryId = extraSecondaryId; // } // private void PutOnSecondary(int _job, int secondaryResId) // { // var oldSecondary = secondaryId; // if (oldSecondary == secondaryResId) // { // return; // } // GameObject prefab = null; // GameObjectPoolManager.GameObjectPool pool = null; // if (oldSecondary != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(oldSecondary); // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(secondaryModel); // secondaryModel = null; // } // if (secondaryResId != 0) // { // var _resConfig = ModelResConfig.Get(secondaryResId); // prefab = InstanceResourcesLoader.LoadModelRes(secondaryResId); // if (!prefab) // { // var config = JobSetupConfig.Get(_job); // secondaryResId = config.BaseEquip[2]; // prefab = InstanceResourcesLoader.LoadModelRes(secondaryResId); // } // if (prefab) // { // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // secondaryModel = pool.Request(); // var parent = clothesModel.transform.GetChildTransformDeeply(GAStaticDefine.SecondaryBindBoneName[job - 1]); // secondaryModel.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); // } // ShowSecondaryEffect(secondaryModel.transform, _resConfig.ResourcesName); // } // secondaryId = secondaryResId; // } // private void PutOnWing(int resourceId) // { // var config = JobSetupConfig.Get(job); // var oldWings = wingsId; // if (resourceId == oldWings) // { // return; // } // GameObject prefab = null; // GameObjectPoolManager.GameObjectPool pool = null; // if (oldWings != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(oldWings); // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // pool.Release(wingsModel); // wingsModel = null; // } // if (resourceId != 0) // { // prefab = InstanceResourcesLoader.LoadModelRes(resourceId); // if (!prefab) // { // resourceId = config.BaseEquip[3]; // prefab = InstanceResourcesLoader.LoadModelRes(resourceId); // } // if (prefab) // { // pool = GameObjectPoolManager.Instance.RequestPool(prefab); // wingsModel = pool.Request(); // wingsModel.layer = LayerUtility.Player; // SkinnedMeshRenderer _renderer = wingsModel.GetComponentInChildren(); // if (_renderer) // { // _renderer.gameObject.layer = LayerUtility.Player; // } // var parent = clothesModel.transform.GetChildTransformDeeply(GAStaticDefine.WingBindBoneName); // var modelResConfig = ModelResConfig.Get(resourceId); // wingsModel.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, modelResConfig.UIScale); // wingsAnimator = wingsModel.GetComponent(); // if (wingsAnimator == null) // { // Debug.LogErrorFormat("翅膀资源{0}没有动画控制器", resourceId); // } // wingsAnimator.enabled = true; // wingsAnimator.Play("UI_Idle", 0); // } // } // wingsId = resourceId; // } // private void LoadClothesEffect() // { // SwitchMaterial(isSuit); // HideSuitEffect(); // if (isSuit) // { // var _modelResConfig = ModelResConfig.Get(clothesId); // if (_modelResConfig != null) // { // var _boneList = ModelResConfig.GetBoneList(_modelResConfig.ResourcesName); // var _effectList = ModelResConfig.GetEffectList(_modelResConfig.ResourcesName); // if (_boneList != null) // { // Transform _node = null; // SFXController _sfx = null; // for (int i = 0; i < _boneList.Count; ++i) // { // _node = clothesModel.transform.GetChildTransformDeeply(_boneList[i]); // if (_node) // { // _sfx = SFXPlayUtility.Instance.PlayEffectAsync(_effectList[i], _node); // if (_sfx) // { // m_SuitEffectList.Add(_sfx); // } // } // } // } // } // } // } // private List m_SuitEffectList = new List(); // private List m_WeaponEffectList = new List(); // private List m_SecondaryEffectList = new List(); // private void ShowWeaponEffect(Transform parent, string modelName) // { // HideWeaponEffect(); // var _boneList = ModelResConfig.GetBoneList(modelName); // var _effectlist = ModelResConfig.GetEffectList(modelName); // if (_boneList != null && _effectlist != null) // { // for (int i = 0; i < _boneList.Count; ++i) // { // if (_boneList[i].Equals("null")) // { // var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], parent); // m_WeaponEffectList.Add(_ctrl); // } // else // { // var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], parent.GetChildTransformDeeply(_boneList[i])); // m_WeaponEffectList.Add(_ctrl); // } // } // } // } // private void ShowSecondaryEffect(Transform parent, string modelName) // { // HideWeaponEffect(); // var _boneList = ModelResConfig.GetBoneList(modelName); // var _effectlist = ModelResConfig.GetEffectList(modelName); // if (_boneList != null && _effectlist != null) // { // for (int i = 0; i < _boneList.Count; ++i) // { // if (_boneList[i].Equals("null")) // { // var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], parent); // m_SecondaryEffectList.Add(_ctrl); // } // else // { // var _ctrl = SFXPlayUtility.Instance.PlayBattleEffect(_effectlist[i], parent.GetChildTransformDeeply(_boneList[i])); // m_SecondaryEffectList.Add(_ctrl); // } // } // } // } // private void HideSecondaryEffect() // { // foreach (var _ctrl in m_SecondaryEffectList) // { // SFXPlayUtility.Instance.Release(_ctrl); // } // m_SecondaryEffectList.Clear(); // } // private void HideWeaponEffect() // { // foreach (var _ctrl in m_WeaponEffectList) // { // SFXPlayUtility.Instance.Release(_ctrl); // } // m_WeaponEffectList.Clear(); // } // private void HideSuitEffect() // { // foreach (var _ctrl in m_SuitEffectList) // { // SFXPlayUtility.Instance.Release(_ctrl); // } // m_SuitEffectList.Clear(); // } // void ShowBodyEffect(UI3DPlayerExhibitionData data) // { // ShowReikiRootEffect(data.equipLevel, data.reikiRootEffectId); // int effectID = 0; // ModelCenter.Instance.GetModel().equipAddEffect.TryGetValue(data.titleID, out effectID); // ShowTitleBodyEffect(effectID, data.scale > 0 ? data.scale*0.5f : 0.5f); // } // private void ShowReikiRootEffect(int equipLevel,int id) // { // //改成强化大师特效 id为强化大师等级 // HideReikiRootEffect(); // var config = ItemPlusMasterConfig.TryGetMasterInfo(equipLevel, id); // if (id != 0 && config != null && clothesModel) // { // if (reikiRootShowPoint == null && showPoint.parent != null) // { // reikiRootShowPoint = new GameObject("ReikiRootShowPoint"); // reikiRootShowPoint.transform.SetParentEx(showPoint.parent, showPoint.localPosition, showPoint.rotation, showPoint.localScale); // } // reikiRootEffect = SFXPlayUtility.Instance.Play(config.effect, reikiRootShowPoint == null ? showPoint : reikiRootShowPoint.transform); // if (reikiRootEffect != null) // { // var scale = config.uiScale/100f; // var offsetY = config.offsetY/100f; // reikiRootEffect.transform.localScale = Vector3.one * scale * 0.6f; // reikiRootEffect.transform.localPosition = reikiRootEffect.transform.localPosition.SetY(offsetY); // } // } // } // private void HideReikiRootEffect() // { // if (reikiRootEffect != null) // { // reikiRootEffect.transform.localPosition = Vector3.zero; // reikiRootEffect.transform.localScale = Vector3.zero; // SFXPlayUtility.Instance.Release(reikiRootEffect); // reikiRootEffect = null; // } // } // public void HideTitleRootEffect() // { // if (titleRootEffect != null) // { // titleRootEffect.transform.localPosition = Vector3.zero; // titleRootEffect.transform.localScale = Vector3.zero; // SFXPlayUtility.Instance.Release(titleRootEffect); // titleRootEffect = null; // } // } // //展示称号的全身特效 // public void ShowTitleBodyEffect(int effectID, float scale = 1) // { // HideTitleRootEffect(); // if (effectID == 0) return; // if (clothesModel) // { // if (reikiRootShowPoint == null && showPoint.parent != null) // { // reikiRootShowPoint = new GameObject("ReikiRootShowPoint"); // reikiRootShowPoint.transform.SetParentEx(showPoint.parent, showPoint.localPosition, showPoint.rotation, showPoint.localScale); // } // titleRootEffect = SFXPlayUtility.Instance.Play(effectID, reikiRootShowPoint == null ? showPoint : reikiRootShowPoint.transform); // if (titleRootEffect != null) // { // titleRootEffect.duration = 0; // titleRootEffect.transform.localScale = Vector3.one * scale; // titleRootEffect.transform.localRotation = Quaternion.Euler(0, 40, 0);//后续优化传参 // } // } // } // public void SwitchMaterial(bool isSuit) // { // if (clothesModel == null) // { // return; // } // var smRenderer = clothesModel.GetComponentInChildren(); // if (smRenderer == null) // { // return; // } // MaterialLoader.Release(smRenderer.material); // var newMat = MaterialLoader.LoadClothesMaterial(this.clothesId, true, isSuit); // if (newMat != null) // { // smRenderer.material = newMat; // } // } // } // }