GameRuleView.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class GameRuleView : MonoBehaviour
  6. {
  7. public string[] rule1 = new string[]{"在固定的时间内尽量射更多的箭。", "总环数逐渐增加,挑战自己的纪录。"};
  8. public string[] rule2 = new string[]{
  9. "两个人轮流射箭,使用奥运会的规则进行PK。",
  10. "比赛一共5局,每局3支箭,累计得分高者胜出。",
  11. "获胜者获得永久积分2分,打平各1分,输者不得积分。",
  12. "先得6分者胜利,如5局打完是平局,则加赛一箭定胜负", "总环数逐渐增加,挑战自己的纪录。"
  13. };
  14. int ruleLookIndex = 0;
  15. void OnDestroy()
  16. {
  17. GameMgr.ins.removeLockerForGamePause(this);
  18. }
  19. public void Click() {
  20. string[] rule = (string[]) this.GetType().GetField("rule" + GameMgr.gameType).GetValue(this);
  21. if (ruleLookIndex >= rule.Length) {
  22. ruleLookIndex = 0;
  23. this.transform.Find("BG").gameObject.SetActive(false);
  24. GameMgr.ins.removeLockerForGamePause(this);
  25. GameMgr.ins.FinishGameRuleGuide();
  26. } else {
  27. this.transform.Find("BG").gameObject.SetActive(true);
  28. this.transform.Find("BG/Panel/Content").GetComponent<Text>().text = rule[ruleLookIndex];
  29. LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform.Find("BG/Panel").GetComponent<RectTransform>());
  30. ruleLookIndex++;
  31. GameMgr.ins.addLockerForGamePause(this);
  32. }
  33. }
  34. }