| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using UnityEngine;
- using uTools;
- public class Soul : MonoBehaviour
- {
- public Rigidbody rb;
- public bool collected = false;
- public float lerpValue = 0.05f;
- public int addMp = 10;
- public uTweenPositionTarget tweenPos;
- public float flySpeed = 10f;
- public void Burst(Vector3 velocity)
- {
- rb.isKinematic = false;
- rb.velocity = velocity;
- collected = false;
- }
- public async void BeCollect()
- {
- rb.isKinematic = true;
- collected = true;
- tweenPos.from = transform;
- tweenPos.to = PlayerController.instance.transform;
- tweenPos.duration = (tweenPos.from.position - tweenPos.to.position).magnitude / flySpeed;
- tweenPos.ResetToBeginning();
- tweenPos.PlayForward();
- await Task.Delay((int)(tweenPos.duration * 1000));
- BeGet();
- gameObject.SetActive(false);
- }
- public void BeGet()
- {
- PlayerController.instance.mp += addMp;
- }
- }
|