123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class PanelOver : MonoBehaviour {
- private Button replayBtn;
- private Button exitBtn;
- private Text nowScore;
- private Text bestScore;
- // Use this for initialization
- void Start () {
- replayBtn = transform.Find("ReplayBtn").GetComponent<Button>();
- exitBtn = transform.Find("ExitBtn").GetComponent<Button>();
- replayBtn.onClick.RemoveAllListeners();
- replayBtn.onClick.AddListener(replayBtnEvent);
- exitBtn.onClick.RemoveAllListeners();
- exitBtn.onClick.AddListener(exitBtnEvent);
- nowScore = transform.Find("NowScore").GetComponent<Text>();
- bestScore = transform.Find("BestScore").GetComponent<Text>();
- }
- private void exitBtnEvent()
- {
- Application.Quit();
- }
- private void replayBtnEvent()
- {
- //重玩按钮 从结束界面跳转到游戏界面 分数重置 生成飞机、石头、道具
- UIManager.instance.CreatePanel("PanelGame");
- UIManager.instance.DestroyPanel("PanelOver");
- ScoreManager.instance.Score = 0;
- PlaneManager.instance.CreateAirPlane();
- CreateStone.instance.InvokeRepeating("createStone",1f,1f);
- CreateStone.instance.InvokeRepeating("createProp", 1f, 3f);
- }
- // Update is called once per frame
- void Update () {
- //结束界面 显示当前分数和最高分
- nowScore.text = ScoreManager.instance.Score.ToString();
- bestScore.text = PlayerPrefs.GetInt("Best").ToString();
- }
- }
-
|