//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Monday, April 02, 2018 //-------------------------------------------------------- using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic; using TableConfig; namespace Snxxz.UI { public class MotnlyInvestmentItem:MonoBehaviour { [SerializeField] Transform m_Group;//奖励品组 [SerializeField] Button m_ReceiveAwardBtn;//领奖按钮 [SerializeField] Image m_IsDrawImage;//是否领取 [SerializeField] Text m_TimeRemaining;//领取时间剩余 [SerializeField] GameObject m_Uieffect;//特效 MonthlyInvestmentModel m_MonthlyInvestmentModel; MonthlyInvestmentModel monthlyInvestmentModel { get { return m_MonthlyInvestmentModel ?? (m_MonthlyInvestmentModel = ModelCenter.Instance.GetModel()); } } public void GetIsDays(int Day) { if (Day < monthlyInvestmentModel.Days) { UsedDay(Day);//过天 } else if (Day == monthlyInvestmentModel.Days) { TheSameDay(Day);//当天 } else if (Day > monthlyInvestmentModel.Days) { NonArrival(Day);//未到 } } private void UsedDay( int Day)//过天 { bool isBool= monthlyInvestmentModel.IsTagGetInfoSeriors(Day); m_TimeRemaining.gameObject.SetActive(false); m_Uieffect.SetActive(false); if (monthlyInvestmentModel.Days != 0) { m_ReceiveAwardBtn.gameObject.SetActive(false); m_IsDrawImage.gameObject.SetActive(true); if (isBool) { // m_IsDrawImage.SetSprite();//已领取 } else { // m_IsDrawImage.SetSprite();//已错过 } } else { m_IsDrawImage.gameObject.SetActive(false); m_ReceiveAwardBtn.gameObject.SetActive(true); m_ReceiveAwardBtn.interactable = false; m_ReceiveAwardBtn.GetComponent().gray = false; } ItemCellAssignment(Day); } private void NonArrival(int Day)//未到 { if (monthlyInvestmentModel.Days != 0) { m_ReceiveAwardBtn.gameObject.SetActive(false); m_IsDrawImage.gameObject.SetActive(false); m_TimeRemaining.gameObject.SetActive(true); int MinimumDays = 0; MinimumDays = Day - monthlyInvestmentModel.Days; if (MinimumDays > 1) { m_TimeRemaining.text = string.Format(Language.Get("Rest_Time"), MinimumDays); } else { m_TimeRemaining.text = Language.Get("Tomorrow_Draw"); } } else { m_ReceiveAwardBtn.gameObject.SetActive(true); m_IsDrawImage.gameObject.SetActive(false); m_ReceiveAwardBtn.interactable = false; m_TimeRemaining.gameObject.SetActive(false); m_Uieffect.SetActive(false); m_ReceiveAwardBtn.GetComponent().gray = false; } ItemCellAssignment(Day); } private void TheSameDay(int Day)//当天 { bool isBool = monthlyInvestmentModel.IsTagGetInfoSeriors(Day); m_TimeRemaining.gameObject.SetActive(false); if (monthlyInvestmentModel.Days != 0) { if (isBool) { m_ReceiveAwardBtn.gameObject.SetActive(false); m_IsDrawImage.gameObject.SetActive(true); // m_IsDrawImage.SetSprite();//已领取 } else { m_IsDrawImage.gameObject.SetActive(false); m_ReceiveAwardBtn.gameObject.SetActive(true); m_ReceiveAwardBtn.interactable = true; m_Uieffect.SetActive(true); m_ReceiveAwardBtn.RemoveAllListeners(); m_ReceiveAwardBtn.AddListener(()=> { monthlyInvestmentModel.SendInvestment(1, Day); }); } } else { m_ReceiveAwardBtn.gameObject.SetActive(true); m_IsDrawImage.gameObject.SetActive(false); m_ReceiveAwardBtn.interactable = false; m_Uieffect.SetActive(false); m_ReceiveAwardBtn.GetComponent().gray = false; } ItemCellAssignment(Day); } private void ItemCellAssignment(int Day) { if (monthlyInvestmentModel.MonthlyInvestmentDic.ContainsKey(Day)) { List monthlyInvestmentItem = monthlyInvestmentModel.MonthlyInvestmentDic[Day].monthlyInvestmentItem.GetAwardItem(1); for (int i = 0; i < m_Group.childCount; i++) { if (i < monthlyInvestmentItem.Count) { m_Group.GetChild(i).gameObject.SetActive(true); AwardItem item = monthlyInvestmentItem[i]; MotnlyItem motnlyItem = m_Group.GetChild(i).GetComponent(); var Item = Config.Instance.Get(item.item.id); ItemCellModel cellModel = new ItemCellModel(item.item.id, true, (ulong)1, item.isBind); motnlyItem.Item_Cell.Init(cellModel); motnlyItem.NameText.text = Item.ItemName; motnlyItem.MoneyNumberText.text = item.item.count.ToString(); motnlyItem.MoneyImage.SetSprite(Item.IconKey); } else { m_Group.GetChild(i).gameObject.SetActive(false); } } } } } }