GameRuleView.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class GameRuleView : MonoBehaviour
  6. {
  7. public int[] rule1;
  8. public int[] rule2;
  9. int ruleLookIndex = 0;
  10. static bool createLock = false;
  11. public static void Create()
  12. {
  13. if (createLock || GameMgr.gameType == 0) return;
  14. createLock = true;
  15. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/GameRuleView"));
  16. }
  17. void Start()
  18. {
  19. GameMgr.ins.addLockerForGamePause(this);
  20. this.Click();
  21. }
  22. void OnDestroy()
  23. {
  24. createLock = false;
  25. GameMgr.ins.removeLockerForGamePause(this);
  26. }
  27. public void Click() {
  28. int[] rule = (int[]) this.GetType().GetField("rule" + GameMgr.gameType).GetValue(this);
  29. if (ruleLookIndex >= rule.Length) {
  30. Destroy(this.gameObject);
  31. GameMgr.ins.FinishGameRuleGuide();
  32. } else {
  33. this.transform.Find("BG/Panel/Content").GetComponent<TextAutoLanguage>().SetText(rule[ruleLookIndex]);
  34. ruleLookIndex++;
  35. }
  36. }
  37. }