PanelOver.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class PanelOver : MonoBehaviour {
  7. private Button replayBtn;
  8. private Button exitBtn;
  9. private Text nowScore;
  10. private Text bestScore;
  11. // Use this for initialization
  12. void Start () {
  13. replayBtn = transform.Find("ReplayBtn").GetComponent<Button>();
  14. exitBtn = transform.Find("ExitBtn").GetComponent<Button>();
  15. replayBtn.onClick.RemoveAllListeners();
  16. replayBtn.onClick.AddListener(replayBtnEvent);
  17. exitBtn.onClick.RemoveAllListeners();
  18. exitBtn.onClick.AddListener(exitBtnEvent);
  19. nowScore = transform.Find("NowScore").GetComponent<Text>();
  20. bestScore = transform.Find("BestScore").GetComponent<Text>();
  21. }
  22. private void exitBtnEvent()
  23. {
  24. Application.Quit();
  25. }
  26. private void replayBtnEvent()
  27. {
  28. //重玩按钮 从结束界面跳转到游戏界面 分数重置 生成飞机、石头、道具
  29. UIManager.instance.CreatePanel("PanelGame");
  30. UIManager.instance.DestroyPanel("PanelOver");
  31. ScoreManager.instance.Score = 0;
  32. PlaneManager.instance.CreateAirPlane();
  33. CreateStone.instance.InvokeRepeating("createStone",1f,1f);
  34. CreateStone.instance.InvokeRepeating("createProp", 1f, 3f);
  35. }
  36. // Update is called once per frame
  37. void Update () {
  38. //结束界面 显示当前分数和最高分
  39. nowScore.text = ScoreManager.instance.Score.ToString();
  40. bestScore.text = PlayerPrefs.GetInt("Best").ToString();
  41. }
  42. }