123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- using System.Threading.Tasks;
- using ET;
- using FairyGUI;
- //using UI.Arena;
- using UnityEngine;
- using UI.FieldWork;
- namespace GFGGame
- {
- public class FieldWorkRoundResultView : BaseWindow
- {
- private UI_FieldWorkRoundResultUI _ui;
- private FieldWorkDataManager _dataManager;
- private int winCount = 0;
- private bool isFinallyFight = false;//是否最后一场战斗
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_FieldWorkRoundResultUI.PACKAGE_NAME;
- _ui = UI_FieldWorkRoundResultUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- _ui.m_list.itemRenderer = RenderListItem;
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected async override void OnShown()
- {
- base.OnShown();
- ViewManager.SetMaskAlpha(0);
- winCount = 0;
- _dataManager = FieldWorkDataManager.Instance;
- //_ui.m_list.numItems = _dataManager.CurFightIndex;
- _ui.m_list.numItems = FieldWorkDataManager.Instance.myScore.Count;
- isFinallyFight = _ui.m_list.numItems == 3;
- _ui.m_ComResult.target.visible = isFinallyFight;
- _ui.m_loaResule.visible = isFinallyFight;
- this.clickBlankToClose = isFinallyFight;
- if (isFinallyFight)
- {
- long myAllScore = 0;
- long targetAllScore = FieldWorkDataManager.Instance.targetWinScore;
- for (int i = 0; i < FieldWorkDataManager.Instance.myScore.Count; i++)
- {
- myAllScore += FieldWorkDataManager.Instance.myScore[i];
- }
- bool isWin = myAllScore > targetAllScore;
- _ui.m_loaResule.url = isWin ? "ui://FieldWork/kstzjj_slsl" : "ui://FieldWork/kstzjj_shib";
- _ui.m_ComResult.m_comResult.m_txtMyFightScore.text = myAllScore.ToString();
- _ui.m_ComResult.m_comResult.m_txtTargetFightScore.text = targetAllScore.ToString();
- bool result = await FieldWorkSproxy.ReqFieldWorkFight(FieldWorkDataManager.Instance.currentLevelID);
- if (result)
- {
- if (FieldWorkDataManager.Instance.CimbingTowerLevelInfoList.ContainsKey(FieldWorkDataManager.Instance.currentLevelID))
- {
- if (FieldWorkDataManager.Instance.CimbingTowerLevelInfoList[FieldWorkDataManager.Instance.currentLevelID].IsPass)
- {
- await FieldWorkSproxy.ReqChangeFieldWorkDressup();
- }
- }
- else
- {
- }
- }
- else
- {
- //PromptController.Instance.ShowFloatTextPrompt("未通过!");
- }
- }
- else
- {
- Timers.inst.Add(1, 1, StartNextRound);
- }
- Timers.inst.AddUpdate(CheckGuide);
- }
- protected override void OnHide()
- {
- base.OnHide();
- ViewManager.SetMaskAlpha(0.6f);
- if (isFinallyFight)
- {
- MusicManager.Instance.PlayCroutine(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
- FinishFight();
- }
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void RenderListItem(int index, GObject obj)
- {
- UI_ListResultItem item = UI_ListResultItem.Proxy(obj);
- item.m_txtRound.text = "回合 " + (index + 1).ToString();
- RoleInfoManager.Instance.UpdateHead(item.m_comMyHead, RoleDataManager.headId, RoleDataManager.headBorderId);
- int myCardId = FieldWorkDataManager.Instance.DressupList[index].cardId;
- ItemCfg cardCfg = ItemCfgArray.Instance.GetCfg(myCardId);
- item.m_loaMyCard.m_comCardmask.m_loaCard.url = cardCfg == null ? "" : ResPathUtil.GetCardIconPath(cardCfg.res);
- int scoreType = FieldWorkDataManager.Instance.ThemeList[index];
- item.m_loaScore.url = ResPathUtil.GetScorePath(scoreType);
- long myScore = FieldWorkDataManager.Instance.myScore[index];
- item.m_txtMyScore.text = myScore.ToString();
- UI_ListResultItem.ProxyEnd();
- }
- private void StartNextRound(object param)
- {
- ViewManager.Hide<FieldWorkFightResultView>();
- ViewManager.Show<StoryFightSingleScoreView>(_dataManager.DressupList[_dataManager.CurFightIndex]);
- ViewManager.Show<FieldWorkRoundTipsView>();
- this.Hide();
- }
- private void FinishFight()
- {
- FieldWorkDataManager dataManager = FieldWorkDataManager.Instance;
- ViewManager.Hide<FieldWorkFightResultView>();
- if(dataManager.BonusList != null || dataManager.BonusList.Count >0)
- {
- BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(dataManager.BonusList), () =>
- {
- // ViewManager.Hide<ArenaFightResultView>();
- });
- dataManager.BonusList.Clear();
- }
- }
- private void CheckGuide(object param)
- {
- if (GuideDataManager.IsGuideFinish(ConstGuideId.FIELD) <= 0 && isFinallyFight)
- {
- UpdateCheckGuide(null);
- }
- else
- {
- Timers.inst.Remove(CheckGuide);
- }
- }
- protected void UpdateCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- GuideController.TryGuide(_ui.m_guide.target, ConstGuideId.FIELD, 15, "三轮累计的分数将决定关卡的通关与否!");
- }
- }
- }
|