using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using System; namespace vnxbqy.UI { public class ModelShowPerfab : MonoBehaviour { [SerializeField] public Text titleText; [SerializeField] public RawImage modelImg; [SerializeField] public Text fightPowerText; [SerializeField] public Image fightImg; [SerializeField] Button m_ViewSkill; int displayId = 0; ModelShowType showType; FashionDressModel fashionDressModel { get { return ModelCenter.Instance.GetModel(); } } ItemTipsModel tipsModel { get { return ModelCenter.Instance.GetModel(); } } private void Awake() { if (m_ViewSkill != null) { m_ViewSkill.onClick.AddListener(OnViewSkill); } } public void OnDisable() { switch (showType) { case ModelShowType.Treasure: UI3DTreasureExhibition.Instance.Stop(); break; case ModelShowType.Mount: break; case ModelShowType.Pet: break; } } public void SetModelShow(int id, ModelShowType showType, string title, int fightValue = 0) { titleText.text = title; this.showType = showType; if (m_ViewSkill != null) { m_ViewSkill.SetActive(false); } switch (showType) { case ModelShowType.Treasure: displayId = id; if (m_ViewSkill != null) { m_ViewSkill.SetActive(id == 304); } fightImg.SetSprite("FightingLv_Normal"); UI3DTreasureExhibition.Instance.ShowTreasure(id, modelImg); break; case ModelShowType.Mount: fightImg.SetSprite("FightingLv_Max"); UI3DModelExhibition.Instance.ShowHourse(id, modelImg); break; case ModelShowType.Pet: fightImg.SetSprite("FightingLv_Max"); var npcConfig = NPCConfig.Get(id); UI3DModelExhibition.Instance.ShowNPC(id, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, modelImg); break; case ModelShowType.FashionDress: fightImg.SetSprite("FightingLv_Normal"); var itemConfig = ItemConfig.Get(id); if(itemConfig != null) { int fashionType = 0; int fashionId = 0; bool isFashion = tipsModel.TryGetItemFashionData(itemConfig.ID, out fashionType, out fashionId); if(isFashion) { List fashionIds = null; fashionDressModel.TryGetFashionIds(fashionType, out fashionIds); if(fashionIds != null && fashionIds.Count > 0) { UI3DModelExhibition.Instance.ShowPlayer(modelImg, SetFashionDressData(fashionIds)); } } } break; } if (fightValue == 0) { fightImg.SetActive(false); fightPowerText.SetActive(false); } else { fightImg.SetActive(true); fightPowerText.SetActive(true); fightPowerText.text = UIHelper.ReplaceLargeNum(fightValue); fightImg.SetNativeSize(); } } public UI3DPlayerExhibitionData SetFashionDressData(List fashionIds) { var job = PlayerDatas.Instance.baseData.Job; var fashionClothesId = 0; var fashionWeaponId = 0; var fashionSecondaryId = 0; foreach(var fashionId in fashionIds) { FashionDress fashionDress = null; bool isFashion = fashionDressModel.TryGetFashionDress(fashionId, out fashionDress); if (isFashion) { int itemId = fashionDress.requireLevelUpItem; var itemConfig = ItemConfig.Get(itemId); switch (fashionDress.fashionDressType) { case 1: fashionClothesId = fashionDress.GetEquipItemId(); break; case 2: fashionWeaponId = fashionDress.GetEquipItemId(); break; case 3: fashionSecondaryId = fashionDress.GetEquipItemId(); break; } } } var data = new UI3DPlayerExhibitionData() { job = job, fashionClothesId = fashionClothesId, fashionWeaponId = fashionWeaponId, fashionSecondaryId = fashionSecondaryId, isDialogue = false, }; return data; } private void OnViewSkill() { WindowCenter.Instance.uiRoot.uicamera.SetActive(false); CameraController.Instance.CameraObject.SetActive(false); UI3DHeroSkillShow.Instance.ShowTreasureSkill(displayId, () => { WindowCenter.Instance.uiRoot.uicamera.SetActive(true); CameraController.Instance.CameraObject.SetActive(true); }); } } public enum ModelShowType { Treasure, //法宝 Mount, //坐骑 Pet, //灵宠 FashionDress, //时装 //后续IL开发添加预设 default1, default2, default3, default4, default5, } }