WavePowerSkill.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WavePowerSkill : MonoBehaviour
  5. {
  6. public Vector3 force;
  7. private int fx = 1;
  8. private Vector3 curForce;
  9. public int damage;
  10. public float continueTime;
  11. public int cacheID;
  12. public PlayerController pc;
  13. private void Update()
  14. {
  15. continueTime -= Time.deltaTime;
  16. if (continueTime <= 0)
  17. {
  18. pc.conductCanRelease[cacheID] = true;
  19. gameObject.SetActive(false);
  20. }
  21. }
  22. private void OnTriggerEnter(Collider other)
  23. {
  24. if (other.gameObject.layer == 8)
  25. {
  26. if (other.gameObject.transform.position.x >= transform.position.x)
  27. {
  28. fx = 1;
  29. }
  30. else
  31. {
  32. fx = -1;
  33. }
  34. curForce = force;
  35. curForce.x = curForce.x * fx;
  36. other.GetComponentInParent<Enemy>().ChangeState(CharacterState.Weak);
  37. other.GetComponentInParent<Enemy>().wallDamage = damage;
  38. other.GetComponentInParent<Rigidbody>().AddForce(curForce);
  39. }
  40. }
  41. }