2025-09-10 22:17:51 +02:00
|
|
|
using UnityEngine;
|
|
|
|
|
using Pixelplacement;
|
2025-09-19 15:51:50 +02:00
|
|
|
using Pixelplacement.TweenSystem;
|
2025-09-10 22:17:51 +02:00
|
|
|
|
|
|
|
|
public class GardenerChaseBehavior : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Spline ChaseSpline;
|
|
|
|
|
public Transform GardenerObject;
|
|
|
|
|
public float chaseDuration;
|
|
|
|
|
public float chaseDelay;
|
2025-09-19 15:51:50 +02:00
|
|
|
[SerializeField] private Animator animator;
|
|
|
|
|
[SerializeField] public GameObject lawnMowerRef;
|
|
|
|
|
private TweenBase tweenRef;
|
2025-09-10 22:17:51 +02:00
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2025-09-19 15:51:50 +02:00
|
|
|
tweenRef = Tween.Spline (ChaseSpline, GardenerObject, 0, 1, false, chaseDuration, chaseDelay, Tween.EaseLinear, Tween.LoopType.None, HandleTweenStarted, HandleTweenFinished);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HandleTweenFinished ()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//Debug.Log ("Tween finished!");
|
|
|
|
|
tweenRef.Stop();
|
|
|
|
|
Destroy(ChaseSpline);
|
|
|
|
|
var gardenerSpriteRef = gameObject.transform.Find("GardenerRunningSprite");
|
|
|
|
|
gardenerSpriteRef.transform.SetParent(lawnMowerRef.transform, true);
|
2025-09-19 16:06:15 +02:00
|
|
|
|
2025-09-19 15:51:50 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void HandleTweenStarted ()
|
|
|
|
|
{
|
|
|
|
|
//Debug.Log ("Tween started!");
|
|
|
|
|
animator.SetBool("IsIdle?", false);
|
2025-09-10 22:17:51 +02:00
|
|
|
}
|
|
|
|
|
}
|