12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using DG.Tweening;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GoForward : MonoBehaviour
- {
- [SerializeField]
- private float _speed;
- [SerializeField]
- private bool _limited;
- [SerializeField]
- private float _maxDist;
- private bool _hit;
- private float _walked;
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void Update()
- {
- if (_hit || (_limited && _walked > _maxDist))
- {
- return;
- }
- var delta = transform.forward * _speed * Time.deltaTime;
- GameController.instance.ReportMove(delta.magnitude);
- transform.position += delta;
- _walked += delta.magnitude;
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.tag == "CoolDown")
- {
- _hit = true;
- var p = GameController.instance.last;
- transform.DOMove(p.camFinish.position, 1f).OnComplete( ()=>
- {
- p.princessAnimator.SetTrigger("Kiss");
- });
- }
- }
- }
|