GoForward.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using DG.Tweening;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class GoForward : MonoBehaviour
  6. {
  7. [SerializeField]
  8. private float _speed;
  9. [SerializeField]
  10. private bool _limited;
  11. [SerializeField]
  12. private float _maxDist;
  13. private bool _hit;
  14. private float _walked;
  15. // Start is called before the first frame update
  16. void Start()
  17. {
  18. }
  19. // Update is called once per frame
  20. void Update()
  21. {
  22. if (_hit || (_limited && _walked > _maxDist))
  23. {
  24. return;
  25. }
  26. var delta = transform.forward * _speed * Time.deltaTime;
  27. GameController.instance.ReportMove(delta.magnitude);
  28. transform.position += delta;
  29. _walked += delta.magnitude;
  30. }
  31. private void OnTriggerEnter(Collider other)
  32. {
  33. if (other.tag == "CoolDown")
  34. {
  35. _hit = true;
  36. var p = GameController.instance.last;
  37. transform.DOMove(p.camFinish.position, 1f).OnComplete( ()=>
  38. {
  39. p.princessAnimator.SetTrigger("Kiss");
  40. });
  41. }
  42. }
  43. }