Added Bird Spawning and Copied behaviour for the hammer bird
This commit is contained in:
@@ -5,6 +5,7 @@ public class BirdEyesBehavior : MonoBehaviour
|
||||
{
|
||||
private StateMachine statemachine;
|
||||
private Animator animator;
|
||||
public bool correctItemIsIn;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
@@ -20,11 +21,13 @@ public class BirdEyesBehavior : MonoBehaviour
|
||||
|
||||
public void CorrectItem()
|
||||
{
|
||||
correctItemIsIn = true;
|
||||
animator.SetTrigger("RightGuess");
|
||||
}
|
||||
|
||||
public void IncorrectItem()
|
||||
{
|
||||
correctItemIsIn = false;
|
||||
animator.SetTrigger("WrongGuess");
|
||||
}
|
||||
public void NoItem()
|
||||
|
||||
@@ -2,10 +2,9 @@ using UnityEngine;
|
||||
|
||||
public class Distancemeasurer : MonoBehaviour
|
||||
{
|
||||
public float playerDistanceFar;
|
||||
public float playerDistanceClose;
|
||||
public float playerToPlaceDistance;
|
||||
public BirdEyesBehavior birdEyes;
|
||||
private Vector2 eyesPosition;
|
||||
private Vector2 placePosition;
|
||||
private Vector2 playerPosition;
|
||||
private float distance;
|
||||
private GameObject player;
|
||||
@@ -13,28 +12,23 @@ public class Distancemeasurer : MonoBehaviour
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
eyesPosition = transform.position;
|
||||
placePosition = transform.position;
|
||||
player = GameObject.FindWithTag("Player");
|
||||
playerPosition = player.transform.position;
|
||||
distance = Vector2.Distance(eyesPosition, playerPosition);
|
||||
distance = Vector2.Distance(placePosition, playerPosition);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
// TODO: Make this less expensive by not doing it every frame
|
||||
void Update()
|
||||
{
|
||||
playerPosition = player.transform.position;
|
||||
distance = Vector2.Distance(eyesPosition, playerPosition);
|
||||
Debug.Log("Distance to player: " + distance);
|
||||
if (distance > playerDistanceFar)
|
||||
distance = Vector2.Distance(placePosition, playerPosition);
|
||||
//Debug.Log("Distance to player: " + distance);
|
||||
if (distance > playerToPlaceDistance && birdEyes.correctItemIsIn == true)
|
||||
{
|
||||
birdEyes.NoItem();
|
||||
} else if (distance > playerDistanceClose)
|
||||
{
|
||||
birdEyes.IncorrectItem();
|
||||
} else
|
||||
{
|
||||
birdEyes.CorrectItem();
|
||||
}
|
||||
birdEyes.BirdReveal();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user