Trans_Cook.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Trans_Cook : MonoBehaviour
  5. {
  6. public PlayerController controller;
  7. public float changeTime;
  8. public Vector3 UIoffset; //UIµ÷ÕûÖµ
  9. private Demonic dem;
  10. public float intervalTime; //¹¥»÷Ó²Ö±
  11. private float pastAttackTime;
  12. private bool canAttack = true;
  13. private void Start()
  14. {
  15. controller = GetComponentInParent<PlayerController>();
  16. controller.changeTime = changeTime;
  17. controller.uiHp.transform.position += UIoffset;
  18. controller.uiMp.transform.position += UIoffset;
  19. dem = GetComponent<Demonic>();
  20. }
  21. private void OnDisable()
  22. {
  23. controller.uiHp.transform.position -= UIoffset;
  24. controller.uiMp.transform.position -= UIoffset;
  25. }
  26. private void Update()
  27. {
  28. if (!canAttack)
  29. {
  30. pastAttackTime += Time.deltaTime;
  31. if (pastAttackTime >= intervalTime)
  32. {
  33. canAttack = true;
  34. pastAttackTime = 0;
  35. }
  36. }
  37. if (controller.isinputJ && canAttack)
  38. {
  39. canAttack = false;
  40. controller.isinputJ = false;
  41. dem.Attack2();
  42. }
  43. if (controller.isinputK)
  44. {
  45. controller.isinputK = false;
  46. }
  47. if (controller.isinputL)
  48. {
  49. controller.isinputL = false;
  50. }
  51. }
  52. }