| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | |
| | | //经验区 |
| | | [SerializeField] Text playerLevelText; |
| | | [SerializeField] SmoothSlider expSlider; |
| | | [SerializeField] Button officialUpBtn; |
| | | |
| | | //任务区 |
| | | [SerializeField] Button taskButton; //引导或者领取任务奖励 |
| | |
| | | [SerializeField] Image awardIcon; |
| | | [SerializeField] Text awardCnt; |
| | | [SerializeField] UIEffectPlayer taskEffect; |
| | | |
| | | [SerializeField] UIEffectPlayer lvUPEffect; |
| | | |
| | | //关卡 |
| | | [SerializeField] Button bossBtn; |
| | | [SerializeField] MainLevelWaveCell[] mainLevelWaves; |
| | | [SerializeField] ScrollRect mainLevelScrollRect; |
| | | [SerializeField] Text levelName; |
| | | |
| | | [SerializeField] GameObject restMark; |
| | | [SerializeField] Button restBtn; |
| | | [SerializeField] GameObject fightMark; |
| | | [SerializeField] ScaleTween bossTween; |
| | | [SerializeField] GameObject bossmask; //完成进度遮挡管道 纯显示 |
| | | [SerializeField] GameObject bossActiveGo; |
| | | [SerializeField] GameObject bitemeGo; |
| | | [SerializeField] Text processText; |
| | | |
| | | |
| | | //卡牌 |
| | | [SerializeField] HeroFightingCardCell[] heroFightingCardCells; |
| | | [SerializeField] Button changeHeroPosBtn; |
| | | |
| | | //底部功能 |
| | | [SerializeField] Button autoBtn; |
| | | [SerializeField] Image autoCloseImg; |
| | | [SerializeField] UIEffectPlayer autoOpenEffect; |
| | | [SerializeField] Button blessLVBtn; |
| | | [SerializeField] Text blessLVText; |
| | | [SerializeField] Button mailBtn; |
| | | |
| | | //其他功能入口 |
| | | [SerializeField] Button monthCardBtn; |
| | | [SerializeField] Button FirstChargeBtn; |
| | | |
| | | /// <summary> |
| | | /// 初始化组件 |
| | |
| | | protected override void InitComponent() |
| | | { |
| | | taskButton.AddListener(OnClickTaskButton); |
| | | bossBtn.AddListener(() => |
| | | { |
| | | UIManager.Instance.OpenWindow<MainBossEnterWin>(); |
| | | }); |
| | | bossBtn.AddListener(OnClickEnterBoss); |
| | | |
| | | changeHeroPosBtn.AddListener(() => |
| | | { |
| | |
| | | UIManager.Instance.OpenWindow<HeroPosWin>(); |
| | | }); |
| | | |
| | | autoBtn.AddListener(()=> |
| | | autoBtn.AddListener(() => |
| | | { |
| | | //测试拾取所有物品 |
| | | var items = PackManager.Instance.GetItems(PackType.DropItem); |
| | | List<int> dropindexs = new List<int>(); |
| | | for (int i = 0; i < items.Count; i++) |
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.AutoFight, true)) |
| | | { |
| | | var item = items[i]; |
| | | if (dropindexs.Count > 5) |
| | | { |
| | | EquipModel.Instance.NotifyItemDrop(dropindexs, BattleManager.Instance.storyBattleField.battleRootNode.blueTeamNodeList[Random.Range(0, 5)].GetComponent<RectTransform>()); |
| | | dropindexs.Clear(); |
| | | } |
| | | |
| | | dropindexs.Add(item.gridIndex); |
| | | return; |
| | | } |
| | | if (dropindexs.Count > 0) |
| | | { |
| | | EquipModel.Instance.NotifyItemDrop(dropindexs, BattleManager.Instance.storyBattleField.battleRootNode.blueTeamNodeList[Random.Range(0,5)].GetComponent<RectTransform>()); |
| | | dropindexs.Clear(); |
| | | } |
| | | UIManager.Instance.OpenWindow<AutoFightWin>(); |
| | | }); |
| | | |
| | | |
| | | monthCardBtn.AddListener(() => |
| | | { |
| | | InvestModel.Instance.BuyInvest(InvestModel.monthCardType); |
| | | }); |
| | | |
| | | FirstChargeBtn.AddListener(() => |
| | | { |
| | | UIManager.Instance.OpenWindow<FirstChargeWin>(); |
| | | }); |
| | | |
| | | blessLVBtn.AddListener(() => |
| | | { |
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlessLV, true)) |
| | | { |
| | | return; |
| | | } |
| | | UIManager.Instance.OpenWindow<BlessLVWin>(); |
| | | }); |
| | | |
| | | mailBtn.AddListener(() => |
| | | { |
| | | UIManager.Instance.OpenWindow<MailWin>(); |
| | | }); |
| | | |
| | | officialUpBtn.AddListener(() => |
| | | { |
| | | if (RealmConfig.GetKeys().Count <= PlayerDatas.Instance.baseData.realmLevel) |
| | | return; |
| | | UIManager.Instance.OpenWindow<OfficialUpWin>(); |
| | | }); |
| | | |
| | | restBtn.AddListener(GotoRest); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public override void Refresh() |
| | | public void Display() |
| | | { |
| | | UpdatePlayerInfo(); |
| | | UpdateTask(); |
| | | RefreshRecharge(); |
| | | ShowBlessLV(); |
| | | DisplayAutoFight(); |
| | | DisplayCard(TeamType.Story); |
| | | DisplayLevel(); |
| | | DisplayRestState(); |
| | | |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefresh; |
| | | TaskManager.Instance.OnTaskUpdate += UpdateTask; |
| | | Refresh(); |
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent += ShowBlessLV; |
| | | AutoFightModel.Instance.ChangeAutoEvent += DisplayAutoFight; |
| | | AutoFightModel.Instance.OnFightEvent += ChangeMode; |
| | | TeamManager.Instance.OnTeamChange += DisplayCard; |
| | | UIManager.Instance.OnCloseWindow += OnCloseWindow; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChange; |
| | | FirstChargeManager.Instance.OnUpdateFirstChargeInfo += OnUpdateFirstChargeInfo; |
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; |
| | | HeroUIManager.Instance.OnUnLockHeroCountEvent += OnUnLockHeroCountEvent; |
| | | Display(); |
| | | DisplayFirstChargeBtn(); |
| | | |
| | | // var battleWin = UIManager.Instance.OpenWindow<BattleWin>(); |
| | | // battleWin.SetBattleField(BattleManager.Instance.storyBattleField); |
| | | } |
| | | protected override void OnOpen() |
| | | { |
| | | base.OnOpen(); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefresh; |
| | | TaskManager.Instance.OnTaskUpdate -= UpdateTask; |
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent -= ShowBlessLV; |
| | | AutoFightModel.Instance.ChangeAutoEvent -= DisplayAutoFight; |
| | | AutoFightModel.Instance.OnFightEvent -= ChangeMode; |
| | | TeamManager.Instance.OnTeamChange -= DisplayCard; |
| | | UIManager.Instance.OnCloseWindow -= OnCloseWindow; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChange; |
| | | FirstChargeManager.Instance.OnUpdateFirstChargeInfo -= OnUpdateFirstChargeInfo; |
| | | GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent; |
| | | HeroUIManager.Instance.OnUnLockHeroCountEvent -= OnUnLockHeroCountEvent; |
| | | |
| | | // 关闭的时候把战斗界面也给关了 虽然是在外面开的 |
| | | UIManager.Instance.CloseWindow<BattleWin>(); |
| | | } |
| | | |
| | | private void OnClickEnterBoss() |
| | | { |
| | | // BattleField battleField = BattleManager.Instance.GetBattleFieldByMapID(2); //BOSS战斗 |
| | | |
| | | // if (null != battleField) |
| | | // { |
| | | // StoryBossBattleWin fsBattleWin = UIManager.Instance.OpenWindow<StoryBossBattleWin>(); |
| | | // fsBattleWin.SetBattleField(battleField); |
| | | // return; |
| | | // } |
| | | |
| | | UIManager.Instance.OpenWindow<MainBossEnterWin>(); |
| | | } |
| | | |
| | | int lastLV = 0; |
| | | void PlayerDataRefresh(PlayerDataType type) |
| | | { |
| | | switch (type) |
| | |
| | | ShowExp(); |
| | | break; |
| | | case PlayerDataType.LV: |
| | | if (lastLV != PlayerDatas.Instance.baseData.LV) |
| | | { |
| | | lastLV = PlayerDatas.Instance.baseData.LV; |
| | | lvUPEffect.Play(); |
| | | } |
| | | playerLevelText.text = PlayerDatas.Instance.baseData.LV.ToString(); |
| | | break; |
| | | case PlayerDataType.ExAttr1: |
| | | case PlayerDataType.ExAttr2: |
| | | DisplayLevel(); |
| | | break; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | void RefreshRecharge() |
| | | { |
| | | monthCardBtn.SetActive(!InvestModel.Instance.IsInvested(InvestModel.monthCardType)); |
| | | } |
| | | |
| | | |
| | | void ShowBlessLV() |
| | | { |
| | | blessLVText.text = BlessLVManager.Instance.m_TreeLV.ToString(); |
| | | } |
| | | |
| | | void DisplayAutoFight() |
| | | { |
| | | if (AutoFightModel.Instance.isAutoAttackSet) |
| | | { |
| | | autoCloseImg.SetActive(false); |
| | | autoOpenEffect.Play(); |
| | | } |
| | | else |
| | | { |
| | | autoCloseImg.SetActive(true); |
| | | autoOpenEffect.Stop(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | void UpdateTask() |
| | | { |
| | | { |
| | | var task = TaskManager.Instance.mainTask; |
| | | if (task.TaskID == 0) |
| | | { |
| | |
| | | var taskConfig = TaskConfig.Get(task.TaskID); |
| | | taskText.text = taskConfig.TaskDescribe; |
| | | taskNumText.text = string.Format("({0}/{1})", task.CurValue, taskConfig.NeedValue); |
| | | taskNumText.color = task.CurValue >= taskConfig.NeedValue ? UIHelper.GetUIColor(TextColType.NavyYellow) : UIHelper.GetUIColor(TextColType.Red); |
| | | taskNumText.color = task.CurValue >= taskConfig.NeedValue ? UIHelper.GetUIColor(TextColType.NavyYellow) : UIHelper.GetUIColor(TextColType.Red); |
| | | if (TaskManager.Instance.GetMainTaskState() == 2) |
| | | { |
| | | { |
| | | taskEffect.Play(); |
| | | } |
| | | else |
| | |
| | | getReward.DataEx = (uint)TaskManager.Instance.mainTask.TaskID; |
| | | GameNetSystem.Instance.SendInfo(getReward); |
| | | } |
| | | |
| | | TaskManager.Instance.ClickTask(); |
| | | } |
| | | |
| | | void DisplayCard(TeamType teamType) |
| | | { |
| | | if (teamType != TeamType.Story) |
| | | return; |
| | | var team = TeamManager.Instance.GetTeam(teamType); |
| | | var heros = team.GetHerosOnTeam(); |
| | | //显示卡牌 |
| | | for (int i = 0; i < heroFightingCardCells.Length; i++) |
| | | { |
| | | heroFightingCardCells[i].Display(i, heros); |
| | | } |
| | | } |
| | | |
| | | private void OnCloseWindow(UIBase closeUI) |
| | | { |
| | | //其他武将功能产生数据变化,需要刷新武将列表 |
| | | if (closeUI is HeroTrainWin) |
| | | { |
| | | DisplayCard(TeamType.Story); |
| | | } |
| | | } |
| | | |
| | | |
| | | private void DisplayLevel() |
| | | { |
| | | var value = PlayerDatas.Instance.baseData.ExAttr2; |
| | | var chapterID = value / 10000; |
| | | var levelNum = value % 10000 / 100; |
| | | var waveID = value % 100; |
| | | |
| | | var config = MainLevelConfig.GetMainLevelConfig(chapterID, levelNum); |
| | | var totalWave = MainLevelConfig.GetwaveCount(config); |
| | | for (int i = 0; i < mainLevelWaves.Length; i++) |
| | | { |
| | | if (i < totalWave) |
| | | { |
| | | mainLevelWaves[i].SetActive(true); |
| | | mainLevelWaves[i].Display(i); |
| | | } |
| | | else |
| | | { |
| | | mainLevelWaves[i].SetActive(false); |
| | | } |
| | | } |
| | | |
| | | mainLevelScrollRect.normalizedPosition = new Vector2(waveID > 3 ? 1 : 0, 0); |
| | | |
| | | var chapterConfig = MainChapterConfig.Get(chapterID); |
| | | //【普通】关卡名字1-6 |
| | | levelName.text = Language.Get("mainui7", chapterConfig.Level, chapterConfig.ChapterName, chapterID, levelNum); |
| | | |
| | | bool canChallengeBoss = MainLevelManager.Instance.CanChallengeBoss(); |
| | | //BOSS |
| | | if (canChallengeBoss) |
| | | { |
| | | bossActiveGo.SetActive(true); |
| | | processText.SetActive(false); |
| | | bossTween.Play(); |
| | | bitemeGo.SetActive(true); |
| | | bossmask.SetActive(true); |
| | | } |
| | | else |
| | | { |
| | | //根据任务类型引导 |
| | | bossActiveGo.SetActive(false); |
| | | processText.SetActive(true); |
| | | processText.text = (waveID - 1) * 100 / totalWave + "%"; |
| | | bossTween.Stop(); |
| | | bitemeGo.SetActive(false); |
| | | bossmask.SetActive(false); |
| | | } |
| | | |
| | | } |
| | | |
| | | void DisplayRestState() |
| | | { |
| | | if (BattleManager.Instance.storyBattleField != null && |
| | | BattleManager.Instance.storyBattleField.GetBattleMode() == BattleMode.Stop) |
| | | { |
| | | //休息中 |
| | | restMark.SetActive(true); |
| | | fightMark.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | //战斗中 |
| | | restMark.SetActive(false); |
| | | fightMark.SetActive(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | void ChangeMode(bool isFight) |
| | | { |
| | | if (isFight) |
| | | return; |
| | | DisplayRestState(); |
| | | DisplayLevel(); |
| | | } |
| | | |
| | | void GotoRest() |
| | | { |
| | | if (BattleManager.Instance.storyBattleField != null && |
| | | BattleManager.Instance.storyBattleField.GetBattleMode() != BattleMode.Stop) |
| | | { |
| | | BattleManager.Instance.storyBattleField.HaveRest(); |
| | | } |
| | | } |
| | | |
| | | private void DisplayFirstChargeBtn() |
| | | { |
| | | bool isFirstChargeFuncOpen = FuncOpen.Instance.IsFuncOpen(FirstChargeManager.FuncID); |
| | | if (FirstChargeManager.Instance.IsAllFirstChargeRewardsClaimed() && |
| | | FirstChargeManager.Instance.IsNextDayAfterAllClaimed()) |
| | | { |
| | | FirstChargeBtn.SetActive(false); |
| | | } |
| | | else |
| | | { |
| | | FirstChargeBtn.SetActive(isFirstChargeFuncOpen); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void OnFuncStateChange(int funcId) |
| | | { |
| | | if (funcId == FirstChargeManager.FuncID) |
| | | { |
| | | DisplayFirstChargeBtn(); |
| | | } |
| | | } |
| | | |
| | | private void OnUpdateFirstChargeInfo() |
| | | { |
| | | DisplayFirstChargeBtn(); |
| | | } |
| | | |
| | | private void OnSecondEvent() |
| | | { |
| | | DisplayFirstChargeBtn(); |
| | | } |
| | | |
| | | void OnUnLockHeroCountEvent() |
| | | { |
| | | DisplayCard(TeamType.Story); |
| | | } |
| | | } |