123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GuangkejiAnimator : MonoBehaviour
- {
- public Animator anim;
- private float startTimer;
- private bool isStart;//动画是否开始播放
- public Animator Line;//线条动画组件
- public GameObject fanguang;//反光动画
- public GameObject[] textGamesLisr;
- private bool isLook;//是否看着对象
- private void Start()
- {
- //anim = this.GetComponent<Animator>();
- startTimer = 2f;
- ShowOrHeidGames(-1);
- }
- private void ShowOrHeidGames(int index)
- {
- for (int i = 0; i < textGamesLisr.Length; i++)
- {
- if (i == index)//如果等于传入的参数
- {
- PlaySounds(i);
- textGamesLisr[i].SetActive(true);
- //文字动画的三个动画组件
- textGamesLisr[i].transform.Find("TP/Galaxy Renamer (1)/frame").GetComponent<Animator>().Play("frame_Appear");
- textGamesLisr[i].transform.Find("TP/Galaxy Renamer (1)/frame (2)").GetComponent<Animator>().Play("frame_Appear");
- textGamesLisr[i].transform.Find("TP/Galaxy Renamer (1)/frame (1)").GetComponent<Animator>().Play("frame_Appear");
- }
- else
- {
- StartCoroutine(WaitForTiemrs(0.8f, textGamesLisr[i]));
- textGamesLisr[i].transform.Find("TP/Galaxy Renamer (1)/frame").GetComponent<Animator>().Play("frame_Disappear");
- textGamesLisr[i].transform.Find("TP/Galaxy Renamer (1)/frame (2)").GetComponent<Animator>().Play("frame_Disappear");
- textGamesLisr[i].transform.Find("TP/Galaxy Renamer (1)/frame (1)").GetComponent<Animator>().Play("frame_Disappear");
- }
- }
- }
- /// <summary>
- /// 线条动画开始
- /// </summary>
- public void LineStart()
- {
- Line.gameObject.GetComponent<MeshRenderer>().enabled = true;//获取线条的组件
- Line.gameObject.GetComponent<Animator>().enabled = true;//获取线条动画的组件
- fanguang.gameObject.SetActive(true);
- Line.speed = 1;//播放动画
- }
- /// <summary>
- /// 线条动画暂停
- /// </summary>
- public void LineStop()
- {
- Line.gameObject.GetComponent<MeshRenderer>().enabled = false;
- Line.gameObject.GetComponent<Animator>().enabled = false;
- fanguang.gameObject.SetActive(false);
- Line.speed = 0;//暂停动画
- }
- /// <summary>
- /// 机械臂的动画开始
- /// </summary>
- public void AnimStart()
- {
- anim.speed = 1f;
- }
- /// <summary>
- /// 机械臂的动画停止
- /// </summary>
- public void AnimStop(int index)
- {
- ShowOrHeidGames(index);
- anim.speed = 0;
- isStart = true;
- }
- private void Update()
- {
- if (isStart)
- {
- startTimer -= Time.deltaTime;//开始时间倒计时
- if (startTimer <= 0)
- {
- AnimStart();
- startTimer = 4;
- ShowOrHeidGames(-1);//不播放文字动画
- isStart = false;
- }
- }
- }
- IEnumerator WaitForTiemrs(float timer, GameObject obj)
- {
- yield return new WaitForSeconds(timer);
- // obj.SetActive(false);
- }
- private void PlaySounds(int Soundindex)
- {
- string soundNames = "";
- switch (Soundindex)
- {
- case 0:
- soundNames = "GY_GKJ1";
- break;
- case 1:
- soundNames = "GY_GKJ2";
- break;
- case 2:
- soundNames = "GY_GKJ3";
- break;
- case 3:
- soundNames = "GY_GKJ4";
- break;
- case 4:
- soundNames = "GY_GKJ5";
- break;
- case 5:
- soundNames = "GY_GKJ6";
- break;
- }
- AudioManager.Instance.AudioGongYe_GKJ_LanguageSounds(soundNames);
- }
- }
|