using UnityEngine; using Pixelplacement; using System.Collections; using Core; public class PicnicBehaviour : MonoBehaviour { [Header("Random Call Settings")] public float getDistractedMin = 2f; public float getDistractedMax = 5f; public float getFlirtyMin = 1f; public float getFlirtyMax = 3f; private StateMachine stateMachine; private Animator animator; [Header("The FakeChocolate to destroy!")] [SerializeField] private GameObject fakeChocolate; // Assign in Inspector // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { StartCoroutine(StateCycleRoutine()); } void Awake() { stateMachine = GetComponent(); animator = GetComponent(); } private IEnumerator StateCycleRoutine() { while (true) { // Distracted state float distractedWait = Random.Range(getDistractedMin, getDistractedMax); stateMachine.ChangeState("Picnic PPL Distracted"); animator.SetBool("theyDistracted", true); yield return new WaitForSeconds(distractedWait); // Chilling state float chillingWait = Random.Range(getFlirtyMin, getFlirtyMax); stateMachine.ChangeState("Picnic PPL Chilling"); animator.SetBool("theyDistracted", false); yield return new WaitForSeconds(chillingWait); } } public void triedToStealChocolate() { animator.SetTrigger("theyAngry"); //stateMachine.ChangeState("Picnic PPL Angry"); Logging.Debug("Hey! Don't steal my chocolate!"); } public void destroyFakeChocolate() { if (fakeChocolate != null) { Destroy(fakeChocolate); fakeChocolate = null; // Optional: clear reference } } }