From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/UI/XPetMainView.cs | 923 +++++++++++++++++++++ 1 file changed, 923 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/XPetMainView.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/XPetMainView.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/XPetMainView.cs b/Client/Assets/Scripts/XMainClient/UI/XPetMainView.cs new file mode 100644 index 00000000..a6c85dcf --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/XPetMainView.cs @@ -0,0 +1,923 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class XPetMainView : DlgBase + { + public XFoodSelectorHandler FoodSelectorHandler + { + get + { + return this.m_FoodSelectorHandler; + } + } + + public XPetSkillHandler SkillHandler + { + get + { + return this.m_SkillHandler; + } + } + + public override string fileName + { + get + { + return "GameSystem/PetMainDlg"; + } + } + + public override int layer + { + get + { + return 1; + } + } + + public override int group + { + get + { + return 1; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + public override bool hideMainMenu + { + get + { + return true; + } + } + + public override bool fullscreenui + { + get + { + return true; + } + } + + public override bool pushstack + { + get + { + return true; + } + } + + private XPetDocument doc; + + private XFoodSelectorHandler m_FoodSelectorHandler; + + private PairsPetSetHandler m_setHandler; + + public XDummy m_Dummy; + + private XPetSkillHandler m_SkillHandler; + + public PetExpTransferHandler ExpTransferHandler; + + public PetSkillLearnHandler SkillLearnHandler; + + public static readonly uint STAR_MAX = 10u; + + public static readonly uint ATTRIBUTE_NUM_MAX = 10u; + + private uint _RefreshDataTimerID = 0u; + + private uint _PlayActionTimerID = 0u; + + private uint _PlayBubbleTimerID = 0u; + + private XPetMainView.PetStatus _PetStatus; + + public XFx _LevelUpFx; + + private XFx _MoodUpFx; + + private XFx _EatUpFx; + + private XFx _GetFx; + + private enum PetStatus + { + IDLE, + IDLE_PEOPLE, + Rand, + EAT, + CARESS + } + + protected override void Init() + { + this.doc = XDocuments.GetSpecificDocument(XPetDocument.uuID); + this.doc.View = this; + DlgHandlerBase.EnsureCreate(ref this.m_FoodSelectorHandler, base.uiBehaviour.m_FeedFrame, null, true); + DlgHandlerBase.EnsureCreate(ref this.m_SkillHandler, base.uiBehaviour.m_SkillFrame, null, true); + DlgHandlerBase.EnsureCreate(ref this.ExpTransferHandler, base.uiBehaviour.m_Bg, false, this); + DlgHandlerBase.EnsureCreate(ref this.SkillLearnHandler, base.uiBehaviour.m_Bg, false, null); + DlgHandlerBase.EnsureCreate(ref this.m_setHandler, base.uiBehaviour.m_Bg, false, null); + } + + protected override void OnShow() + { + base.OnShow(); + base.Alloc3DAvatarPool("XPetMainView"); + this.InitShow(); + this.m_FoodSelectorHandler.ShowBag(false); + this.doc.Select(this.doc.DefaultPet, true); + } + + public override void StackRefresh() + { + base.StackRefresh(); + base.Alloc3DAvatarPool("XPetMainView"); + this.RefreshPetModel(); + this.m_FoodSelectorHandler.ShowBag(false); + } + + private void InitShow() + { + this.doc.ClearPetAnimation(); + XSingleton.singleton.KillTimer(this._RefreshDataTimerID); + XSingleton.singleton.KillTimer(this._PlayActionTimerID); + XSingleton.singleton.KillTimer(this._PlayBubbleTimerID); + } + + public void UnloadFx(XFx fx) + { + bool flag = fx != null; + if (flag) + { + XSingleton.singleton.DestroyFx(fx, true); + fx = null; + } + } + + private void UnloadShow() + { + this.doc.ClearPetAnimation(); + XSingleton.singleton.KillTimer(this._RefreshDataTimerID); + XSingleton.singleton.KillTimer(this._PlayActionTimerID); + XSingleton.singleton.KillTimer(this._PlayBubbleTimerID); + this._RefreshDataTimerID = 0u; + this._PlayActionTimerID = 0u; + this._PlayBubbleTimerID = 0u; + this.UnloadFx(this._LevelUpFx); + this.UnloadFx(this._MoodUpFx); + this.UnloadFx(this._EatUpFx); + this.UnloadFx(this._GetFx); + bool flag = base.uiBehaviour.m_PetSnapshot != null; + if (flag) + { + base.uiBehaviour.m_PetSnapshot.RefreshRenderQueue = null; + } + base.Return3DAvatarPool(); + } + + protected override void OnHide() + { + this.UnloadShow(); + this.doc.HasNewPet = false; + base.OnHide(); + } + + protected override void OnUnload() + { + this.UnloadShow(); + this.doc.View = null; + this.doc = null; + DlgHandlerBase.EnsureUnload(ref this.SkillLearnHandler); + DlgHandlerBase.EnsureUnload(ref this.ExpTransferHandler); + DlgHandlerBase.EnsureUnload(ref this.m_FoodSelectorHandler); + DlgHandlerBase.EnsureUnload(ref this.m_SkillHandler); + DlgHandlerBase.EnsureUnload(ref this.m_setHandler); + base.OnUnload(); + } + + public override void RegisterEvent() + { + base.uiBehaviour.m_Help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClicked)); + base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnCloseBtnClick)); + base.uiBehaviour.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this._OnPetListItemUpdated)); + base.uiBehaviour.m_BtnMount.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnMountClicked)); + base.uiBehaviour.m_BtnSkillLearn.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnSkillLearnClicked)); + base.uiBehaviour.m_Activation.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnActivationClicked)); + base.uiBehaviour.m_Throw.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnThrowClicked)); + base.uiBehaviour.m_ExpTransfer.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnExpTransferClicked)); + base.uiBehaviour.m_TravelSet.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnTravelSetClicked)); + base.uiBehaviour.m_MoodClose.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnMoodCloseClick)); + base.uiBehaviour.m_FullDegreeClose.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnFullDegreeCloseClick)); + base.uiBehaviour.m_FullDegreeSp.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnShowFullDegreeTip)); + base.uiBehaviour.m_MoodIcon.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnShowMoodTip)); + base.uiBehaviour.m_Caress.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnCaressClick)); + base.uiBehaviour.m_GoGetPet.ID = ulong.Parse(XSingleton.singleton.GetValue("PetGoBuyPet")); + base.uiBehaviour.m_GoGetPet.RegisterLabelClickEventHandler(new LabelClickEventHandler(this._OnGoClick)); + base.uiBehaviour.m_GoGetFeed.ID = ulong.Parse(XSingleton.singleton.GetValue("PetGoBuyFeed")); + base.uiBehaviour.m_GoGetFeed.RegisterLabelClickEventHandler(new LabelClickEventHandler(this._OnGoClick)); + base.uiBehaviour.m_PrivilegeBg.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMemberPrivilegeClicked)); + } + + private void OnMemberPrivilegeClicked(IXUISprite btn) + { + DlgBase.singleton.CheckActiveMemberPrivilege(MemberPrivilege.KingdomPrivilege_Adventurer); + } + + public bool OnHelpClicked(IXUIButton button) + { + DlgBase.singleton.ShowHelp(XSysDefine.XSys_Horse); + return true; + } + + private void _OnGoClick(IXUILabel go) + { + XSingleton.singleton.OpenSystem((XSysDefine)go.ID, 0UL); + } + + private bool _OnCloseBtnClick(IXUIButton go) + { + this.SetVisibleWithAnimation(false, null); + return true; + } + + private void _OnShowFullDegreeTip(IXUISprite iSp) + { + bool activeSelf = base.uiBehaviour.m_FullDegreeTip.gameObject.activeSelf; + if (activeSelf) + { + base.uiBehaviour.m_FullDegreeTip.gameObject.SetActive(false); + } + else + { + base.uiBehaviour.m_FullDegreeTip.gameObject.SetActive(true); + base.uiBehaviour.m_MoodTip.gameObject.SetActive(false); + base.uiBehaviour.m_FullDegreeLabel.SetText(XSingleton.singleton.ReplaceReturn(XSingleton.singleton.GetString("PET_FULL_DEGREE_TIP"))); + } + } + + private void _OnShowMoodTip(IXUISprite iSp) + { + bool activeSelf = base.uiBehaviour.m_MoodTip.gameObject.activeSelf; + if (activeSelf) + { + base.uiBehaviour.m_MoodTip.gameObject.SetActive(false); + } + else + { + base.uiBehaviour.m_MoodTip.gameObject.SetActive(true); + base.uiBehaviour.m_FullDegreeTip.gameObject.SetActive(false); + PetMoodTipsTable.RowData petMoodTip = this.doc.GetPetMoodTip(this.doc.CurSelectedPet.Mood); + base.uiBehaviour.m_MoodLabel.SetText(petMoodTip.tips); + XSingleton.singleton.AddLog("Mood:" + this.doc.CurSelectedPet.Mood, null, null, null, null, null, XDebugColor.XDebug_None); + } + } + + private void _OnMoodCloseClick(IXUISprite iSp) + { + base.uiBehaviour.m_MoodTip.gameObject.SetActive(false); + } + + private void _OnFullDegreeCloseClick(IXUISprite iSp) + { + base.uiBehaviour.m_FullDegreeTip.gameObject.SetActive(false); + } + + private void _OnCaressClick(IXUISprite iSp) + { + this.doc.ReqPetTouch(); + } + + public void RefreshPage(bool bResetPosition = true) + { + this.RefreshList(bResetPosition); + this.RefreshContent(); + } + + public void RefreshContent() + { + XPet curSelectedPet = this.doc.CurSelectedPet; + bool flag = curSelectedPet == null; + if (flag) + { + base.uiBehaviour.m_ContentFrame.SetActive(false); + } + else + { + base.uiBehaviour.m_ContentFrame.SetActive(true); + this.RefreshBaseInfo(); + this.RefreshAttribute(); + this.RefreshExp(); + this.RefreshFullDegree(); + this.RefreshMood(); + this.RefreshPrivilege(); + base.uiBehaviour.m_FeedRedPoint.gameObject.SetActive(this.doc.HasRedPoint && curSelectedPet.UID == this.doc.CurFightUID); + } + this.m_SkillHandler.Refresh(curSelectedPet); + } + + public void RefreshPrivilege() + { + base.uiBehaviour.m_ExpPrivilegeSp.gameObject.SetActive(false); + } + + public void RefreshPetModel() + { + bool flag = this.doc.CurSelectedPet == null; + if (!flag) + { + XSingleton.singleton.KillTimer(this._PlayActionTimerID); + this.m_Dummy = XSingleton.singleton.CreateCommonEntityDummy(this.m_dummPool, XPetDocument.GetPresentID(this.doc.CurSelectedPet.ID), this.m_uiBehaviour.m_PetSnapshot, this.m_Dummy, 1f); + this.PetActionChange(XPetActionFile.IDLE, this.doc.CurSelectedPet.ID, this.m_Dummy, true); + } + } + + public void PlayPetLevelUpFx(Transform t, bool follow = false) + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + Vector3 scale; + scale= new Vector3(t.localScale.x / 300f, t.localScale.y / 300f, t.localScale.z / 300f); + bool flag2 = this._LevelUpFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._LevelUpFx, true); + } + this._LevelUpFx = XSingleton.singleton.CreateAndPlay("Effects/FX_Particle/Roles/Lzg_Ty/P_level_up_02", t, Vector3.zero, scale, 1f, follow, 5f, true); + } + } + + public void PlayPetMoodUpFx() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + bool flag2 = this._MoodUpFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._MoodUpFx, true); + } + this._MoodUpFx = XSingleton.singleton.CreateAndPlay("Effects/FX_Particle/VehicleFX/Vehicle_weiyang", base.uiBehaviour.m_Fx, Vector3.zero, Vector3.one, 1f, false, 5f, true); + } + } + + public void PlayPetEatUpFx() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + bool flag2 = this._EatUpFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._EatUpFx, true); + } + this._EatUpFx = XSingleton.singleton.CreateAndPlay("Effects/FX_Particle/VehicleFX/Vehicle_weiyang_Clip01", base.uiBehaviour.m_Fx, Vector3.zero, Vector3.one, 1f, false, 5f, true); + } + } + + public void PlayPetGetFx() + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + bool flag2 = this._GetFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._GetFx, true); + } + this._GetFx = XSingleton.singleton.CreateAndPlay("Effects/FX_Particle/UIfx/UI_yh", base.uiBehaviour.m_Fx, Vector3.zero, Vector3.one, 1f, true, 5f, true); + XSingleton.singleton.PlayUISound("Audio/UI/UI_Gethorse", true, AudioChannel.Action); + } + } + + public void SetPetSex(IXUISprite sp, PetSex sex) + { + bool flag = sex == PetSex.Girl; + if (flag) + { + sp.SetSprite("zq_Gender0"); + } + else + { + bool flag2 = sex == PetSex.Boy; + if (flag2) + { + sp.SetSprite("zq_Gender1"); + } + else + { + XSingleton.singleton.AddErrorLog("Pet Sex is Null", null, null, null, null, null); + } + } + sp.MakePixelPerfect(); + } + + public void RefreshBaseInfo() + { + XPet curSelectedPet = this.doc.CurSelectedPet; + bool flag = curSelectedPet == null; + if (!flag) + { + this.SetPetSex(base.uiBehaviour.m_Sex, curSelectedPet.Sex); + base.uiBehaviour.m_Name.SetText(curSelectedPet.Name); + base.uiBehaviour.m_PPT.SetText(curSelectedPet.PPT.ToString()); + base.uiBehaviour.m_Level.SetText(string.Format("Lv.{0}", curSelectedPet.showLevel.ToString())); + base.uiBehaviour.m_ActivationSelected.SetActive(this.doc.CurFightUID == curSelectedPet.UID); + string text = (this.doc.CurFightUID == curSelectedPet.UID) ? XSingleton.singleton.GetString("ACTIVATED") : XSingleton.singleton.GetString("ACTIVATION"); + base.uiBehaviour.m_ActivationLabel.SetText(text); + text = ((this.doc.CurMount == curSelectedPet.UID) ? XSingleton.singleton.GetString("PET_DOWN") : XSingleton.singleton.GetString("PET_RIDE")); + base.uiBehaviour.m_BtnMountLabel.SetText(text); + } + } + + private void RefreshAttribute() + { + XPet curSelectedPet = this.doc.CurSelectedPet; + bool flag = curSelectedPet == null; + if (!flag) + { + PetInfoTable.RowData petInfo = XPetDocument.GetPetInfo(curSelectedPet.ID); + BuffTable.RowData buffData = XSingleton.singleton.GetBuffData((int)petInfo.SpeedBuff, 1); + bool flag2 = buffData == null; + if (flag2) + { + XSingleton.singleton.AddErrorLog("Buff No Find!\nSp BuffId:" + petInfo.SpeedBuff, null, null, null, null, null); + } + bool flag3 = 1201 != (int)buffData.BuffChangeAttribute[0, 0]; + if (flag3) + { + XSingleton.singleton.AddErrorLog("Buff No Find XAttr_RUN_SPEED_Percent.\nSp BuffId:" + petInfo.SpeedBuff, null, null, null, null, null); + } + base.uiBehaviour.m_SpeedUp.SetText(string.Format("{0}%", (buffData.BuffChangeAttribute[0, 1] + 100f).ToString())); + PetLevelTable.RowData petLevel = XPetDocument.GetPetLevel(curSelectedPet); + PetLevelTable.RowData petLevel2 = XPetDocument.GetPetLevel(curSelectedPet.ID, curSelectedPet.Level + 1); + base.uiBehaviour.m_AttributePool.ReturnAll(false); + int num = 0; + while ((long)num < (long)((ulong)XPetMainView.ATTRIBUTE_NUM_MAX)) + { + bool flag4 = num >= petLevel.PetsAttributes.Count; + if (!flag4) + { + GameObject gameObject = base.uiBehaviour.m_AttributePool.FetchGameObject(false); + int spriteHeight = (gameObject.transform.GetComponent("XUISprite") as IXUISprite).spriteHeight; + IXUILabel ixuilabel = gameObject.transform.Find("AttributeName").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel2 = gameObject.transform.Find("AttributeName/AttributeVal").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel3 = gameObject.transform.Find("AttributeName/GrowUp").GetComponent("XUILabel") as IXUILabel; + gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)spriteHeight * num), 0f); + string attrStr = XAttributeCommon.GetAttrStr((int)petLevel.PetsAttributes[num, 0]); + ixuilabel.SetText(attrStr); + uint num2 = 0u; + for (int i = 1; i <= curSelectedPet.Level; i++) + { + PetLevelTable.RowData petLevel3 = XPetDocument.GetPetLevel(curSelectedPet.ID, i); + num2 += petLevel3.PetsAttributes[num, 1]; + } + ixuilabel2.SetText(XAttributeCommon.GetAttrValueStr(petLevel.PetsAttributes[num, 0], num2, false)); + bool flag5 = petLevel2 != null; + if (flag5) + { + ixuilabel3.SetText(string.Format("+{0}", petLevel2.PetsAttributes[num, 1].ToString())); + } + else + { + ixuilabel3.SetText(""); + } + } + num++; + } + } + } + + public void RefreshExp() + { + XPet curSelectedPet = this.doc.CurSelectedPet; + bool flag = curSelectedPet == null; + if (!flag) + { + bool flag2 = this.doc.IsMaxLevel(curSelectedPet.ID, curSelectedPet.showLevel); + if (flag2) + { + base.uiBehaviour.m_Exp.SetText(XSingleton.singleton.GetString("PET_LEVEL_MAX_TIP")); + base.uiBehaviour.m_ExpBar.value = 0f; + base.uiBehaviour.m_ExpBarLevel.SetText(string.Format("Lv.{0}", curSelectedPet.showLevel.ToString())); + this.doc.InPlayExpUp = false; + } + else + { + int num; + int num2; + this.doc.GetExpInfo(curSelectedPet, out num, out num2); + base.uiBehaviour.m_Exp.SetText(string.Format("{0}/{1}", num, num2)); + base.uiBehaviour.m_ExpBar.value = Math.Min((float)num / (float)num2, 1f); + base.uiBehaviour.m_ExpBarLevel.SetText(string.Format("Lv.{0}", curSelectedPet.showLevel.ToString())); + } + } + } + + public void RefreshFullDegree() + { + XPet curSelectedPet = this.doc.CurSelectedPet; + bool flag = curSelectedPet == null; + if (!flag) + { + PetInfoTable.RowData petInfo = XPetDocument.GetPetInfo(curSelectedPet.ID); + uint maxHungry = petInfo.maxHungry; + bool flag2 = maxHungry == 0u; + if (flag2) + { + XSingleton.singleton.AddErrorLog("FullDegreeMAX = 0", null, null, null, null, null); + } + else + { + base.uiBehaviour.m_FullDegree.SetText(string.Format("{0}%", curSelectedPet.showFullDegree)); + base.uiBehaviour.m_FullDegreeBar.value = curSelectedPet.showFullDegree / maxHungry; + bool flag3 = (ulong)curSelectedPet.showFullDegree >= (ulong)((long)int.Parse(this.doc.ColorLevel[0])); + Color color; + if (flag3) + { + color= new Color(0.6784314f, 0.8392157f, 0.09019608f); + } + else + { + bool flag4 = (ulong)curSelectedPet.showFullDegree >= (ulong)((long)int.Parse(this.doc.ColorLevel[1])); + if (flag4) + { + color= new Color(1f, 0.470588237f, 0.121568628f); + } + else + { + color= new Color(0.894117653f, 0.266666681f, 0.266666681f); + } + } + base.uiBehaviour.m_FullDegreeColor.SetColor(color); + } + } + } + + public void RefreshMood() + { + XPet curSelectedPet = this.doc.CurSelectedPet; + bool flag = curSelectedPet == null; + if (!flag) + { + PetMoodTipsTable.RowData petMoodTip = this.doc.GetPetMoodTip(curSelectedPet.Mood); + bool flag2 = petMoodTip != null; + if (flag2) + { + base.uiBehaviour.m_MoodLevel.SetText(petMoodTip.tip); + base.uiBehaviour.m_MoodIcon.SetSprite(petMoodTip.icon); + } + } + } + + public void RefreshList(bool bResetPosition = true) + { + int num = Math.Min(this.doc.PetCountMax, (int)(this.doc.PetSeat + 1u)); + base.uiBehaviour.m_WrapContent.SetContentCount(num, false); + if (bResetPosition) + { + base.uiBehaviour.m_PetListScrollView.ResetPosition(); + } + else + { + base.uiBehaviour.m_WrapContent.RefreshAllVisibleContents(); + } + } + + public void SetTravelSetBtnStatus() + { + bool flag = this.doc.CurSelectedPet != null; + if (flag) + { + PetInfoTable.RowData petInfo = XPetDocument.GetPetInfo(this.doc.CurSelectedPet.ID); + base.uiBehaviour.m_TravelSet.gameObject.SetActive(petInfo != null && petInfo.PetType == 1u); + } + } + + private void _OnPetListItemUpdated(Transform t, int index) + { + bool flag = index < 0; + if (flag) + { + XSingleton.singleton.AddErrorLog("index:" + index, null, null, null, null, null); + } + else + { + List pets = this.doc.Pets; + IXUILabel ixuilabel = t.Find("Level").GetComponent("XUILabel") as IXUILabel; + IXUISprite ixuisprite = t.Find("Item/PetIcon").GetComponent("XUISprite") as IXUISprite; + IXUISprite ixuisprite2 = t.Find("Item/Quality").GetComponent("XUISprite") as IXUISprite; + GameObject gameObject = t.Find("Mount").gameObject; + GameObject gameObject2 = t.Find("Fight").gameObject; + IXUISprite ixuisprite3 = t.Find("Unlock").GetComponent("XUISprite") as IXUISprite; + GameObject gameObject3 = t.Find("New").gameObject; + GameObject gameObject4 = t.Find("Selected").gameObject; + GameObject gameObject5 = t.Find("Item").gameObject; + GameObject gameObject6 = t.Find("RedPoint").gameObject; + gameObject3.SetActive(false); + gameObject6.SetActive(false); + bool flag2 = index >= pets.Count; + if (flag2) + { + ixuilabel.SetText(""); + gameObject5.SetActive(false); + gameObject.SetActive(false); + gameObject2.SetActive(false); + gameObject4.SetActive(false); + bool flag3 = (long)index >= (long)((ulong)this.doc.PetSeat); + if (flag3) + { + ixuisprite3.gameObject.SetActive(true); + ixuisprite3.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnUnlockClicked)); + } + else + { + ixuisprite3.gameObject.SetActive(false); + } + } + else + { + bool flag4 = this.doc.HasNewPet && index == pets.Count - 1; + if (flag4) + { + gameObject3.SetActive(true); + } + XPet xpet = pets[index]; + gameObject5.SetActive(true); + ixuilabel.SetText("Lv." + xpet.showLevel); + gameObject4.SetActive(index == this.doc.CurSelectedIndex); + gameObject.SetActive(xpet.UID == this.doc.CurMount); + gameObject2.SetActive(xpet.UID == this.doc.CurFightUID); + ixuisprite3.gameObject.SetActive(false); + gameObject6.SetActive(xpet.UID == this.doc.CurFightUID && this.doc.HasRedPoint); + PetInfoTable.RowData petInfo = XPetDocument.GetPetInfo(xpet.ID); + bool flag5 = petInfo != null; + if (flag5) + { + ixuisprite.SetSprite(petInfo.icon, petInfo.Atlas, false); + } + ixuisprite2.SetSprite(XSingleton.singleton.GetItemQualityFrame((int)petInfo.quality, 0)); + ixuisprite.ID = (ulong)((long)index); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnPetClicked)); + } + } + } + + private void _OnUnlockClicked(IXUISprite iSp) + { + bool flag = (ulong)this.doc.PetSeat < (ulong)((long)this.doc.PetSeatBuy.Length); + if (flag) + { + XSingleton.singleton.ShowModalDialog(string.Format(XStringDefineProxy.GetString("PET_SEAT_BUY"), this.doc.PetSeatBuy[(int)this.doc.PetSeat]), XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this._BuySeat)); + } + else + { + XSingleton.singleton.AddErrorLog(string.Concat(new object[] + { + "PetSeat:", + this.doc.PetSeat, + "\nPetSeatMAX", + this.doc.PetSeatBuy.Length + }), null, null, null, null, null); + } + } + + private bool _BuySeat(IXUIButton btn) + { + this.doc.ReqBuySeat(); + XSingleton.singleton.CloseModalDlg(); + return true; + } + + private void _OnPetClicked(IXUISprite iSp) + { + int index = (int)iSp.ID; + this.doc.Select(index, false); + } + + private bool _OnMountClicked(IXUIButton btn) + { + this.doc.ReqMount(); + return true; + } + + private bool _OnSkillLearnClicked(IXUIButton btn) + { + this.SkillLearnHandler.SetVisible(true); + return true; + } + + private bool _OnActivationClicked(IXUIButton btn) + { + this.doc.ReqFight(); + return true; + } + + public override void LeaveStackTop() + { + base.LeaveStackTop(); + base.Return3DAvatarPool(); + } + + private bool _OnThrowClicked(IXUIButton btn) + { + XSingleton.singleton.ShowModalDialog(string.Format(XSingleton.singleton.ReplaceReturn(XSingleton.singleton.GetString("PET_THROW")), this.doc.CurSelectedPet.Name), XStringDefineProxy.GetString("COMMON_OK"), XStringDefineProxy.GetString("COMMON_CANCEL"), new ButtonClickEventHandler(this._PetThrow)); + return true; + } + + private bool _OnExpTransferClicked(IXUIButton btn) + { + bool flag = this.doc.Pets.Count < 2; + bool result; + if (flag) + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("PET_TRANSFER_NOT_ENOUGH_TIP"), "fece00"); + result = false; + } + else + { + bool flag2 = this.doc.CurSelectedPet == null; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("PET_NO_SELECT"), "fece00"); + result = false; + } + else + { + this.ExpTransferHandler.SetVisible(true); + result = true; + } + } + return result; + } + + private bool _OnTravelSetClicked(IXUIButton btn) + { + bool flag = this.m_setHandler != null; + if (flag) + { + this.m_setHandler.SetVisible(true); + } + return true; + } + + private bool _PetThrow(IXUIButton btn) + { + this.doc.ReqRelease(); + XSingleton.singleton.CloseModalDlg(); + return true; + } + + private void AutoRefresh(object param) + { + bool flag = base.IsVisible() && this.doc.CurSelectedPet != null; + if (flag) + { + bool flag2 = !this.doc.InPlayExpUp; + if (flag2) + { + this.doc.ReqPetInfo(); + } + this._RefreshDataTimerID = XSingleton.singleton.SetTimer(30f, new XTimerMgr.ElapsedEventHandler(this.AutoRefresh), null); + this.doc.PlayRandAction(); + } + } + + public void RefreshAutoRefresh() + { + XSingleton.singleton.KillTimer(this._RefreshDataTimerID); + bool flag = base.IsVisible() && this.doc.CurSelectedPet != null; + if (flag) + { + bool flag2 = !this.doc.InPlayExpUp; + if (flag2) + { + this.doc.ReqPetInfo(); + } + this._RefreshDataTimerID = XSingleton.singleton.SetTimer(10f, new XTimerMgr.ElapsedEventHandler(this.AutoRefresh), null); + } + } + + private void RefreshAction(object param) + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + base.uiBehaviour.m_Talk.gameObject.SetActive(false); + this.doc.PlayIdleAction(); + } + } + + private void CloseBubble(object param) + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + base.uiBehaviour.m_Talk.gameObject.SetActive(false); + } + } + + public void PetActionChange(XPetActionFile Action, uint petID, XDummy m_Dummy, bool init = false) + { + bool flag = m_Dummy == null; + if (!flag) + { + XPetDocument specificDocument = XDocuments.GetSpecificDocument(XPetDocument.uuID); + PetBubble.RowData petBubble = specificDocument.GetPetBubble(Action, petID); + string sefile = petBubble.SEFile; + bool flag2 = !string.IsNullOrEmpty(sefile); + if (flag2) + { + XSingleton.singleton.PlayUISound(sefile, true, AudioChannel.Action); + } + string actionFile = petBubble.ActionFile; + float length = m_Dummy.SetAnimationGetLength(actionFile); + XSingleton.singleton.AddLog("Pet Action:" + Action, null, null, null, null, null, XDebugColor.XDebug_None); + bool flag3 = Action == XPetActionFile.IDLE; + if (flag3) + { + this._PetStatus = XPetMainView.PetStatus.IDLE; + this.PlayActionTime(length); + } + bool flag4 = Action == XPetActionFile.IDLE_PEOPLE; + if (flag4) + { + this._PetStatus = XPetMainView.PetStatus.IDLE_PEOPLE; + this.PlayActionTime(length); + } + bool flag5 = Action == XPetActionFile.EAT; + if (flag5) + { + bool flag6 = this._PetStatus != XPetMainView.PetStatus.EAT; + if (flag6) + { + this._PetStatus = XPetMainView.PetStatus.EAT; + this.PlayActionTime(length); + this.PlayBubble(petBubble); + } + } + bool flag7 = Action == XPetActionFile.CARESS; + if (flag7) + { + bool flag8 = this._PetStatus != XPetMainView.PetStatus.CARESS; + if (flag8) + { + this._PetStatus = XPetMainView.PetStatus.CARESS; + this.PlayActionTime(length); + this.PlayBubble(petBubble); + } + } + bool flag9 = Action == XPetActionFile.LOSE || Action == XPetActionFile.HAPPY || Action == XPetActionFile.SLEEP || Action == XPetActionFile.HUNGER; + if (flag9) + { + bool flag10 = this._PetStatus == XPetMainView.PetStatus.IDLE; + if (flag10) + { + this._PetStatus = XPetMainView.PetStatus.Rand; + this.PlayActionTime(length); + this.PlayBubble(petBubble); + } + } + } + } + + private void PlayActionTime(float length) + { + XSingleton.singleton.KillTimer(this._PlayActionTimerID); + bool flag = length > 0f; + if (flag) + { + this._PlayActionTimerID = XSingleton.singleton.SetTimer(length, new XTimerMgr.ElapsedEventHandler(this.RefreshAction), null); + } + } + + private void PlayBubble(PetBubble.RowData petBubbleData) + { + string text = this.doc.RandomPlayBubble(petBubbleData.Bubble); + bool flag = !string.IsNullOrEmpty(text); + if (flag) + { + base.uiBehaviour.m_Talk.gameObject.SetActive(true); + base.uiBehaviour.m_TalkLabel.SetText(text); + XSingleton.singleton.KillTimer(this._PlayBubbleTimerID); + this._PlayBubbleTimerID = XSingleton.singleton.SetTimer(petBubbleData.BubbleTime, new XTimerMgr.ElapsedEventHandler(this.CloseBubble), null); + } + } + } +} -- cgit v1.1-26-g67d0