123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using FairyGUI;
- using UnityEngine;
- using XGame;
- using XGame.Database;
- using XGame.Framework.Map;
- namespace FL.Map.UI
- {
- public class MainMapUIView : EntityView<MainMapUIVM>
- {
- public Transform CombatValRoot => VM.CombatValRoot;
- public Transform PlayerRoot => VM.PlayerRoot;
- public Transform MonsterRoot => VM.MonsterRoot;
- public Transform BossRoot => VM.BossRoot;
- protected override void OnEnable(object intent)
- {
- VM.Canvas.worldCamera = StageCamera.main;
- VM.ChallengeBtn.onClick.AddListener(OnClickChallengeBtn);
- }
- protected override void OnDisable()
- {
- VM.ChallengeBtn.onClick.RemoveAllListeners();
- VM.Canvas.worldCamera = null;
- }
- public void RefreshChapter(int chapterId)
- {
- var chapter = ChapterTableRepo.Get(chapterId);
- if (chapter == null)
- {
- Log.Error($"找不到ChapterTable. chapterId: {chapterId}");
- return;
- }
- var isBossPart = chapter.Part_type == 1;
- if ( isBossPart)
- {
- VM.ChallengeBtn.gameObject.SetActive(false);
- }
- var isBossFailed = VM.ChallengeBtn.gameObject.activeSelf; // boss挑战失败显示挑战按钮隐藏副本进度条
- //Log.Debug($"MainMapUIView RefreshChapter Id:{chapterId} isBoss:{isBossPart} isBossFailed:{isBossFailed}");
- // 副本进度只在非boss且挑战按钮隐藏的时候显示
- VM.MapInfoRoot.SetActive(!isBossPart);
- if (VM.MapInfoRoot.activeSelf)
- {
- VM.MapNameTxt.text = $"{chapter.Name} {chapter.Chapter}-{chapter.Section}";
- VM.MapProgress.SetActive(!isBossFailed);
- if (!isBossFailed )
- {
- VM.MapProgressImg.fillAmount = (chapter.Part - 1) / 4f;
- ((RectTransform)VM.CurProgressImg.transform).anchoredPosition = new Vector2(56 * (chapter.Part - 1) - 112, 0);
- }
- }
- }
- public void SetBossFailed(bool isFailed)
- {
- VM.ChallengeBtn.gameObject.SetActive(isFailed);
- }
- private void OnClickChallengeBtn()
- {
- EventSingle.Instance.Notify(EventDefine.GameMainMapChallengeBoss);
- VM.ChallengeBtn.gameObject.SetActive (false);
- }
- }
- }
|