| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using Sirenix.OdinInspector;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PolliwogShot : SpecialSkills
- {
- [Header("òòò½Ô¤ÖÆÌå")]
- public GameObject fishPrefab;
- public Vector2 groupCenter { get; set; }
- private float lastUpdateCenterTime;
- private Vector2 groupVelocity;
- private float lastUpdateVelocityTime;
- public int num;
- public override void Attack()
- {
- for (int i = 0; i < num; i++)
- {
- if(PolliwogManager.GetInstance().IsFull()) continue;
- PoolManager.InstantiateAsync("Prefab/Enemy/Enemy_Polliwog", transform.position + new Vector3(Random.Range(-5, 5), Random.Range(-5, 5), 0));
- }
- }
- public void Attack(int num, Vector3 pos)
- {
- for (int i = 0; i < num; i++)
- {
- if (PolliwogManager.GetInstance().IsFull()) continue;
- PoolManager.InstantiateAsync("Prefab/Enemy/Enemy_Polliwog", pos, new Quaternion(0, 0, 0, 0), null, obj =>
- {
- Polliwog pol = obj.GetComponent<Polliwog>();
- });
- }
- }
- public Vector3 UpdateGroupCenter()
- {
- if (Time.time - lastUpdateCenterTime < 0.1f) return groupCenter;
- lastUpdateCenterTime = Time.time;
- groupCenter = Vector2.zero;
- foreach (Polliwog pol in PolliwogManager.GetInstance().list)
- {
- groupCenter += (Vector2)transform.position;
- }
- groupCenter /= PolliwogManager.GetInstance().list.Count;
- return groupCenter;
- }
- public Vector2 UpdateGroupVelocity()
- {
- if (Time.time - lastUpdateVelocityTime < 0.1f) return groupVelocity;
- lastUpdateVelocityTime = Time.time;
- groupVelocity = Vector2.zero;
- foreach (Polliwog pol in PolliwogManager.GetInstance().list)
- {
- groupVelocity += pol.currentVelocity;
- }
- groupVelocity /= PolliwogManager.GetInstance().list.Count;
- return groupVelocity;
- }
- }
|