123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- public class FishManage : MonoBehaviour
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public Transform Group;
- public TankBehaviour []Finsh;
- public Transform[] FishPos;
- private int _isFunction = 1;
- public Transform startPosition;
- private float distacneToPlayer;
- public GameObject player;
- private bool _IsWhetherToPlayer = true;
- public bool _isVuforia;
- void Start()
- {
-
-
-
-
-
- StartCoroutine(RandomFunction());
-
-
-
- }
-
-
- private int getRangeNum = 0;
- public int GetRangeNum
- {
- get => getRangeNum;
- set
- {
- getRangeNum = value;
- if (getRangeNum == 0)
- {
-
- Group.DOMove(FishPos[0].transform.position, 1f, false);
- }
- else if (getRangeNum == 1)
- {
-
- Group.DOMove(FishPos[1].transform.position, 1f, false);
- }
- else if (getRangeNum == 2)
- {
-
- Group.DOMove(FishPos[2].transform.position, 1f, false);
- }
- if (_IsWhetherToPlayer==true)
- {
- StartCoroutine(FinshPos1(20f)) ;
- _IsWhetherToPlayer = false;
- }
- }
- }
- int rangeRadomNum = 0;
- int numCount = 0;
- int oneType=0;
-
- IEnumerator RandomFunction()
- {
- while (_isFunction == 1)
- {
- if (oneType == 0)
- {
- yield return new WaitForSeconds(0.1f);
- StartCoroutine(SpeedUpFinshMessage(0.1f, 30, 100));
- StartCoroutine(SpeedDownFinshMessage(2f, 9, 40));
- }
- else
- {
- yield return new WaitForSeconds(7f);
- }
- numCount++;
- do
- {
- rangeRadomNum = Random.Range(0, 2);
- }
- while (GetRangeNum == rangeRadomNum);
- GetRangeNum = rangeRadomNum;
- oneType++;
-
- }
-
- while (_isFunction==2)
- {
- yield return new WaitForSeconds(1f);
- distacneToPlayer = Vector3.Distance(Group.transform.position, player.transform.position);
-
- if (distacneToPlayer <= 1.2)
- {
- _IsWhetherToPlayer = true;
- _isFunction = 1;
- StartCoroutine(RandomFunction());
- }
- else
- {
- Group.transform.position = startPosition.position;
- }
- }
- }
- public IEnumerator FinshPos1(float PosNum)
- {
- yield return new WaitForSeconds(PosNum);
- StopAllCoroutines();
- _isFunction = 2;
- StartCoroutine(RandomFunction());
- oneType = 0;
- StartCoroutine(SpeedUpFinshMessage(0.1f, 13, 60)) ;
- StartCoroutine(SpeedDownFinshMessage(2f, 9, 40)) ;
-
- }
-
-
-
-
-
-
-
- public IEnumerator SpeedUpFinshMessage(float deletime ,float Speed, float RotateSpeed )
- {
- yield return new WaitForSeconds(deletime);
- for (int i = 0,count= Finsh.Length; i < count; i++)
- {
- Finsh[i].moveSpeed = Speed+i;
- Finsh[i].rotateSpeed = RotateSpeed+i;
- }
- }
-
-
-
-
-
-
-
- public IEnumerator SpeedDownFinshMessage(float deletime, float Speed, float RotateSpeed)
- {
- yield return new WaitForSeconds(deletime);
- for (int i = 0, count = Finsh.Length; i < count; i++)
- {
- Finsh[i].moveSpeed = Speed + i;
- Finsh[i].rotateSpeed = RotateSpeed + i;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|