Added anim placeholders for the worker belt animation
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
|
||||
public class WorkerBeltApproachingBehaviour : AppleState
|
||||
{
|
||||
public Spline ApproachingSpline;
|
||||
public Transform workerObjectTransform;
|
||||
public float approachduration;
|
||||
public float approachDelay;
|
||||
|
||||
//References to the Worker Gameobject
|
||||
public GameObject workerBeltObject;
|
||||
public Animator workerAnimator;
|
||||
public WorkerBeltRoamingBehaviour workerBeltRoamingRef;
|
||||
private TweenBase aproachTween;
|
||||
public AppleMachine workerBeltStateMAchineRef;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
|
||||
Transform anchorB = transform.Find("AnchorA");
|
||||
if (anchorB != null)
|
||||
{
|
||||
anchorB.position = workerBeltRoamingRef.midRoamPosition;
|
||||
}
|
||||
|
||||
Debug.Log("Entered Worker Belt Approaching State");
|
||||
if (ApproachingSpline == null || workerObjectTransform == null)
|
||||
{
|
||||
Debug.LogWarning("WorkerBeltApproachingBehaviour: ApproachingSpline or workerObjectTransform is not assigned.", this);
|
||||
return;
|
||||
}
|
||||
// Start the tween to move the worker along the approaching spline
|
||||
aproachTween = Tween.Spline(
|
||||
ApproachingSpline,
|
||||
workerObjectTransform,
|
||||
0, 1,
|
||||
false,
|
||||
approachduration,
|
||||
approachDelay,
|
||||
Tween.EaseLinear,
|
||||
Tween.LoopType.None,
|
||||
HandleApproachStarted, // optional
|
||||
HandleApproachFinished // called when spline completes
|
||||
);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Debug.Log("Exited Worker Belt Approaching State");
|
||||
}
|
||||
|
||||
// callback implementations
|
||||
void HandleApproachStarted()
|
||||
{
|
||||
// optional: play audio/anim etc.
|
||||
}
|
||||
|
||||
void HandleApproachFinished()
|
||||
{
|
||||
Debug.Log("Approach tween finished");
|
||||
// cleanup
|
||||
aproachTween?.Stop();
|
||||
workerAnimator.SetBool("isLifting?", true);
|
||||
workerBeltStateMAchineRef.ChangeState(2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91332c6209dd81042b43f3d809fb8fe0
|
||||
@@ -0,0 +1,44 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
|
||||
public class WorkerBeltRoamingBehaviour : AppleState
|
||||
{
|
||||
public Spline RoamingSpline;
|
||||
public Transform workerObjectTransform;
|
||||
public float roamDuration;
|
||||
public float roamDelay;
|
||||
|
||||
//References to the Worker Gameobject
|
||||
public GameObject workerBeltObject;
|
||||
public Animator workerAnimator;
|
||||
public Vector3 midRoamPosition;
|
||||
|
||||
// Reference to the active spline tween so we can pause/stop it
|
||||
private TweenBase roamingTween;
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
workerAnimator.SetBool("isLifting?", false);
|
||||
Debug.Log("Entered Worker Belt Roaming State");
|
||||
|
||||
if (RoamingSpline == null || workerObjectTransform == null)
|
||||
{
|
||||
Debug.LogWarning("WorkerBeltRoamingBehaviour: RoamingSpline or workerObjectTransform is not assigned.", this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the returned TweenBase so we can control it later
|
||||
roamingTween = Tween.Spline(RoamingSpline, workerObjectTransform, 0, 1, false, roamDuration, roamDelay, Tween.EaseLinear, Tween.LoopType.Loop);
|
||||
}
|
||||
|
||||
// Also stop the tween if the GameObject is disabled for any reason (covers StateMachine deactivation)
|
||||
void OnDisable()
|
||||
{
|
||||
midRoamPosition = workerObjectTransform.position;
|
||||
Debug.Log("WorkerBeltRoamingBehaviour: OnExitState - stopping roaming tween" + midRoamPosition);
|
||||
roamingTween?.Stop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a56c71f58f682734187995e25bf53ff9
|
||||
@@ -0,0 +1,76 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
|
||||
public class WorkerBeltReturningBehaviour : AppleState
|
||||
{
|
||||
public Spline ReturningSpline;
|
||||
public Transform workerObjectTransform;
|
||||
public float returnduration;
|
||||
public float returnDelay;
|
||||
|
||||
|
||||
public GameObject workerBeltObject;
|
||||
public Animator workerAnimator;
|
||||
private TweenBase returnTween;
|
||||
public AppleMachine workerBeltStateMAchineRef;
|
||||
public Transform StartingAnchor;
|
||||
public Transform EndingAnchor;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Transform anchorA = transform.Find("AnchorA");
|
||||
if (anchorA != null)
|
||||
{
|
||||
anchorA.position = StartingAnchor.position;
|
||||
}
|
||||
Transform anchorB = transform.Find("AnchorB");
|
||||
if (anchorB != null)
|
||||
{
|
||||
anchorB.position = EndingAnchor.position;
|
||||
}
|
||||
workerAnimator.SetBool("isLifting?", false);
|
||||
|
||||
Debug.Log("Entered Worker Belt Returning State");
|
||||
if (ReturningSpline == null || workerObjectTransform == null)
|
||||
{
|
||||
Debug.LogWarning("WorkerBeltApproachingBehaviour: ApproachingSpline or workerObjectTransform is not assigned.", this);
|
||||
return;
|
||||
}
|
||||
// Start the tween to move the worker along the approaching spline
|
||||
returnTween = Tween.Spline(
|
||||
ReturningSpline,
|
||||
workerObjectTransform,
|
||||
0, 1,
|
||||
false,
|
||||
returnduration,
|
||||
returnDelay,
|
||||
Tween.EaseLinear,
|
||||
Tween.LoopType.None,
|
||||
HandleApproachStarted, // optional
|
||||
HandleApproachFinished // called when spline completes
|
||||
);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Debug.Log("Exited Worker Belt Returning State");
|
||||
}
|
||||
|
||||
// callback implementations
|
||||
void HandleApproachStarted()
|
||||
{
|
||||
// optional: play audio/anim etc.
|
||||
}
|
||||
|
||||
void HandleApproachFinished()
|
||||
{
|
||||
|
||||
Debug.Log("Return tween finished");
|
||||
// cleanup
|
||||
returnTween?.Stop();
|
||||
workerBeltStateMAchineRef.ChangeState(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d61b4497a5a14d42a04675ed619b560
|
||||
Reference in New Issue
Block a user