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:
2025-09-11 17:03:56 +02:00
parent 15b8146815
commit 9b590ca6ec
15 changed files with 455 additions and 409 deletions

View File

@@ -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");
}

View File

@@ -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();
}
}

View 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()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 166b84cf50de17846bceb3635482f612

View File

@@ -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;
}