using System; using System.Collections.Generic; using ET; using FairyGUI; using UI.DailyWelfare; using UnityEngine; namespace GFGGame { public class DailySignView : BaseWindow { private UI_DailySignUI _ui; private GameObject _gameObject0; private GameObject _gameObject1; private GameObject _gameObject2; private GameObject _gameObject3; private GameObject _gameObject4; private GameObject _gameObject5; private GoWrapper _wrapper0; private GoWrapper _wrapper1; private GoWrapper _wrapper2; private GoWrapper _wrapper3; private GoWrapper _wrapper4; private GoWrapper _wrapper5; private GGraph m_holderSign; private float _signCount; private int _month; private int _day; public override void Dispose() { base.Dispose(); SceneController.DestroyObjectFromView(_gameObject0, _wrapper0); SceneController.DestroyObjectFromView(_gameObject1, _wrapper1); SceneController.DestroyObjectFromView(_gameObject2, _wrapper2); SceneController.DestroyObjectFromView(_gameObject3, _wrapper3); SceneController.DestroyObjectFromView(_gameObject4, _wrapper4); SceneController.DestroyObjectFromView(_gameObject5, _wrapper5); if (_ui != null) { _ui.Dispose(); _ui = null; } } protected override void OnInit() { base.OnInit(); packageName = UI_DailySignUI.PACKAGE_NAME; _ui = UI_DailySignUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; _ui.m_btnClose.onClick.Add(Hide); _ui.m_list.itemRenderer = ListItemRender; string resPath = ResPathUtil.GetViewEffectPath("ui_league", "Answer_bgtx"); SceneController.AddObjectToView(null, null, _ui.m_holderFlower, resPath, out _gameObject0, out _wrapper0); string resPath1 = ResPathUtil.GetViewEffectPath("ui_Activity", "Everyday_2lizi"); SceneController.AddObjectToView(null, null, _ui.m_holderLizi, resPath1, out _gameObject1, out _wrapper1); string resPath2 = ResPathUtil.GetViewEffectPath("ui_Activity", "Everydayy_people"); SceneController.AddObjectToView(null, null, _ui.m_holderRole, resPath2, out _gameObject2, out _wrapper2); string resPath4 = ResPathUtil.GetViewEffectPath("ui_fight_new", "Progress_head"); SceneController.AddObjectToView(null, null, _ui.m_proSign.m_holder, resPath4, out _gameObject4, out _wrapper4, 90); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateSignView); } protected override void OnShown() { base.OnShown(); _ui.m_t0.Play(() => { if (m_holderSign != null) { m_holderSign.visible = true; } }); _month = TimeUtil.GetCurMonth(); _day = TimeUtil.GetCurDay(); _ui.m_txtMonth.text = NumberUtil.GetOldChiniseNumberText(_month); UpdateSignView(); } protected override void OnHide() { base.OnHide(); _ui.m_t0.Stop(); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateSignView); } private void UpdateSignView() { _signCount = MathHelper.CountOnes(GameGlobal.myNumericComponent.GetAsInt(NumericType.SignDay)); _ui.m_proSign.m_txtSignCount.text = _signCount.ToString(); List signBonusCfgs = DailySignBonusCfgArray.Instance.GetCfgsBymonth(_month); _ui.m_proSign.target.max = signBonusCfgs.Count; _ui.m_proSign.target.value = _signCount; _ui.m_proSign.m_holder.x = _signCount / signBonusCfgs.Count * _ui.m_proSign.target.width - 68; List signCfgs = DailySignCfgArray.Instance.GetCfgsBymonth(_month); _ui.m_proSign.m_holderReward.visible = false; for (int i = 0; i < signCfgs.Count; i++) { GComponent comProBonus = _ui.m_proSign.target.GetChild("comProBonus" + i).asCom; comProBonus.x = ((float)signCfgs[i].day / (float)signBonusCfgs.Count) * _ui.m_proSign.target.width; UI_ComProBonus item = UI_ComProBonus.Proxy(comProBonus); item.m_loaIcon.url = ResPathUtil.GetIconPath(ItemCfgArray.Instance.GetCfg(signCfgs[i].bonusArr[0][0])); item.m_txtCount.text = signCfgs[i].bonusArr[0][1].ToString(); item.m_txtDay.text = signCfgs[i].day.ToString(); if (item.target.data == null) { item.target.onClick.Add(OnBtnGetProBonus); } item.target.data = signCfgs[i]; bool isGot = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.SignReward), signCfgs[i].day); item.m_imgGot.visible = isGot; bool canGet = _signCount >= signCfgs[i].day && !isGot; if (canGet) { if (_gameObject5 == null) { string resPath5 = ResPathUtil.GetViewEffectPath("ui_Activity", "Everyday_enable"); SceneController.AddObjectToView(null, null, _ui.m_proSign.m_holderReward, resPath5, out _gameObject5, out _wrapper5); } _ui.m_proSign.m_holderReward.visible = canGet; _ui.m_proSign.m_holderReward.position = new Vector2(item.target.x, 35); } RedDotController.Instance.SetComRedDot(item.target, canGet); UI_ComProBonus.ProxyEnd(); } _ui.m_list.numItems = signBonusCfgs.Count > 29 ? signBonusCfgs.Count + 1 : signBonusCfgs.Count; } private async void OnBtnGetProBonus(EventContext context) { GObject obj = context.sender as GObject; DailySignCfg signCfg = obj.data as DailySignCfg; if (_signCount < signCfg.day || MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.SignReward), signCfg.day)) { GoodsItemTipsController.ShowItemTips(signCfg.bonusArr[0][0]); } else { bool result = await DailyWelfareSProxy.ReqGetSignReward(signCfg.day); if (result) { UpdateSignView(); } } } private void ListItemRender(int index, GObject obj) { UI_ListSignItem item = UI_ListSignItem.Proxy(obj); if (index == 29) { item.target.touchable = false; item.target.visible = false; return; } int _index = index >= 29 ? index - 1 : index; DailySignBonusCfg bonusCfg = DailySignBonusCfgArray.Instance.GetCfgsBymonth(_month)[_index]; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(bonusCfg.bonusArr[0][0]); bool isGot = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.SignDay), bonusCfg.day); if (bonusCfg.day == _day && !isGot && _gameObject3 == null) { string resPath3 = ResPathUtil.GetViewEffectPath("ui_Activity", "everyday_kuang"); SceneController.AddObjectToView(null, null, item.m_holderSign, resPath3, out _gameObject3, out _wrapper3); m_holderSign = item.m_holderSign; } item.m_holderSign.visible = false; item.m_c1.selectedIndex = itemCfg.itemType == ConstItemType.DRESS_UP ? 0 : bonusCfg.type; item.m_txtDay.text = NumberUtil.GetChiniseNumberText(bonusCfg.day);// bonusCfg.day.ToString(); if (item.m_comItem.data == null) { item.m_comItem.data = new ItemView(item.m_comItem); } ItemData itemData = ItemUtil.createItemData(bonusCfg.bonusArr[0]); (item.m_comItem.data as ItemView).SetData(itemData); (item.m_comItem.data as ItemView).ShowTips = false; (item.m_comItem.data as ItemView).ChangeTxtCountStyle(); item.m_imgMask.visible = isGot || bonusCfg.day < _day && !isGot; item.m_imgGot.visible = isGot; item.m_imgNotGet.visible = bonusCfg.day < _day && !isGot; RedDotController.Instance.SetComRedDot(item.target, bonusCfg.day == _day && !isGot); if (item.target.data == null) { item.target.onClick.Add(OnGetSignBonus); } item.target.data = bonusCfg.day; UI_ListSignItem.ProxyEnd(); } private async void OnGetSignBonus(EventContext context) { GObject obj = context.sender as GObject; int day = (int)obj.data; bool result = false; if (day > _day) return; bool isGot = MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.SignDay), day); if (isGot) { PromptController.Instance.ShowFloatTextPrompt("已领取"); return; } if (day < _day) { int[] cost = GlobalCfgArray.globalCfg.dailySignConsumeArr[0]; AlertUI.Show(string.Format("是否确定花费{0}{1}补签?", cost[1], ItemCfgArray.Instance.GetCfg(cost[0]).name)). SetLeftButton(true, "否"). SetRightButton(true, "是", async (object param) => { if (ItemDataManager.GetItemNum(cost[0]) < cost[1]) { PromptController.Instance.ShowFloatTextPrompt("消耗不足"); return; } result = await DailyWelfareSProxy.ReqReSign(day); }); } else { result = await DailyWelfareSProxy.ReqSign(day); } if (result) { _ui.m_list.numItems = DailySignBonusCfgArray.Instance.GetCfgsBymonth(_month).Count; } } } }