Files
AppleHillsProduction/Assets/Scripts/DamianExperiments/Picnic/PicnicBehaviour.cs
DamianCorazza fb24537daf Implemented Picnic Logic
(It can use some improvement)
2025-09-30 15:52:37 +02:00

86 lines
2.2 KiB
C#

using UnityEngine;
using Pixelplacement;
using System.Collections;
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(RandomFirstMethodRoutine());
}
void Awake()
{
stateMachine = GetComponent<StateMachine>();
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
}
private IEnumerator RandomFirstMethodRoutine()
{
while (true)
{
float waitTime = Random.Range(getDistractedMin, getDistractedMax);
yield return new WaitForSeconds(waitTime);
FirstMethod();
}
}
private void FirstMethod()
{
Debug.Log("First method called!");
stateMachine.ChangeState("Picnic PPL Distracted");
animator.SetBool("theyDistracted", true);
StartCoroutine(RandomSecondMethodRoutine());
}
private IEnumerator RandomSecondMethodRoutine()
{
float waitTime = Random.Range(getFlirtyMin, getFlirtyMax);
yield return new WaitForSeconds(waitTime);
SecondMethod();
}
private void SecondMethod()
{
Debug.Log("Second method called!");
stateMachine.ChangeState("Picnic PPL Chilling");
animator.SetBool("theyDistracted", false);
}
public void triedToStealChocolate()
{
animator.SetTrigger("theyAngry");
//stateMachine.ChangeState("Picnic PPL Angry");
Debug.Log("Hey! Don't steal my chocolate!");
}
public void destroyFakeChocolate()
{
if (fakeChocolate != null)
{
Destroy(fakeChocolate);
fakeChocolate = null; // Optional: clear reference
}
}
}