123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class AquariumManage : MonoBehaviour
- {
- // Start is called before the first frame update
- public SCButton moguyuButton, jiaohuButton, bigshellsButton;
- // public Animator moguiyu,jiaohu,bigshells;
- public Animator mgy;
- public GameObject moguyuTeXiao;
- public AudioSource kunAudio;
- // private AudioSource audiosource;
- private bool isPlay;
- public bool IsPlay
- {
- get => isPlay;
- set
- {
- isPlay = value;
- // StartCoroutine(PlayMusic());
- }
- }
- void Start()
- {
- // audiosource = this.gameObject.GetComponent<AudioSource>();
- StartCoroutine(PlaykunAudio());
- moguyuButton.onClick.AddListener(() =>
- {
- moguyuButton.gameObject.GetComponent<Animator>().SetBool("Open", true);
- mgy.SetBool("Open", true);
- moguyuTeXiao.gameObject.SetActive(true);
- });
- jiaohuButton.onClick.AddListener(() =>
- {
- JiaohuManage();
- });
- bigshellsButton.onClick.AddListener(() =>
- {
- BigshellManage();
- });
- }
- /// <summary>
- /// 每8秒琨叫一次
- /// </summary>
- /// <returns></returns>
- IEnumerator PlaykunAudio()
- {
- while (true)
- {
- yield return new WaitForSeconds(8f);
- kunAudio.Play();
- }
- }
- public void JiaohuManage()
- {
- jiaohuButton.gameObject.GetComponent<Animator>().Play("jiaohu");
- }
- public void BigshellManage()
- {
- bigshellsButton.gameObject.GetComponent<Animator>().Play("Take 001 0");
- }
- //public IEnumerator PlayMusic()
- //{
- // yield return new WaitForSeconds(10f);
- // audiosource.Play();
- // IsPlay = true;
- //}
- }
|