PanelStart.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class PanelStart : MonoBehaviour {
  7. private Button startBtn;
  8. private Button setBtn;
  9. private Button exitBtn;
  10. // Use this for initialization
  11. void Start () {
  12. startBtn = transform.Find("StartBtn").GetComponent<Button>();
  13. setBtn = transform.Find("SetBtn").GetComponent<Button>();
  14. exitBtn = transform.Find("ExitBtn").GetComponent<Button>();
  15. startBtn.onClick.RemoveAllListeners();
  16. startBtn.onClick.AddListener(startBtnEvent);
  17. setBtn.onClick.RemoveAllListeners();
  18. setBtn.onClick.AddListener(setBtnEvent);
  19. exitBtn.onClick.RemoveAllListeners();
  20. exitBtn.onClick.AddListener(exitBtnEvent);
  21. }
  22. private void exitBtnEvent()
  23. {
  24. Application.Quit();
  25. }
  26. private void setBtnEvent()
  27. {
  28. UIManager.instance.CreatePanel("PanelSet");
  29. UIManager.instance.DestroyPanel("PanelStart");
  30. }
  31. // Update is called once per frame
  32. void Update () {
  33. }
  34. void startBtnEvent()
  35. {
  36. //点击开始按钮 界面跳转 生成飞机、石头、道具
  37. UIManager.instance.CreatePanel("PanelGame");
  38. UIManager.instance.DestroyPanel("PanelStart");
  39. PlaneManager.instance.CreateAirPlane();
  40. CreateStone.instance.InvokeRepeating("createStone",1f,1f);
  41. CreateStone.instance.InvokeRepeating("createProp",1f,3f);
  42. }
  43. }