using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using Games.GlobeDefine; using GCGame.Table; using GCGame; using System; public class MarketingPacketPageRoot : MarketingUIBaseCS { public static MarketingPacketPageRoot Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } public UIContainerBase _SubTagContainer; public UIContainerSelect _SubTagMenuContainer; public Image _ActIcon; public List _DescList; //页面描述 public UICameraTexture _CameraTexture; private int _SelectedTagId = -1; void OnEnable() { InitWin(); } public void InitWin() { ReqActList(); } public void ReqActList() { MarketingActAwardPageReq packet = new MarketingActAwardPageReq(); packet.actID = _ActID; packet.updateOrInit = 1; packet.SendMsg(); } private List _SubTags; public List SubTags { get { return _SubTags; } } protected override void MarketingActPageAwardRetDelInner(object tags) { MarketingActPacketPageRet _Tags = (MarketingActPacketPageRet)tags; for (int index = 0; index < _DescList.Count; index++) { _DescList[index].gameObject.SetActive(index < _Tags.pageDescList.Count); } for(int index = 0; index < _DescList.Count && index < _Tags.pageDescList.Count; index++) { _DescList[index].text = StrDictionary.GetServerDictionaryFormatString(_Tags.pageDescList[index]); } _SubTags = new List(); _SubTags.AddRange(_Tags.subTags); Tab_ActInfoClient actInfoClient = TableManager.GetActInfoClientByID(_Tags.actId, 0); if (actInfoClient != null) { LoadAssetBundle.Instance.SetImageSprite(_ActIcon, actInfoClient.Icon); } if (_Tags.subTags.Count > 0 && _SubTagMenuContainer != null) { if(!_SubTagMenuContainer.gameObject.activeInHierarchy) { _SubTagMenuContainer.gameObject.SetActive(true); } int needShowIndex = 0; for(int index = 0; index < _Tags.subTags.Count; index++) { if (_Tags.subTags[index].tagId == _SelectedTagId) { needShowIndex = index; break; } } _SubTagMenuContainer.InitSelectContent(_Tags.subTags, new List { _Tags.subTags[needShowIndex] }, OnMenuSelect); _SubTagMenuContainer.ForeachActiveItem((menuItem) => { for(int index = 0; index < _Tags.subTags.Count; index++) { if(menuItem._TagId == _Tags.subTags[index].tagId) { menuItem.ShowRedIcon(_Tags.subTags[index].state); break; } } }); } } public void OnMenuSelect(object actObj) { MarketingActPacketSubTag info = actObj as MarketingActPacketSubTag; _SelectedTagId = info.tagId; InitSubTagPage(_SelectedTagId); } public virtual void InitSubTagPage(int tagId) { for(int index = 0; index < SubTags.Count; index++) { if(SubTags[index].tagId == tagId) { _SubTagContainer.InitContentItem(SubTags[index].awardTags); //当前页面是否需要显示模型 ShowCharModel(SubTags[index].modleID); } } } public void ShowCharModel(int charModelId) { if(_CameraTexture != null && charModelId != -1) { Tab_CharModel charModel = TableManager.GetCharModelByID(charModelId, 0); if(charModel != null) { _CameraTexture.gameObject.SetActive(true); _CameraTexture.InitModelPath(charModel.ResPath, charModel); }else { _CameraTexture.gameObject.SetActive(false); } } } public void GetAwardRet(MarketingActAwardPageGetAwardRet packet) { //菜单状态设置为已领取 _SubTagMenuContainer.ForeachActiveItem((menuItem) => { if (menuItem._TagId == packet.tagID) { menuItem.ShowRedIcon(packet.btnState); } }); //奖励状态 _SubTagContainer.ForeachActiveItem((tagItem) => { if (tagItem._SubTagId == packet.subTagId) { tagItem.RefreshTagState(packet.btnState); } }); } public void OnRechargeBtnClick() { YuanBaoShopLogic.OpenChargePage(); } }