Soul.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using UnityEngine;
  5. using uTools;
  6. public class Soul : MonoBehaviour
  7. {
  8. public Rigidbody rb;
  9. public bool collected = false;
  10. public float lerpValue = 0.05f;
  11. public int addMp = 10;
  12. public uTweenPositionTarget tweenPos;
  13. public float flySpeed = 10f;
  14. public void Burst(Vector3 velocity)
  15. {
  16. rb.isKinematic = false;
  17. rb.velocity = velocity;
  18. collected = false;
  19. }
  20. public async void BeCollect()
  21. {
  22. rb.isKinematic = true;
  23. collected = true;
  24. tweenPos.from = transform;
  25. tweenPos.to = PlayerController.instance.transform;
  26. tweenPos.duration = (tweenPos.from.position - tweenPos.to.position).magnitude / flySpeed;
  27. tweenPos.ResetToBeginning();
  28. tweenPos.PlayForward();
  29. await Task.Delay((int)(tweenPos.duration * 1000));
  30. BeGet();
  31. gameObject.SetActive(false);
  32. }
  33. public void BeGet()
  34. {
  35. PlayerController.instance.mp += addMp;
  36. }
  37. }