//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, June 11, 2019 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class ForeverCardWin : Window { [SerializeField] Button m_Invest; [SerializeField] Text m_Price; [SerializeField] Text m_Process; [SerializeField] Button m_Get; [SerializeField] Image m_State; [SerializeField] Button m_Close; [SerializeField] List itemCellList; VipModel vipModel { get { return ModelCenter.Instance.GetModel(); } } #region Built-in protected override void BindController() { } protected override void AddListeners() { m_Invest.AddListener(OnInvest); m_Close.AddListener(CloseClick); m_Get.AddListener(() => { var ids = InvestModel.Instance.GetIdsByType(InvestModel.foreverCardType); InvestModel.Instance.SendGetReward(InvestModel.foreverCardType, ids[0]); }); } protected override void OnPreOpen() { InvestModel.Instance.onInvestUpdate += Display; } protected override void OnActived() { Display(); } protected override void OnAfterOpen() { } protected override void OnPreClose() { InvestModel.Instance.onInvestUpdate -= Display; } protected override void OnAfterClose() { } #endregion void Display() { var ids = InvestModel.Instance.GetIdsByType(InvestModel.foreverCardType); var state = InvestModel.Instance.GetSingleInvestState(InvestModel.foreverCardType, ids[0]); m_Invest.SetActive(state == 0); m_Get.SetActive(state == 2); m_State.SetActive(state == 3); int needMoney = InvestModel.Instance.rechargeSumDict[InvestModel.foreverCardType] / 10000; m_Price.text = Language.Get("ForeverCard6", needMoney); m_Process.text = Language.Get("ForeverCard7", UIHelper.GetMoneyFormat( vipModel.realRecharge / 10000.0), needMoney); for (int i = 0; i < itemCellList.Count; i++) { List awards = new List(); InvestModel.Instance.TryGetItems(12, 1200, out awards); if (i < awards.Count) { itemCellList[i].SetActiveIL(true); var itemId = awards[i].id; var model = new ItemCellModel(itemId, false, (ulong)awards[i].count); itemCellList[i].Init(model); itemCellList[i].auctionIcon.SetActiveIL(awards[i].bind != 0); itemCellList[i].button.SetListener(() => { ItemTipUtility.Show(itemId); }); } else { itemCellList[i].SetActiveIL(false); } } } private void OnInvest() { if (vipModel.realRecharge < InvestModel.Instance.rechargeSumDict[InvestModel.foreverCardType]) { WindowJumpMgr.Instance.WindowJumpToEx("VipRechargeWin"); return; } CA540_tagCMGoldInvest investGold = new CA540_tagCMGoldInvest(); investGold.InvestType = 12; GameNetSystem.Instance.SendInfo(investGold); } } }