63 lines
1.3 KiB
C#
63 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class JinbiAnimatoin : MonoBehaviour
|
|
{
|
|
public float time = 0f;
|
|
private float speed = 10f;
|
|
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"));
|
|
float x = Random.Range(-5, 5);
|
|
float y = Random.Range(-12, -40);
|
|
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)));
|
|
float x = Random.Range(-11, -18);
|
|
float y = Random.Range(-12, -40);
|
|
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();
|
|
}
|
|
|
|
}
|
|
}
|