Worker barely working
This commit is contained in:
@@ -2,6 +2,7 @@ using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using Pixelplacement;
|
||||
using Pixelplacement.TweenSystem;
|
||||
using System.Collections;
|
||||
|
||||
public class WorkerBeltRoamingBehaviour : AppleState
|
||||
{
|
||||
@@ -9,6 +10,9 @@ public class WorkerBeltRoamingBehaviour : AppleState
|
||||
public Transform workerObjectTransform;
|
||||
public float roamDuration;
|
||||
public float roamDelay;
|
||||
public bool walkingRight;
|
||||
public bool pantsLess;
|
||||
public Coroutine pantsRoutine;
|
||||
|
||||
//References to the Worker Gameobject
|
||||
public GameObject workerBeltObject;
|
||||
@@ -32,6 +36,11 @@ public class WorkerBeltRoamingBehaviour : AppleState
|
||||
|
||||
// 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);
|
||||
|
||||
if (pantsLess)
|
||||
{
|
||||
pantsRoutine = StartCoroutine(RandomFallChance());
|
||||
}
|
||||
}
|
||||
|
||||
// Also stop the tween if the GameObject is disabled for any reason (covers StateMachine deactivation)
|
||||
@@ -41,4 +50,40 @@ public class WorkerBeltRoamingBehaviour : AppleState
|
||||
Debug.Log("WorkerBeltRoamingBehaviour: OnExitState - stopping roaming tween" + midRoamPosition);
|
||||
roamingTween?.Stop();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (RoamingSpline.GetDirection(roamingTween.Percentage).x > 0.1)
|
||||
workerAnimator.SetBool("walkingRight?", true);
|
||||
else
|
||||
workerAnimator.SetBool("walkingRight?", false);
|
||||
}
|
||||
|
||||
IEnumerator RandomFallChance()
|
||||
{
|
||||
while (pantsLess)
|
||||
yield return new WaitForSeconds(2);
|
||||
CheckForFall();
|
||||
|
||||
}
|
||||
|
||||
public void CheckForFall()
|
||||
{
|
||||
int _randNumber;
|
||||
_randNumber = Random.Range(0, 1);
|
||||
|
||||
if (_randNumber > 5)
|
||||
{
|
||||
workerAnimator.SetTrigger("shouldFall?");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (pantsRoutine != null)
|
||||
{
|
||||
StopCoroutine(pantsRoutine);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user