using FairyGUI; using System; using UnityEngine; using XGame; using XGame.Database; using XGame.Framework.Map; namespace FL.Map.UI { public class MainMapUIView : EntityView { 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); VM.MapTaskBtn.onClick.AddListener(OnClickMapTaskBtn); } protected override void OnDisable() { VM.ChallengeBtn.onClick.RemoveAllListeners(); VM.MapTaskBtn.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); } private void OnClickMapTaskBtn() { } } }