| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 | 
							- using System.Collections.Generic;
 
- using ET;
 
- using FairyGUI;
 
- using UI.League;
 
- namespace GFGGame
 
- {
 
-     //联盟礼包
 
-     public class LeagueGiftView : BaseWindow
 
-     {
 
-         private UI_LeagueGiftUI _ui;
 
-         private List<LeagueGiftGetData> _getDatas;
 
-         private List<LeagueGiftBuyData> _buyDatas;
 
-         public override void Dispose()
 
-         {
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_LeagueGiftUI.PACKAGE_NAME;
 
-             _ui = UI_LeagueGiftUI.Create();
 
-             this.viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             // this.viewCom.Center();
 
-             //   this.viewCom = _ui.target;
 
-             // this.modal = true;
 
-             // viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
 
-             _ui.m_btnBack.onClick.Add(OnBtnBackClick);
 
-             _ui.m_btnGet.onClick.Add(OnBtnGetClick);
 
-             _ui.m_btnGet.data = LeagueWelfareType.ALL;
 
-             _ui.m_btnRule.onClick.Add(RuleController.ShowRuleView);
 
-             _ui.m_btnRule.data = 300003;
 
-             _ui.m_listBuy.itemRenderer = RenderListBuyItem;
 
-             _ui.m_listBuy.itemProvider = GetListBuyItemResource;
 
-             _ui.m_listGet.itemRenderer = RenderListGetItem;
 
-             _ui.m_listGet.itemProvider = GetListGetItemResource;
 
-             _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("lm_beijing2");
 
-         }
 
-         protected override void AddEventListener()
 
-         {
 
-             base.AddEventListener();
 
-             EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
 
-             EventAgent.AddEventListener(ConstMessage.LEAGUE_NUMBERIC_CHANGE, UpdateView);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             UpdateView();
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             if (_ui.m_listBuy.numItems > 0) _ui.m_listBuy.ScrollToView(0);
 
-             if (_ui.m_listGet.numItems > 0) _ui.m_listGet.ScrollToView(0);
 
-             _ui.m_c1.selectedIndex = 0;
 
-         }
 
-         protected override void RemoveEventListener()
 
-         {
 
-             base.RemoveEventListener();
 
-             EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
 
-             EventAgent.RemoveEventListener(ConstMessage.LEAGUE_NUMBERIC_CHANGE, UpdateView);
 
-         }
 
-         private void OnBtnBackClick()
 
-         {
 
-             ViewManager.GoBackFrom(typeof(LeagueGiftView).FullName);
 
-         }
 
-         private void OnBtnCreatClick()
 
-         {
 
-         }
 
-         private void UpdateView()
 
-         {
 
-             UpdateGetList();
 
-             UpdateBuyList();
 
-         }
 
-         private void UpdateGetList()
 
-         {
 
-             _getDatas = LeagueDataManager.Instance.GetGiftGetDatas();
 
-             _ui.m_listGet.numItems = _getDatas.Count;
 
-             _ui.m_grpTips.visible = _getDatas.Count == 0;
 
-         }
 
-         private void UpdateBuyList()
 
-         {
 
-             _buyDatas = LeagueDataManager.Instance.GetGiftBuyDatas();
 
-             _ui.m_listBuy.numItems = _buyDatas.Count;
 
-         }
 
-         private void RenderListGetItem(int index, GObject obj)
 
-         {
 
-             UI_ListGiftGetItemTop item = UI_ListGiftGetItemTop.Proxy(obj);
 
-             if (item.m_comItem.m_listGift.data == null)
 
-             {
 
-                 item.m_comItem.m_listGift.itemRenderer = RenderListRewardItem;
 
-             }
 
-             item.m_comItem.m_c1.selectedIndex = _getDatas[index].IsGet ? 1 : 0;
 
-             item.m_comItem.m_loaType.url = string.Format("ui://League/lm_biaoqian_{0}", _getDatas[index].GiftCfg.type);
 
-             item.m_comItem.m_listGift.data = _getDatas[index].GiftCfg.bonusArr;
 
-             item.m_comItem.m_listGift.numItems = _getDatas[index].GiftCfg.bonusArr.Length;
 
-             if (item.target.data == null)
 
-             {
 
-                 item.target.onClick.Add(OnBtnGetClick);
 
-             }
 
-             item.target.data = _getDatas[index].Type;
 
-             int y = index < 2 ? 98 : 30;
 
-             RedDotController.Instance.SetComRedDot(item.target, !_getDatas[index].IsGet, "", 0, y);
 
-             UI_ListGiftGetItemTop.ProxyEnd();
 
-         }
 
-         private void RenderListBuyItem(int index, GObject obj)
 
-         {
 
-             UI_ListGiftBuyItemTop item = UI_ListGiftBuyItemTop.Proxy(obj);
 
-             LeagueGiftBuyData buyData = _buyDatas[index];
 
-             string strCount = buyData.GiftCfg.limitType == 1 ? "今日剩余:{0}/{1}" : "本周剩余:{0}/{1}";
 
-             item.m_comItem.m_txtCount.text = string.Format(strCount, buyData.GiftCfg.limit - buyData.BuyCount, buyData.GiftCfg.limit);
 
-             long day = TimeUtil.FormattingTime11(TimeHelper.ServerNow(), buyData.EndTime);
 
-             item.m_comItem.m_loaType.url = string.Format("ui://League/lm_biaoqian_{0}", _buyDatas[index].GiftCfg.type);
 
-             item.m_comItem.m_txtTime.visible = buyData.EndTime != 0;
 
-             item.m_comItem.m_txtTime.text = string.Format("剩余{0}天", StringUtil.GetColorText(day.ToString(), "#E45E29"));
 
-             item.m_comItem.m_grpLock.visible = LeagueDataManager.Instance.HallLevel < buyData.GiftCfg.level;
 
-             item.m_comItem.m_txtLock.text = string.Format("宴客厅等级达到{0}级解锁", buyData.GiftCfg.level);
 
-             ItemUtil.UpdateItemNeedNum(item.m_comItem.m_comCost, buyData.GiftCfg.consumeArr[0]);
 
-             if (item.m_comItem.m_listGift.data == null)
 
-             {
 
-                 item.m_comItem.m_listGift.itemRenderer = RenderListRewardItem;
 
-             }
 
-             item.m_comItem.m_listGift.data = _buyDatas[index].GiftCfg.bonusArr;
 
-             item.m_comItem.m_listGift.numItems = _buyDatas[index].GiftCfg.bonusArr.Length;
 
-             if (item.m_comItem.m_btnBuy.data == null)
 
-             {
 
-                 item.m_comItem.m_btnBuy.onClick.Add(OnBtnBuyClick);
 
-             }
 
-             item.m_comItem.m_btnBuy.data = buyData;
 
-             UI_ListGiftBuyItemTop.ProxyEnd();
 
-         }
 
-         private void RenderListRewardItem(int index, GObject obj)
 
-         {
 
-             int[][] reward = (int[][])obj.parent.data;
 
-             ItemData itemData = ItemUtil.createItemData(reward[index]);
 
-             if (obj.data == null)
 
-             {
 
-                 obj.data = new ItemView(obj as GComponent);
 
-             }
 
-             (obj.data as ItemView).SetData(itemData);
 
-             (obj.data as ItemView).ChangeTxtCountStyle();
 
-             // (obj.data as ItemView).SetTxtCountScale = 3f;
 
-             // (obj.data as ItemView).SetTxtCountPos(250, 142);
 
-         }
 
-         private string GetListGetItemResource(int index)
 
-         {
 
-             if (index < _ui.m_listBuy.columnCount)
 
-             {
 
-                 return "ui://League/ListGiftGetItemTop";
 
-             }
 
-             else if (index >= _ui.m_listBuy.numItems - _ui.m_listBuy.columnCount - 1)
 
-             {
 
-                 return "ui://League/ListGiftGetItemBottom";
 
-             }
 
-             else
 
-             {
 
-                 return "ui://League/ListGiftGetItemCenter";
 
-             }
 
-         }
 
-         private string GetListBuyItemResource(int index)
 
-         {
 
-             if (index < _ui.m_listBuy.columnCount)
 
-             {
 
-                 return "ui://League/ListGiftBuyItemTop";
 
-             }
 
-             else if (index >= _ui.m_listBuy.numItems - _ui.m_listBuy.columnCount - 1)
 
-             {
 
-                 return "ui://League/ListGiftBuyItemBottom";
 
-             }
 
-             else
 
-             {
 
-                 return "ui://League/ListGiftBuyItemCenter";
 
-             }
 
-         }
 
-         private void OnBtnBuyClick(EventContext context)
 
-         {
 
-             GObject obj = context.sender as GObject;
 
-             LeagueGiftBuyData buyData = obj.data as LeagueGiftBuyData;
 
-             int myPos = LeagueDataManager.Instance.GetMyPos();
 
-             bool isLeader = myPos == LeaguePos.Owner || myPos == LeaguePos.SubOwner;
 
-             if (!isLeader)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("权限不足");
 
-                 return;
 
-             }
 
-             if (LeagueDataManager.Instance.HallLevel < buyData.GiftCfg.level)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("宴客厅等级不足");
 
-                 return;
 
-             }
 
-             int needNum = buyData.GiftCfg.consumeArr[0][1];
 
-             int hasNum = (int)ItemDataManager.GetItemNum(buyData.GiftCfg.consumeArr[0][0]);
 
-             if (hasNum < needNum)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("消耗不足");
 
-                 return;
 
-             }
 
-             if (buyData.BuyCount == buyData.GiftCfg.limit)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("购买次数不足");
 
-                 return;
 
-             }
 
-             LeagueSproxy.ReqBuyLeagueWelfare(buyData.GiftCfg.type).Coroutine();
 
-         }
 
-         private void OnBtnGetClick(EventContext context)
 
-         {
 
-             GObject obj = context.sender as GObject;
 
-             int type = (int)obj.data;
 
-             LeagueSproxy.ReqGetLeagueWelfare(type).Coroutine();
 
-         }
 
-     }
 
- }
 
 
  |