123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using FairyGUI;
- using UI.Field;
- using UnityEngine;
- namespace GFGGame
- {
- public class FieldFightInfoView : BaseWindow
- {
- private UI_FieldFightInfoUI _ui;
- // private StoryLevelCfg _storyLevelCfg;
- // private StoryFightCfg _storyFightCfg;
- private int _time = 3;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui = UI_FieldFightInfoUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- this.clickBlankToClose = false;
- _ui.m_btnStop.onClick.Add(OnBtnStopClick);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _time = 3;
- UpdateView();
- }
- private void UpdateView()
- {
- FieldDataManager dataManager = FieldDataManager.Instance;
- FieldCfg fieldCfg = FieldCfgArray.Instance.GetCfg(dataManager.chapterId);
- StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(fieldCfg.type, 0, fieldCfg.id)[dataManager.currFightLv];
- StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(storyLevelCfg.fightID);
- dataManager.currFightLv++;
- FieldFightDataManager.Instance.currentLevelCfgId = storyLevelCfg.id;
- _ui.m_txtName.text = storyFightCfg.targetName;
- _ui.m_txtDesc.text = storyLevelCfg.desc;
- string num = StringUtil.GetColorText(string.Format("{0}/{1}", dataManager.currFightLv, fieldCfg.num), "#BB674E");
- _ui.m_txtNum.text = string.Format("第{0}轮", num);
- _ui.m_loaNpc.url = ResPathUtil.GetNpcHeadPath(storyFightCfg.targetRes);
- _ui.m_txtTime.text = string.Format("{0}秒后自动进入下一轮", _time);
- Timers.inst.Add(1, _time, OnTimerUpdate, 1);
- }
- private void OnTimerUpdate(object param)
- {
- _time -= (int)param;
- if (_time == 0)
- {
- Timers.inst.Remove(OnTimerUpdate);
- InstanceZonesDataManager.currentCardId = FieldFightDataManager.Instance.CurrentCardId;
- InstanceZonesDataManager.currentScoreType = FieldFightDataManager.Instance.CurrentScoreType;
- InstanceZonesDataManager.currentLevelCfgId = FieldFightDataManager.Instance.currentLevelCfgId;
- ViewManager.Show<StoryFightTargetView>(null,true);
- this.Hide();
- }
- _ui.m_txtTime.text = string.Format("{0}秒后自动进入下一轮", _time);
- }
- private void OnBtnStopClick()
- {
- Timers.inst.Remove(OnTimerUpdate);
- AlertUI.Show("确认中止本轮挑战?")
- .SetLeftButton(true, "取消", (object data) =>
- {
- Timers.inst.Add(1, _time, OnTimerUpdate, 1);
- })
- .SetRightButton(true, "中止", async (object data) =>
- {
- this.Hide();
- bool result = await FieldSProxy.ReqFieldInstanceResult();
- if (result)
- {
- FieldDataManager.Instance.accumulateReward = 0;
- ViewManager.Show<FieldFightEndView>();
- }
- });
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- }
- }
|