Working gardener saveable behavior tree
This commit is contained in:
@@ -1,21 +1,15 @@
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Core;
|
||||
using Core.SaveLoad;
|
||||
using Pixelplacement;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class GardenerBehaviour : MonoBehaviour
|
||||
public class GardenerBehaviour : SaveableStateMachine
|
||||
{
|
||||
private StateMachine stateMachineRef;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
stateMachineRef = GetComponent<StateMachine>();
|
||||
}
|
||||
|
||||
public void stateSwitch (string StateName)
|
||||
{
|
||||
Logging.Debug("State Switch to: " + StateName);
|
||||
stateMachineRef.ChangeState(StateName);
|
||||
ChangeState(StateName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using Core.SaveLoad;
|
||||
using Pixelplacement;
|
||||
|
||||
public class LawnMowerBehaviour : MonoBehaviour
|
||||
public class LawnMowerBehaviour : SaveableStateMachine
|
||||
{
|
||||
private StateMachine stateMachineRef;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
stateMachineRef = GetComponent<StateMachine>();
|
||||
}
|
||||
|
||||
public void mowerTouched()
|
||||
{
|
||||
Logging.Debug("Mower Touched");
|
||||
@@ -20,6 +12,6 @@ public class LawnMowerBehaviour : MonoBehaviour
|
||||
public void stateSwitch(string StateName)
|
||||
{
|
||||
Logging.Debug("State Switch to: " + StateName);
|
||||
stateMachineRef.ChangeState(StateName);
|
||||
ChangeState(StateName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using Core.SaveLoad;
|
||||
using UnityEngine;
|
||||
using Pixelplacement;
|
||||
|
||||
public class LawnMowerChaseBehaviour : MonoBehaviour
|
||||
public class LawnMowerChaseBehaviour : SaveableState
|
||||
{
|
||||
public Spline ChaseSpline;
|
||||
public Transform LawnMowerObject;
|
||||
@@ -23,7 +24,7 @@ public class LawnMowerChaseBehaviour : MonoBehaviour
|
||||
public bool gardenerChasing = true;
|
||||
public GardenerAudioController gardenerAudioController;
|
||||
|
||||
void Start()
|
||||
public override void OnEnterState()
|
||||
{
|
||||
LawnMowerObject.position = ChaseSpline.GetPosition(startPercentage);
|
||||
|
||||
@@ -66,6 +67,11 @@ public class LawnMowerChaseBehaviour : MonoBehaviour
|
||||
_initialTweenActive = true;
|
||||
}
|
||||
|
||||
public override void OnRestoreState(string data)
|
||||
{
|
||||
OnEnterState();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float percentage = ChaseSpline.ClosestPoint(LawnMowerObject.position);
|
||||
|
||||
Reference in New Issue
Block a user