AquariumManage.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class AquariumManage : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. public SCButton moguyuButton, jiaohuButton, bigshellsButton;
  8. // public Animator moguiyu,jiaohu,bigshells;
  9. public Animator mgy;
  10. public GameObject moguyuTeXiao;
  11. public AudioSource kunAudio;
  12. // private AudioSource audiosource;
  13. private bool isPlay;
  14. public bool IsPlay
  15. {
  16. get => isPlay;
  17. set
  18. {
  19. isPlay = value;
  20. // StartCoroutine(PlayMusic());
  21. }
  22. }
  23. void Start()
  24. {
  25. // audiosource = this.gameObject.GetComponent<AudioSource>();
  26. StartCoroutine(PlaykunAudio());
  27. moguyuButton.onClick.AddListener(() =>
  28. {
  29. moguyuButton.gameObject.GetComponent<Animator>().SetBool("Open", true);
  30. mgy.SetBool("Open", true);
  31. moguyuTeXiao.gameObject.SetActive(true);
  32. });
  33. jiaohuButton.onClick.AddListener(() =>
  34. {
  35. JiaohuManage();
  36. });
  37. bigshellsButton.onClick.AddListener(() =>
  38. {
  39. BigshellManage();
  40. });
  41. }
  42. /// <summary>
  43. /// 每8秒琨叫一次
  44. /// </summary>
  45. /// <returns></returns>
  46. IEnumerator PlaykunAudio()
  47. {
  48. while (true)
  49. {
  50. yield return new WaitForSeconds(8f);
  51. kunAudio.Play();
  52. }
  53. }
  54. public void JiaohuManage()
  55. {
  56. jiaohuButton.gameObject.GetComponent<Animator>().Play("jiaohu");
  57. }
  58. public void BigshellManage()
  59. {
  60. bigshellsButton.gameObject.GetComponent<Animator>().Play("Take 001 0");
  61. }
  62. //public IEnumerator PlayMusic()
  63. //{
  64. // yield return new WaitForSeconds(10f);
  65. // audiosource.Play();
  66. // IsPlay = true;
  67. //}
  68. }