IceRainController.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class IceRainController : MonoBehaviour
  5. {
  6. public GameObject sword;
  7. public PlayerController owner;
  8. public int swordsNum;
  9. public float totalTime;
  10. private float interval;
  11. public int damage;
  12. public Vector2 PosRangeX;
  13. public bool start;
  14. public float time;
  15. public int num;
  16. public float height;
  17. public void Update()
  18. {
  19. if (!start) return;
  20. time -= Time.deltaTime;
  21. if(time < 0)
  22. {
  23. GameObject obj = PoolManager.Instantiate(sword);
  24. owner.attackController.curAttackMethod.attackInfo.damage = damage;
  25. owner.attackController.curAttackMethod.attackInfo.attackMethod_Type = AttackMethod_Type.Attack_Summon;
  26. Vector3 targetPos = new Vector3(Random.Range(PosRangeX.x,PosRangeX.y), 0, 0);
  27. if (owner.bodyTrans.localScale.x >= 0)
  28. {
  29. targetPos = owner.transform.position - targetPos;
  30. }
  31. else
  32. {
  33. targetPos = owner.transform.position - targetPos;
  34. }
  35. targetPos.y = height;
  36. obj.GetComponent<Bullet>().BeShoot(owner, targetPos, Vector3.down, false);
  37. num++;
  38. time = interval;
  39. if(num >= swordsNum)
  40. {
  41. start = false;
  42. gameObject.SetActive(false);
  43. }
  44. }
  45. }
  46. public void Biu()
  47. {
  48. time = 0;
  49. num = 0;
  50. interval = totalTime / swordsNum;
  51. start = true;
  52. }
  53. }