123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- using FairyGUI;
- using UnityEngine;
- using UI.Main;
- using System.Collections;
- using System.Collections.Generic;
- using ET;
- namespace GFGGame
- {
- public class StroyFightResultView : BaseView
- {
- private UI_StoryFightResultUI _ui;
- private GameObject _sceneObject;
- private GameObject _scenePrefab;
- private List<ItemData> _currentBonusList;
- private bool _fistPassLastLvl;
- private bool _curLvfirstPass = false;
- private bool resule = false;
- public override void Dispose()
- {
- if (_scenePrefab != null)
- {
- GameObject.Destroy(_scenePrefab);
- _scenePrefab = null;
- }
- if (_ui != null)
- {
- _ui.Dispose();
- }
- _ui = null;
- base.Dispose();
- }
- protected override void Init()
- {
- base.Init();
- _ui = UI_StoryFightResultUI.Create();
- viewCom = _ui.target;
- isfullScreen = true;
- _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFightResult"));
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui.m_btnClose.enabled = false;
- _ui.m_btnClose.onClick.Add(OnClickBtnClose);
- }
- protected override void OnShown()
- {
- base.OnShown();
- // Timers.inst.AddUpdate(UpdateToCheckGuide);
- if (_sceneObject == null)
- {
- _sceneObject = GameObject.Instantiate(_scenePrefab);
- }
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(StoryDataManager.currentLevelID);
- StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- bool hasFightTarget = fightCfg.targetName != null && fightCfg.targetName.Length > 0;
- int score = EquipDataCache.cacher.totalScore;
- SceneController.UpdateRole(EquipDataCache.cacher.equipDatas, _sceneObject);
- _ui.m_selfScore.m_txtScore.text = "" + score;
- _ui.m_expBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
- RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
- _ui.m_expBar.m_pbExp.max = roleLevelCfg.exp;
- _ui.m_expBar.m_pbExp.value = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
- resule = GetFightResult();
- int starCount = !resule ? 0 : StoryDataManager.GetResultStarCount(score);
- StoryUtil.UpdateStar(starCount, _ui.m_selfScore.m_flower.target);
- _ui.m_selfScore.m_bg.url = "ui://Main/zd_jsjm_jszi_" + starCount;
- TextFormat tf = _ui.m_selfScore.m_txtScore.textFormat;
- UpdateToCheckGuide(null);
- if (!resule)
- {
- tf.font = "ui://Main/Font3";
- _ui.m_expBar.m_txtLvlAdded.text = "0";
- _ui.m_expBar.target.visible = false;
- _ui.m_btnClose.enabled = true;
- int targetY = (int)_ui.m_expBar.target.y - 250;
- }
- else
- {
- tf.font = "ui://Main/Font2";
- _ui.m_expBar.target.visible = true;
- _ui.m_btnClose.enabled = false;
- //过关
- _ui.m_expBar.m_txtLvlAdded.text = "" + fightCfg.exp;
- _currentBonusList = StoryDataManager.PassCurrentLevel(out _fistPassLastLvl, out _curLvfirstPass);
- if (_curLvfirstPass)
- {
- FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(StoryDataManager._passChapter + 1, StoryDataManager._passLevel);//首次通过要检查是否有功能开启
- }
- }
- Timers.inst.Add(0.5f, 1, AddExp);
- _ui.m_selfScore.m_txtScore.textFormat = tf;
- }
- private bool GetFightResult()
- {
- bool equipedNeeded = EquipDataCache.cacher.CheckEquipedFightNeeded();
- if (!equipedNeeded)
- {
- PromptController.Instance.ShowFloatTextPrompt("未穿必需物品");
- return false;//没穿必需品
- }
- int starCount = StoryDataManager.GetResultStarCount(EquipDataCache.cacher.totalScore);
- StoryDataManager.SetScore(EquipDataCache.cacher.totalScore, starCount);
- if (starCount <= 0)
- {
- return false;//低于一星
- }
- StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(StoryDataManager.currentLevelID);
- StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- bool hasFightTarget = fightCfg.targetName != null && fightCfg.targetName.Length > 0;
- if (hasFightTarget && EquipDataCache.cacher.totalScore < EquipDataCache.cacher.npcTotalScore)
- {
- return false;//分数低于对战对象
- }
- return true;
- }
- protected override void OnHide()
- {
- base.OnHide();
- Timers.inst.Remove(AddExp);
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- _currentBonusList = null;
- }
- private void OnClickBtnClose()
- {
- List<ItemData> bonusList = _currentBonusList;
- this.Hide();
- if (_fistPassLastLvl)
- {
- ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW);
- }
- else
- {
- ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, ViewManager.GetGoBackDatas(ViewName.STORY_CHAPTER_VIEW));
- }
- if (bonusList != null && bonusList.Count > 0)
- {
- ViewManager.Show(ViewName.GET_BONUS_VIEW, bonusList);
- }
- StoryDataManager.currentCardId = -1;
- }
- private void AddExp(object param)
- {
- _ui.m_expBar.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
- int exp = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
- if (exp <= _ui.m_expBar.m_pbExp.value)
- {
- _ui.m_expBar.m_pbExp.value = 0;
- }
- _ui.m_expBar.m_pbExp.TweenValue(exp, 0.2f);
- _ui.m_btnClose.enabled = true;
- int targetY = (int)_ui.m_expBar.target.y - 250;
- }
- protected override void UpdateToCheckGuide(object param)
- {
- if (!ViewManager.CheckIsTopView(this.viewCom)) return;
- if (!resule) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_FAILED, 1, "不要气馁呀,可以通过再次挑战已通关的关卡、摘星、绣坊等途径获取更多的物资来提升自己的战斗力哦!", false, 0, true, false, (int)(this.viewCom.height - 150));
- if (resule) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_SINGLE_WIN, 1, "这条连衣裙可真好看!点击空白区域继续", false, 0, true, false, (int)(this.viewCom.height - 150));
- if (resule) GuideController.TryGuide(null, ConstGuideId.FIRST_FIGHT_TARGET_WIN, 1, "你太厉害了,初次对战就获得了这么好的战绩,继续加油吧", false, 0, true, false, (int)(this.viewCom.height - 350));
- }
- protected override void TryCompleteGuide()
- {
- GuideCfg cfg;
- cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_FAILED);
- GuideController.TryCompleteGuideIndex(cfg.id, 1);
- GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_FAILED, 1);
- cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_SINGLE_WIN);
- GuideController.TryCompleteGuideIndex(cfg.id, 1);
- GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_SINGLE_WIN, 1);
- cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.FIRST_FIGHT_TARGET_WIN);
- GuideController.TryCompleteGuideIndex(cfg.id, 1);
- GuideController.TryCompleteGuide(ConstGuideId.FIRST_FIGHT_TARGET_WIN, 1);
- }
- }
- }
|