2025-11-05 13:48:25 +01:00
|
|
|
using Core.SaveLoad;
|
2025-09-24 17:24:51 +02:00
|
|
|
using Pixelplacement;
|
|
|
|
|
using Pixelplacement.TweenSystem;
|
|
|
|
|
using UnityEngine;
|
2025-10-20 21:23:18 +02:00
|
|
|
using UnityEngine.Audio;
|
2025-09-24 17:24:51 +02:00
|
|
|
|
|
|
|
|
public class soundBird_TakeOffBehaviour : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Spline FlightSpline;
|
|
|
|
|
public Transform SoundBirdObject;
|
|
|
|
|
public float flightDuration;
|
|
|
|
|
public float flightDelay;
|
2025-11-05 13:48:25 +01:00
|
|
|
private AppleMachine stateMachine;
|
2025-09-24 17:24:51 +02:00
|
|
|
private Animator animator;
|
|
|
|
|
private TweenBase objectTween;
|
2025-11-04 16:26:33 +01:00
|
|
|
public soundBird_FlyingBehaviour flyingBehaviour;
|
2025-09-24 17:24:51 +02:00
|
|
|
|
2025-10-30 16:31:01 +01:00
|
|
|
public AppleAudioSource audioSource;
|
2025-10-20 21:23:18 +02:00
|
|
|
|
2025-09-24 17:24:51 +02:00
|
|
|
void Awake()
|
|
|
|
|
{
|
2025-11-05 13:48:25 +01:00
|
|
|
stateMachine = GetComponentInParent<AppleMachine>();
|
2025-09-24 17:24:51 +02:00
|
|
|
animator = GetComponentInParent<Animator>();
|
|
|
|
|
}
|
|
|
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
//initiateTweenSpline();
|
|
|
|
|
}
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
animator.SetBool("isScared", true);
|
2025-09-26 15:12:18 +02:00
|
|
|
objectTween = Tween.Spline(FlightSpline, SoundBirdObject, 0, 1, false, flightDuration, flightDelay, Tween.EaseIn, Tween.LoopType.None, HandleTweenStarted, HandleTweenFinished);
|
2025-10-30 16:31:01 +01:00
|
|
|
audioSource.Play(0);
|
2025-09-24 17:24:51 +02:00
|
|
|
}
|
|
|
|
|
void HandleTweenStarted()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void HandleTweenFinished()
|
|
|
|
|
{
|
|
|
|
|
if (SoundBirdObject != null)
|
|
|
|
|
{
|
|
|
|
|
objectTween.Cancel(); // Stop the spline tween for this object
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-14 15:53:58 +02:00
|
|
|
//Logging.Debug("Tween finished!");
|
2025-09-24 17:24:51 +02:00
|
|
|
if (stateMachine != null)
|
|
|
|
|
{
|
|
|
|
|
stateMachine.ChangeState("SoundBirdFlyAround"); // Change to the desired state name
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-04 16:26:33 +01:00
|
|
|
|
|
|
|
|
// Added for cameraSwitcher
|
|
|
|
|
public void StartLanding()
|
|
|
|
|
{
|
|
|
|
|
if (objectTween != null)
|
|
|
|
|
{
|
|
|
|
|
objectTween.Cancel();
|
|
|
|
|
}
|
|
|
|
|
if (stateMachine != null)
|
|
|
|
|
{
|
|
|
|
|
flyingBehaviour.midFlightPosition = SoundBirdObject.position;
|
|
|
|
|
stateMachine.ChangeState("SoundBirdLanding");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-24 17:24:51 +02:00
|
|
|
}
|