Made Changes To slotted items (not fully functional but progressing)
Added Unity events to the Slotting Items, the eyes react fine but sometimes they fuck up. gonna check that out later.
This commit is contained in:
@@ -15,19 +15,23 @@ public class BirdEyesBehavior : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CorrectItem()
|
||||
public void CorrectItem()
|
||||
{
|
||||
animator.SetTrigger("RightGuess");
|
||||
}
|
||||
|
||||
void IncorrectItem()
|
||||
public void IncorrectItem()
|
||||
{
|
||||
animator.SetTrigger("WrongGuess");
|
||||
animator.SetTrigger("WrongGuess");
|
||||
}
|
||||
void BirdReveal()
|
||||
public void NoItem()
|
||||
{
|
||||
animator.SetTrigger("NoGuess");
|
||||
}
|
||||
public void BirdReveal()
|
||||
{
|
||||
statemachine.ChangeState ("BirdSpawned");
|
||||
}
|
||||
|
||||
@@ -2,23 +2,39 @@ using UnityEngine;
|
||||
|
||||
public class Distancemeasurer : MonoBehaviour
|
||||
{
|
||||
public float playerDistanceToChange;
|
||||
public float playerDistanceFar;
|
||||
public float playerDistanceClose;
|
||||
public BirdEyesBehavior birdEyes;
|
||||
private Vector2 eyesPosition;
|
||||
private Vector2 playerPosition;
|
||||
private float distance;
|
||||
private GameObject player;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
eyesPosition = transform.position;
|
||||
playerPosition = transform.position;
|
||||
player = GameObject.FindWithTag("Player");
|
||||
playerPosition = player.transform.position;
|
||||
distance = Vector2.Distance(eyesPosition, playerPosition);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
playerPosition = player.transform.position;
|
||||
distance = Vector2.Distance(eyesPosition, playerPosition);
|
||||
Debug.Log("Distance to player: " + distance);
|
||||
if (distance > playerDistanceFar)
|
||||
{
|
||||
birdEyes.NoItem();
|
||||
} else if (distance > playerDistanceClose)
|
||||
{
|
||||
birdEyes.IncorrectItem();
|
||||
} else
|
||||
{
|
||||
birdEyes.CorrectItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
16
Assets/Scripts/DamianExperiments/ItemJudgement.cs
Normal file
16
Assets/Scripts/DamianExperiments/ItemJudgement.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ItemJudgement : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/DamianExperiments/ItemJudgement.cs.meta
Normal file
2
Assets/Scripts/DamianExperiments/ItemJudgement.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 166b84cf50de17846bceb3635482f612
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Interactions
|
||||
{
|
||||
@@ -9,6 +10,11 @@ namespace Interactions
|
||||
[RequireComponent(typeof(Interactable))]
|
||||
public class ItemSlot : Pickup
|
||||
{
|
||||
public UnityEvent onItemSlotted;
|
||||
public UnityEvent onItemSlotRemoved;
|
||||
public UnityEvent onCorrectItemSlotted;
|
||||
public UnityEvent onIncorrectItemSlotted;
|
||||
public UnityEvent onForbiddenItemSlotted;
|
||||
private PickupItemData _currentlySlottedItemData;
|
||||
public SpriteRenderer slottedItemRenderer;
|
||||
private GameObject _currentlySlottedItemObject = null;
|
||||
@@ -44,6 +50,7 @@ namespace Interactions
|
||||
FollowerController.TryPickupItem(_currentlySlottedItemObject, _currentlySlottedItemData);
|
||||
_currentlySlottedItemObject = null;
|
||||
_currentlySlottedItemData = null;
|
||||
onItemSlotRemoved?.Invoke();
|
||||
UpdateSlottedSprite();
|
||||
return;
|
||||
}
|
||||
@@ -72,6 +79,7 @@ namespace Interactions
|
||||
if (forbidden.Contains(heldItemData))
|
||||
{
|
||||
DebugUIMessage.Show("Can't place that here.");
|
||||
onForbiddenItemSlotted?.Invoke();
|
||||
Interactable.BroadcastInteractionComplete(false);
|
||||
return;
|
||||
}
|
||||
@@ -79,12 +87,14 @@ namespace Interactions
|
||||
SlotItem(heldItemObj, heldItemData);
|
||||
if (allowed.Contains(heldItemData))
|
||||
{
|
||||
onCorrectItemSlotted?.Invoke();
|
||||
Interactable.BroadcastInteractionComplete(true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUIMessage.Show("I'm not sure this works.");
|
||||
onIncorrectItemSlotted?.Invoke();
|
||||
Interactable.BroadcastInteractionComplete(false);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user