using System; using UnityEngine; using TableConfig; using UnityEngine.UI; using System.Collections.Generic; using System.Collections; namespace Snxxz.UI { public class VipInvestWin : Window { [SerializeField] ScrollerController ctrl; [SerializeField] Button investBtn; [SerializeField] GameObject m_Realized_BGM; [SerializeField] Text m_RemainingDays;//剩余天数 //--------------------------------- [SerializeField] Transform m_ButtonGroup;//按钮组 [SerializeField] Button m_Button_one; [SerializeField] Button m_Button_Two; [SerializeField] Button m_Button_Three; [SerializeField] Button m_Button_Four; [SerializeField] Button m_GoToVipBoss; VipInvestModel _investModel; VipInvestModel investModel { get { return _investModel ?? (_investModel = ModelCenter.Instance.GetModel()); } } ItemTipsModel _tipsModel; ItemTipsModel tipsModel { get { return _tipsModel ?? (_tipsModel = ModelCenter.Instance.GetModel()); } } private List configlist; int cycle = 0; string investIndex = ""; ServerInvestInfo InvestInfo; public static event Action VipInvestRedPointEvent; protected override void BindController() { ctrl.OnRefreshCell += RefreshRewardCell; ctrl.lockType = EnhanceLockType.KeepVertical; investBtn.AddListener(ClickInvestBtn); } protected override void AddListeners() { m_Button_one.AddListener(OnclickButtonOne); m_Button_Two.AddListener(OnClickButtonTwo); m_Button_Three.AddListener(OnClickButtonThree); m_Button_Four.AddListener(OnClickButtonFour); m_GoToVipBoss.AddListener(OnClickVipBossWin); } protected override void OnPreOpen() { InvestInfo = investModel.GetInvestInfoByType((int)InvestType.Vip); cycle = investModel.GetInvestCycle(InvestInfo.curDay); investIndex = investModel.GetVipInvestIndex(); if (InvestInfo.curDay <= 0) { m_RemainingDays.text = string.Format(Language.Get("TheRemainingNumberDays_Z"), UIHelper.GetTextColorByItemColor(TextColType.Green, 0.ToString(), true)); } else { m_RemainingDays.text = string.Format(Language.Get("TheRemainingNumberDays_Z"), UIHelper.GetTextColorByItemColor(TextColType.Green, (28 - InvestInfo.curDay).ToString(), true)); } if (InvestInfo.investGold <= 0) { m_Realized_BGM.SetActive(false); investBtn.gameObject.SetActive(true); cycle = 1; } else { m_Realized_BGM.SetActive(true); investBtn.gameObject.SetActive(false); } SwithWeek(cycle); //configlist = investModel.GetInvestConfiglistByCycle(cycle); //CreateRewardCell(); investModel.RefreshInvestAct += RefreshInvestState; } protected override void OnAfterOpen() { if (investModel.redPointStre1.state==RedPointState.Simple) { investModel.IsRedpoint = false; if (VipInvestRedPointEvent != null) { VipInvestRedPointEvent(); } } } protected override void OnPreClose() { investModel.RefreshInvestAct -= RefreshInvestState; } protected override void OnAfterClose() { } private void RefreshInvestState(int obj) { if (obj == 2) { CreateRewardCell(); InvestInfo = investModel.GetInvestInfoByType((int)InvestType.Vip); if (InvestInfo.investGold <= 0) { m_Realized_BGM.SetActive(false); investBtn.gameObject.SetActive(true); cycle = 1; } else { m_Realized_BGM.SetActive(true); investBtn.gameObject.SetActive(false); } if (InvestInfo.curDay <= 0) { m_RemainingDays.text = string.Format(Language.Get("TheRemainingNumberDays_Z"), UIHelper.GetTextColorByItemColor(TextColType.Green, 0.ToString(), true)); } else { m_RemainingDays.text = string.Format(Language.Get("TheRemainingNumberDays_Z"), UIHelper.GetTextColorByItemColor(TextColType.Green, (28 - InvestInfo.curDay).ToString(), true)); } } } private void CreateRewardCell() { if (ctrl.GetNumberOfCells(ctrl.m_Scorller) > 0) { ctrl.m_Scorller.RefreshActiveCellViews(); } else { ctrl.Refresh(); if (configlist != null) { for (int i = 0; i < configlist.Count; i++) { ctrl.AddCell(ScrollerDataType.Header, i); } } ctrl.Restart(); } int a_Week= investModel.GetInvestCycle(InvestInfo.curDay); if (a_Week == cycle) { ctrl.JumpIndex(investModel.JumpIndex); } else { ctrl.JumpIndex(0); } } private void RefreshRewardCell(ScrollerDataType type, CellView cell) { Text titleText = cell.transform.Find("Title").GetComponent(); Button button = cell.transform.Find("ReceiveBtn").GetComponent