GameRuleView.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. GameMgr.ins.addLockerForGamePause(this);
  21. this.Click();
  22. }
  23. void OnDestroy()
  24. {
  25. createLock = false;
  26. GameMgr.ins.removeLockerForGamePause(this);
  27. }
  28. public void Click() {
  29. int[] rule = (int[]) this.GetType().GetField("rule" + GameMgr.gameType).GetValue(this);
  30. if (ruleLookIndex >= rule.Length) {
  31. Destroy(this.gameObject);
  32. GameMgr.ins.FinishGameRuleGuide();
  33. } else {
  34. this.transform.Find("BG/Panel/Content").GetComponent<TextAutoLanguage>().SetText(rule[ruleLookIndex]);
  35. ruleLookIndex++;
  36. }
  37. }
  38. }