MainMapUIView.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using FairyGUI;
  2. using System;
  3. using UnityEngine;
  4. using XGame;
  5. using XGame.Database;
  6. using XGame.Framework.Map;
  7. namespace FL.Map.UI
  8. {
  9. public class MainMapUIView : EntityView<MainMapUIVM>
  10. {
  11. public Transform CombatValRoot => VM.CombatValRoot;
  12. public Transform PlayerRoot => VM.PlayerRoot;
  13. public Transform MonsterRoot => VM.MonsterRoot;
  14. public Transform BossRoot => VM.BossRoot;
  15. protected override void OnEnable(object intent)
  16. {
  17. VM.Canvas.worldCamera = StageCamera.main;
  18. VM.ChallengeBtn.onClick.AddListener(OnClickChallengeBtn);
  19. VM.MapTaskBtn.onClick.AddListener(OnClickMapTaskBtn);
  20. }
  21. protected override void OnDisable()
  22. {
  23. VM.ChallengeBtn.onClick.RemoveAllListeners();
  24. VM.MapTaskBtn.onClick.RemoveAllListeners();
  25. VM.Canvas.worldCamera = null;
  26. }
  27. public void RefreshChapter(int chapterId)
  28. {
  29. var chapter = ChapterTableRepo.Get(chapterId);
  30. if (chapter == null)
  31. {
  32. Log.Error($"找不到ChapterTable. chapterId: {chapterId}");
  33. return;
  34. }
  35. var isBossPart = chapter.Part_type == 1;
  36. if ( isBossPart)
  37. {
  38. VM.ChallengeBtn.gameObject.SetActive(false);
  39. }
  40. var isBossFailed = VM.ChallengeBtn.gameObject.activeSelf; // boss挑战失败显示挑战按钮隐藏副本进度条
  41. //Log.Debug($"MainMapUIView RefreshChapter Id:{chapterId} isBoss:{isBossPart} isBossFailed:{isBossFailed}");
  42. // 副本进度只在非boss且挑战按钮隐藏的时候显示
  43. VM.MapInfoRoot.SetActive(!isBossPart);
  44. if (VM.MapInfoRoot.activeSelf)
  45. {
  46. VM.MapNameTxt.text = $"{chapter.Name} {chapter.Chapter}-{chapter.Section}";
  47. VM.MapProgress.SetActive(!isBossFailed);
  48. if (!isBossFailed )
  49. {
  50. VM.MapProgressImg.fillAmount = (chapter.Part - 1) / 4f;
  51. ((RectTransform)VM.CurProgressImg.transform).anchoredPosition = new Vector2(56 * (chapter.Part - 1) - 112, 0);
  52. }
  53. }
  54. }
  55. public void SetBossFailed(bool isFailed)
  56. {
  57. VM.ChallengeBtn.gameObject.SetActive(isFailed);
  58. }
  59. private void OnClickChallengeBtn()
  60. {
  61. EventSingle.Instance.Notify(EventDefine.GameMainMapChallengeBoss);
  62. VM.ChallengeBtn.gameObject.SetActive (false);
  63. }
  64. private void OnClickMapTaskBtn()
  65. {
  66. }
  67. }
  68. }