Cute_demon_attacks/meng_yao/Assets/script/Manager/AnimatoinManager.cs
2024-11-25 17:58:55 +08:00

63 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimatoinManager : MonoBehaviour
{
public float time=0f;
private float yuntime = 0f;
// Start is called before the first frame update
private void Start()
{
}
private void Playanim()
{
GameObject fi = Instantiate((GameObject)Resources.Load("fish_1"),this.gameObject.transform);
float x = Random.Range(-5, 5);
float y = Random.Range(-11,0);
fi.transform.position = new Vector3(x,y,0);
Destroy(fi, 2f);
}
private void Moveyunduo()
{
for (int i = 0; i < Random.Range(1, 4); i++)
{
GameObject fi = Instantiate(Resources.Load<GameObject>("yunduo" + Random.Range(1, 4)),this.gameObject.transform);
float x = Random.Range(-14, -10);
float y = Random.Range(-7,11);
fi.transform.position = new Vector3(x,y,0);
Destroy(fi,10f);
}
}
private void Update()
{
time += Time.deltaTime;
yuntime += Time.deltaTime;
if (time > 5f)
{
time = 0;
for (int i = 0; i < Random.Range(1,4); i++)
{
Playanim();
}
}
if (yuntime > 10f)
{
yuntime = 0;
Moveyunduo();
}
}
}