using FairyGUI; using UnityEngine; using UI.Main; using System.Collections; using System.Collections.Generic; namespace GFGGame { public class StroyFightResultView : BaseView { private UI_StoryFightResultUI _ui; private GameObject _sceneObject; private GameObject _scenePrefab; private List _currentBonusList; private bool _fistPassLastLvl; private bool _curLvfirstPass = 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(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(); 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 = "" + RoleDataManager.lvl; RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl); _ui.m_expBar.m_pbExp.max = roleLevelCfg.exp; _ui.m_expBar.m_pbExp.value = RoleDataManager.exp; bool 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; 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; string txt = "不要气馁呀,可以通过再次挑战已通关的关卡、摘星、绣坊等途径获取更多的物资来提升自己的战斗力哦!"; int targetY = (int)_ui.m_expBar.target.y - 250; GuideController.TryGuideByGuideId(null, ConstGuideId.CHAPTER_RESULT_VIEW, 5, false, txt, targetY); } 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(); GuideController.TryCompleteGuide(ConstGuideId.CHAPTER_RESULT_VIEW); GuideController.TryCompleteGuide(ConstGuideId.FIGHT_RESULT_TIPS_GUIDE); Timers.inst.Remove(AddExp); if (_sceneObject != null) { GameObject.Destroy(_sceneObject); _sceneObject = null; } _currentBonusList = null; } private void OnClickBtnClose() { List 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 = "" + RoleDataManager.lvl; if (RoleDataManager.exp <= _ui.m_expBar.m_pbExp.value) { _ui.m_expBar.m_pbExp.value = 0; } _ui.m_expBar.m_pbExp.TweenValue(RoleDataManager.exp, 0.2f); _ui.m_btnClose.enabled = true; int targetY = (int)_ui.m_expBar.target.y - 250; int count = GuideDataManager.GetGuideCount(ConstGuideId.CHAPTER_RESULT_VIEW); string txt = null; if (_curLvfirstPass && StoryDataManager._passChapter + 1 == 1 && StoryDataManager._passLevel == 2) { txt = "这条连衣裙可真好看!点击空白区域继续"; } else if (_curLvfirstPass && StoryDataManager._passChapter + 1 == 1 && StoryDataManager._passLevel == 6) { txt = "你太厉害了,初次对战就获得了这么好的战绩,继续加油吧"; } GuideController.TryGuideByGuideId(null, ConstGuideId.FIGHT_RESULT_TIPS_GUIDE, 2, false, txt, targetY); } } }