PolliwogShot.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using Sirenix.OdinInspector;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class PolliwogShot : SpecialSkills
  6. {
  7. [Header("òòò½Ô¤ÖÆÌå")]
  8. public GameObject fishPrefab;
  9. public int num;
  10. public Transform pos;
  11. private bool isAttack;
  12. private SpineEvent se;
  13. [HideInInspector]
  14. public List<Polliwog> pollis;
  15. //public override void Attack()
  16. //{
  17. // se = owner.GetComponent<Enemy>().spineEvent;
  18. // isAttack = true;
  19. //}
  20. private void shoot()
  21. {
  22. for (int i = 0; i < num; i++)
  23. {
  24. if (PolliwogManager.GetInstance().IsFull()) break;
  25. PoolManager.InstantiateAsync("Prefab/Enemy/Enemy_Polliwog", pos.position, new Quaternion(0, 0, 0, 0), null, obj =>
  26. {
  27. Polliwog pol = obj.GetComponent<Polliwog>();
  28. });
  29. }
  30. }
  31. public void Shoot(int numm, Vector3 poss)
  32. {
  33. pollis = new List<Polliwog>();
  34. for (int i = 0; i < numm; i++)
  35. {
  36. if (PolliwogManager.GetInstance().IsFull()) break;
  37. PoolManager.InstantiateAsync("Prefab/Enemy/Enemy_Polliwog", poss + new Vector3(Random.Range(-3,3), Random.Range(-3, 3), 0), new Quaternion(0, 0, 0, 0), null, obj =>
  38. {
  39. Polliwog pol = obj.GetComponent<Polliwog>();
  40. pollis.Add(pol);
  41. pol.rushDir = (pol.transform.position - poss).normalized;
  42. });
  43. }
  44. }
  45. public void AllPoliDie()
  46. {
  47. for (int i = pollis.Count - 1; i >= 0; i--)
  48. {
  49. Polliwog pol = pollis[i];
  50. if (pol.isDie)
  51. {
  52. pollis.RemoveAt(i);
  53. }
  54. else
  55. {
  56. pol.StartReturn(owner.transform);
  57. }
  58. }
  59. }
  60. private void Update()
  61. {
  62. if (isAttack)
  63. {
  64. if (se && se.isAttackOn)
  65. {
  66. shoot();
  67. se.isAttackOn = false;
  68. isAttack = false;
  69. }
  70. }
  71. }
  72. private void OnTriggerEnter(Collider other)
  73. {
  74. }
  75. }