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