//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Monday, April 02, 2018 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //月卡投资 namespace Snxxz.UI { public class MonthlyInvestmentWin : Window { MonthlyInvestmentModel m_MonthlyInvestmentModel; MonthlyInvestmentModel monthlyInvestmentModel { get { return m_MonthlyInvestmentModel ?? (m_MonthlyInvestmentModel = ModelCenter.Instance.GetModel()); } } [SerializeField] ScrollerController m_ScrollerController; [SerializeField] Button m_InvestmentButton; [SerializeField] GameObject m_RealizedInvestment; #region Built-in protected override void BindController() { } protected override void AddListeners() { m_InvestmentButton.AddListener(InvestmentButton); } protected override void OnPreOpen() { // if (monthlyInvestmentModel.Days!=0) // { // m_RealizedInvestment.SetActive(true); // m_InvestmentButton.gameObject.SetActive(false); // } // else // { m_RealizedInvestment.SetActive(false); m_InvestmentButton.gameObject.SetActive(true); //} m_ScrollerController.OnRefreshCell += OnRefreshGridCell; monthlyInvestmentModel.MonthlyInvestmentUpdating += MonthlyInvestmentUpdating; OnCreateGridLineCell(m_ScrollerController); m_ScrollerController.JumpIndex(JumpIndex()); } protected override void OnAfterOpen() { } protected override void OnPreClose() { m_ScrollerController.OnRefreshCell -= OnRefreshGridCell; monthlyInvestmentModel.MonthlyInvestmentUpdating -= MonthlyInvestmentUpdating; } private void MonthlyInvestmentUpdating() { m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见 } protected override void OnAfterClose() { } void OnCreateGridLineCell(ScrollerController gridCtrl)//预制体创建 { gridCtrl.Refresh(); foreach (int key in monthlyInvestmentModel.MonthlyInvestmentDic.Keys) { gridCtrl.AddCell(ScrollerDataType.Header, key); } gridCtrl.Restart(); } void OnRefreshGridCell(ScrollerDataType type, CellView cell) { MotnlyInvestmentItem motnlyInvestmentItem = cell.GetComponent(); int day = cell.index; motnlyInvestmentItem.GetIsDays(day); } private void InvestmentButton() { ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"),Language.Get("WhetherRecharge_Z"),(bool isOK) => { if (isOK) { if (UIHelper.GetMoneyCnt(1) >= 0) { monthlyInvestmentModel.InvestmentMonthlyInvestment(1, 300); } else { WindowCenter.Instance.Open(); } } }); } private int JumpIndex() { if (monthlyInvestmentModel.Days != 0) { return monthlyInvestmentModel.Days - 1; } else { return 0; } } #endregion } }