using GCGame.Table; using System.Collections; using UnityEngine; using UnityEngine.UI; // 开服活动菜单 // 需要额外控制 “红点” 和 “已结束”、“进行中” 标签 public class OpenServiceWinMenuItemCS : UIItemSelect { public Text _MenuText; public Text _HLMenuText; public Image actStateTips; public Sprite runingSprite; public Sprite endSprite; public GameObject _RedDot; public Text remainTimeText; public GameObject _NonInvestment; // 用于投资活动,标记 “未投资” 状态 public int _ActId; public override void Show(Hashtable hash) { base.Show(hash); MarketingActState actState = (MarketingActState)hash["InitObj"]; ShowActState(actState); } private void ShowActState(MarketingActState actState) { _ActId = actState.actID; var actInfo = TableManager.GetActInfoClientByID(actState.actID, 0); if (_MenuText != null && actInfo != null) { _MenuText.text = actInfo.Name.Replace("#r", "\n"); if (_HLMenuText != null) { _HLMenuText.text = _MenuText.text; } } else if (actInfo == null) { Debug.LogError("找不到活动配置 活动id:" + actState.actID); } if (_RedDot != null) { _RedDot.SetActive(actState.state > 0); } if (remainTimeText) remainTimeText.text = (actState.state >= 99 ? 99 : actState.state).ToString(); // 用于投资活动, 0.未购买 1.已购买 if (_NonInvestment != null) { _NonInvestment.SetActive(actState.ispurchase == 0); } RefreshActRunTips(actState.isRunning); } public void RefreshActState(int state) { if (_RedDot != null) { _RedDot.SetActive(state > 0); } if (remainTimeText) remainTimeText.text = (state >= 99 ? 99 : state).ToString(); if (state > 0 == true && _NonInvestment != null) { _NonInvestment.SetActive(false); } } public void RefreshActRunTips(int state) { if (actStateTips != null) { switch (state) { case 0: actStateTips.gameObject.SetActive(false); break; case 1: actStateTips.overrideSprite = runingSprite; actStateTips.gameObject.SetActive(true); break; case 2: actStateTips.overrideSprite = endSprite; actStateTips.gameObject.SetActive(true); break; } } } }