//新版显示按钮的方法 private void ShowButtonsNew() { for (int i = 0; i < theMissionButtons.Count; i++) { missionButtonsPool.Enqueue(theMissionButtons[i]); theMissionButtons [i].gameObject.SetActive(false); } theMissionButtons.Clear(); MissionPackage thePackage = SystemValues.thePlayer.GetComponent <Player> ().theMissionPackage; for (int i = 0; i < thePackage.theMissions.Count; i++) { MissionButton aMission; if (missionButtonsPool.Count > 0) { aMission = missionButtonsPool.Dequeue(); aMission.gameObject.SetActive(true); } else { aMission = GameObject.Instantiate(MissionButtonProfab).GetComponent <MissionButton>(); } aMission.SetMission(thePackage.theMissions[i], missionInformationText); theMissionButtons.Add(aMission); } theMissionButtons.Sort((x, y) => (x.missionID.CompareTo(y.missionID))); //先完成排序再加入 for (int i = 0; i < theMissionButtons.Count; i++) { theMissionButtons[i].transform.SetParent(MissionButtonfather); } }
void Start() { HpChanger += this.ChangeHp; DamageChanger += this.ChangeDamage; LearningChanger += this.ChangeLearning; theAnimationController = this.GetComponent <Animator> (); theMoveController = this.GetComponent <move> (); theMissionPackage = this.GetComponent <MissionPackage> (); MakeHpSlider(); }
//旧版显示按钮的方法 private void ShowBttonsOld() { for (int i = 0; i < theMissionButtons.Count; i++) { Destroy(theMissionButtons[i].gameObject); } theMissionButtons.Clear(); MissionPackage thePackage = SystemValues.thePlayer.GetComponent <Player> ().theMissionPackage; for (int i = 0; i < thePackage.theMissions.Count; i++) { MissionButton aMission = GameObject.Instantiate(MissionButtonProfab).GetComponent <MissionButton>(); aMission.transform.SetParent(MissionButtonfather); aMission.SetMission(thePackage.theMissions[i], missionInformationText); theMissionButtons.Add(aMission); } }