ChildChipExplosion.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using UnityEngine;
  3. public class ChildChipExplosion : BaseBehaviour
  4. {
  5. private float deltaTime
  6. {
  7. get
  8. {
  9. return Time.time - this.startTime;
  10. }
  11. }
  12. private void OnEnable()
  13. {
  14. this.startTime = Time.time;
  15. this.backToPlayer = false;
  16. this.player = R.Player.Transform;
  17. base.transform.GetChild(0).gameObject.SetActive(true);
  18. }
  19. private void Update()
  20. {
  21. if (this.backToPlayer)
  22. {
  23. base.transform.position = Vector3.MoveTowards(base.transform.position, this.player.position + new Vector3(0f, 1.2f, 0f), 0.5f * this.playerChargingSpeed * this.deltaTime);
  24. if (Vector3.Distance(base.transform.position, this.player.position + new Vector3(0f, 1.2f, 0f)) < 0.1f)
  25. {
  26. R.Player.Action.AbsorbEnergyBall();
  27. this.backToPlayer = false;
  28. base.StartCoroutine(this.player.GetComponent<ChangeSpineColor>().EnergyBallColorChange());
  29. base.transform.GetChild(0).gameObject.SetActive(false);
  30. }
  31. }
  32. }
  33. public bool backToPlayer;
  34. public Transform player;
  35. private float startTime;
  36. private float playerChargingSpeed = 20f;
  37. }