Created new minigame Buttons, Added base assets + all on canvas, Added lights for glow effect

This commit is contained in:
2026-05-19 23:06:07 +02:00
parent bca7c930c2
commit 9455cdb4e6
97 changed files with 1770 additions and 9287 deletions

View File

@@ -1,98 +0,0 @@
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class DraggableKey : MonoBehaviour,
IBeginDragHandler, IDragHandler, IEndDragHandler, ITask
{
[Header("Key Settings")]
public string keyID;
public string correctSlotID;
public string previousSceneName;
[Header("Visual")]
public Color wrongAttemptColor = Color.red;
public float blinkDuration = 0.2f;
private RectTransform rectTransform;
private CanvasGroup canvasGroup;
private Vector2 startPosition;
private bool isOverCorrectSlot = false;
public string TaskID { get; set; }
public TaskType TaskType { get; set; }
public string TaskName { get; set; }
public (double, double) TaskLocation { get; set; }
public bool IsCompleted { get; private set; }
private Action<ITask> _onCompleted;
private Action<ITask> _onExit;
public void Initialize(Action<ITask> onCompleted)
{
IsCompleted = false;
_onCompleted = onCompleted;
}
public void Complete()
{
if (IsCompleted) return;
IsCompleted = true;
_onCompleted?.Invoke(this);
ExitTask(_onExit);
}
public void ExitTask(Action<ITask> onExit)
{
onExit?.Invoke(this);
}
// ===== UNITY =====
private void Awake()
{
rectTransform = GetComponent<RectTransform>();
canvasGroup = GetComponent<CanvasGroup>();
}
public void OnBeginDrag(PointerEventData eventData)
{
startPosition = rectTransform.anchoredPosition;
canvasGroup.blocksRaycasts = false;
}
public void OnDrag(PointerEventData eventData)
{
rectTransform.anchoredPosition += eventData.delta;
}
public void OnEndDrag(PointerEventData eventData)
{
canvasGroup.blocksRaycasts = true;
if (isOverCorrectSlot)
{
Complete();
}
}
public void SetSlotMatch(bool value)
{
isOverCorrectSlot = value;
}
void ResetPosition()
{
rectTransform.anchoredPosition = startPosition;
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 21dc5fa96a2ceec428d7b0332e55cbe5

View File

@@ -1,28 +0,0 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
public class KeySlot : MonoBehaviour, IDropHandler
{
public string correctKeyID;
public void OnDrop(PointerEventData eventData)
{
DraggableKey key = eventData.pointerDrag.GetComponent<DraggableKey>();
if (key != null)
{
if (key.keyID == correctKeyID)
{
key.transform.position = transform.position;
key.enabled = false;
KeyminigameManager.Instance.CheckWin();
}
else
{
KeyminigameManager.Instance.Fail();
}
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 4f5eef97f16bb6b47ba88f96f9d051e9

View File

@@ -1,30 +0,0 @@
using UnityEngine;
using UnityEngine.SceneManagement;
public class KeyminigameManager : MonoBehaviour
{
public static KeyminigameManager Instance;
private int correctCount = 0;
public int totalKeys = 3;
private void Awake()
{
Instance = this;
}
public void CheckWin()
{
correctCount++;
if (correctCount >= totalKeys)
{
Debug.Log("WIN");
}
}
public void Fail()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 0ef083a6749a8ce459b724dafa1eb08f