// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2021-04-22 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** namespace G.UI { using System.Collections; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// /// partial class GetPetBox { #region Field [KUIFlag] Button _btnConfirm; [KUIFlag] Image _imgPicture; [KUIFlag] TextMeshProUGUI _tmpName; [KUIFlag] TextMeshProUGUI _tmpDescription; [KUIFlag] KUIList __listSkills; [KUIFlag] PetSpineWidget _skeleton; [KUIFlag] GameObject _god; [KUIFlag] Button _btnGo; #endregion #region Method /// /// /// public void InitView() { SetViewData(); __listSkills.AddTemplate(true); _btnConfirm.onClick.AddListener(this.OnConfirmBtnClick); _btnGo.onClick.AddListener(this.OnGoBtnClick); } /// /// /// public void RefreshView() { if (this.data is PetProxy.PetInfo pet) { _tmpName.text = pet.name; _tmpDescription.text = pet.item.description; if (pet.id ==13020) { _god.SetActive(true); _btnGo.gameObject.SetActive(true); } else { _god.SetActive(false); _btnGo.gameObject.SetActive(false); } var petPic = pet.item.skins[0]; //if (petPic.EndsWith("pic")) // IconProxy.Instance.SetSpriteAsync(_imgPicture, petPic); //else // IconProxy.Instance.SetSprite(_imgPicture, pet.icon); StartCoroutine(SetSkin(petPic)); //__listSkills.Clear(); //var petSkills = pet.skills; //int combatValue = pet.item.combatValue; //for (int i = 0; i < petSkills.Count; i++) //{ // var widget = __listSkills.GetItem(); // if (petSkills[i] != null) // { // widget.SetData(petSkills[i]); // combatValue += petSkills[i].item.combatValue; // } // else // { // widget.SetData(null); // } //} } } IEnumerator SetSkin(string skinAsset) { if (!string.IsNullOrEmpty(skinAsset)) { if (skinAsset.EndsWith("pic")) { _skeleton.gameObject.SetActive(false); var handle = AssetProxy.Instance.TryGetTemporaryAssetAsync(skinAsset); yield return handle; if (handle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded) { _imgPicture.enabled = true; _imgPicture.overrideSprite = handle.Result; } } else { _imgPicture.enabled = false; _skeleton.gameObject.SetActive(true); _skeleton.Show(skinAsset, null); //var handle = AssetProxy.Instance.TryGetGlobalAssetAsync(spriteAsset); //yield return handle; //Object.Instantiate(handle.Result, _imgIcon.transform); } } } private void OnGoBtnClick() { if (FunctionProxy.Instance.GetFunctionUnlock(FunctionProxy.FunctionId.Pet)) { CloseWindow(); CloseWindow(this); OpenWindow("tiger"); } else { ToastBox.ShowText("未达到宠物功能解锁关卡"); } } private void OnConfirmBtnClick() { CloseWindow(this); } #endregion } }