RankingView.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6. public class RankingView : MonoBehaviour, MenuBackInterface
  7. {
  8. [SerializeField] Transform panelLeftContent;
  9. void Start()
  10. {
  11. PersistenHandler.ins?.menuBackCtr.views.Add(this);
  12. }
  13. void OnDestroy()
  14. {
  15. PersistenHandler.ins?.menuBackCtr.views.Remove(this);
  16. }
  17. public bool OnMenuBack()
  18. {
  19. ViewManager2.HideView(ViewManager2.Path_RankingView);
  20. return true;
  21. }
  22. public void OnClick_PanelLeftItem(Transform target)
  23. {
  24. foreach (Transform item in panelLeftContent)
  25. {
  26. if (item == target)
  27. {
  28. item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Bold;
  29. item.Find("Text").GetComponent<Text>().color = Color.white;
  30. bool oldActive = item.Find("LightMask").gameObject.activeSelf;
  31. item.Find("LightMask").gameObject.SetActive(true);
  32. if (!oldActive)
  33. {
  34. AudioMgr.ins.PlayBtn();
  35. ShowBox(item.name);
  36. }
  37. }
  38. else
  39. {
  40. item.Find("Text").GetComponent<Text>().fontStyle = FontStyle.Normal;
  41. item.Find("Text").GetComponent<Text>().color = Color.gray;
  42. item.Find("LightMask").gameObject.SetActive(false);
  43. }
  44. }
  45. }
  46. int _btnIndex = 0;
  47. public int currentBtnIndex { get => _btnIndex; }
  48. void ShowBox(string itemName)
  49. {
  50. if (itemName == "BtnGlobalRanking") _btnIndex = 0;
  51. else if (itemName == "BtnCountryRanking") _btnIndex = 1;
  52. RefreshBoxRankList();
  53. }
  54. public void RefreshBoxRankList()
  55. {
  56. GetComponentInChildren<BoxRankList>().Refresh();
  57. }
  58. public void OnClick_Back()
  59. {
  60. AudioMgr.ins.PlayBtn();
  61. ViewManager2.HideView(ViewManager2.Path_RankingView);
  62. }
  63. }