Implemented Picnic Logic
(It can use some improvement)
This commit is contained in:
8
Assets/Scripts/DamianExperiments/Picnic.meta
Normal file
8
Assets/Scripts/DamianExperiments/Picnic.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 152828d0655f5c14cae91cf1cf71fd39
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
85
Assets/Scripts/DamianExperiments/Picnic/PicnicBehaviour.cs
Normal file
85
Assets/Scripts/DamianExperiments/Picnic/PicnicBehaviour.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a0d74ee1aa43b54ab5d08005bdd9b16
|
||||
Reference in New Issue
Block a user