GameRuleView.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. /* 游戏规则界面 */
  6. public class GameRuleView : MonoBehaviour
  7. {
  8. public int[] rule1;
  9. public int[] rule2;
  10. int ruleLookIndex = 0;
  11. static bool createLock = false;
  12. public static void Create()
  13. {
  14. if (createLock || GameMgr.gameType == 0) return;
  15. createLock = true;
  16. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/GameRuleView"));
  17. }
  18. void Start()
  19. {
  20. if (GlobalData.pkMatchType != PKMatchType.OnlinePK) {
  21. GameMgr.ins.addLockerForGamePause(this);
  22. }
  23. this.Click();
  24. }
  25. void OnDestroy()
  26. {
  27. createLock = false;
  28. if (GlobalData.pkMatchType != PKMatchType.OnlinePK) {
  29. if (GameMgr.ins) GameMgr.ins.removeLockerForGamePause(this);
  30. }
  31. }
  32. public void Click() {
  33. int[] rule = null;
  34. if (GameMgr.gameType == 1) {
  35. rule = rule1;
  36. } else if (GameMgr.gameType == 2 || GameMgr.gameType == 9) {
  37. rule = rule2;
  38. }
  39. if (ruleLookIndex >= rule.Length) {
  40. Destroy(this.gameObject);
  41. GameMgr.ins.FinishGameRuleGuide();
  42. } else {
  43. this.transform.Find("BG/Panel/Content").GetComponent<TextAutoLanguage>().SetText(rule[ruleLookIndex]);
  44. ruleLookIndex++;
  45. }
  46. }
  47. }