This commit is contained in:
2026-05-31 20:55:36 +02:00
parent 4655e57aaf
commit c78bdc2b2a
42 changed files with 135 additions and 7399 deletions

View File

@@ -3,10 +3,8 @@ using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
<<<<<<< HEAD
using GeoSus.Client;
=======
>>>>>>> origin/main
public class CableMiniGame : MonoBehaviour, ITask
{
@@ -16,31 +14,24 @@ public class CableMiniGame : MonoBehaviour, ITask
public string colorName;
public Button sourceButton;
public Button targetButton;
<<<<<<< HEAD
public Image cableImage;
[HideInInspector] public bool connected;
}
=======
[HideInInspector] public bool connected;
// Line UI
[HideInInspector] public GameObject lineObject;
[HideInInspector] public RectTransform lineRect;
[HideInInspector] public Image lineImage;
}
>>>>>>> origin/main
public string TaskID { get; set; }
public TaskType TaskType { get; set; }
public string TaskName { get; set; }
<<<<<<< HEAD
public Position TaskLocation { get; set; }
=======
public (double, double) TaskLocation { get; set; }
>>>>>>> origin/main
public bool IsCompleted { get; private set; }
private Action<ITask> _onCompleted;
@@ -48,17 +39,7 @@ public class CableMiniGame : MonoBehaviour, ITask
[Header("MiniGame Settings")]
public Cable[] cables;
<<<<<<< HEAD
public string previousSceneName;
public Color wrongAttemptColor = Color.white;
public float blinkDuration = 0.2f;
private string selectedColor = null;
public void Initialize(Action<ITask> onCompleted)
{
=======
public Canvas canvas; // Assign your Canvas here in the inspector
public string previousSceneName;
public Color wrongAttemptColor = Color.white;
@@ -74,20 +55,18 @@ public class CableMiniGame : MonoBehaviour, ITask
public void Initialize(Action<ITask> onCompleted)
{
Debug.Log("[Init] Initializing mini game...");
>>>>>>> origin/main
IsCompleted = false;
_onCompleted = onCompleted;
foreach (var cable in cables)
<<<<<<< HEAD
cable.connected = false;
=======
{
cable.connected = false;
}
PrintAllCableStates("After Initialization");
>>>>>>> origin/main
}
public void Complete()
@@ -95,38 +74,14 @@ public class CableMiniGame : MonoBehaviour, ITask
if (IsCompleted) return;
IsCompleted = true;
<<<<<<< HEAD
=======
Debug.Log("[Complete] Task completed successfully!");
>>>>>>> origin/main
_onCompleted?.Invoke(this);
ExitTask(_onExit);
}
public void ExitTask(Action<ITask> onExit)
{
<<<<<<< HEAD
onExit?.Invoke(this);
}
void Start()
{
foreach (var cable in cables)
{
Cable localCable = cable;
cable.sourceButton.onClick.AddListener(() => OnSourceClicked(localCable));
cable.targetButton.onClick.AddListener(() => OnTargetClicked(localCable));
}
}
void OnSourceClicked(Cable cable)
{
if (cable.connected) return;
selectedColor = cable.colorName;
=======
Debug.Log("[ExitTask] Exiting task...");
onExit?.Invoke(this);
}
@@ -169,21 +124,12 @@ public class CableMiniGame : MonoBehaviour, ITask
selectedColor = cable.colorName;
Debug.Log($"[SourceClick] Selected color set to '{selectedColor}'");
PrintAllCableStates("After Source Click");
>>>>>>> origin/main
}
void OnTargetClicked(Cable cable)
{
<<<<<<< HEAD
if (selectedColor == null || cable.connected)
return;
if (selectedColor == cable.colorName)
{
cable.cableImage.color = GetColorFromName(selectedColor);
cable.connected = true;
=======
Debug.Log($"[TargetClick] Clicked target of cable '{cable.colorName}'");
if (selectedColor == null)
@@ -207,19 +153,12 @@ public class CableMiniGame : MonoBehaviour, ITask
DrawLine(cable);
PrintAllCableStates("After Correct Connection");
>>>>>>> origin/main
CheckCompletion();
}
else
{
<<<<<<< HEAD
StartCoroutine(BlinkAndExit(cable.cableImage));
}
selectedColor = null;
}
=======
Debug.Log($"[TargetClick] Wrong connection attempt! Selected: '{selectedColor}', Target: '{cable.colorName}'");
PrintAllCableStates("Before BlinkAndExit");
StartCoroutine(BlinkAndExit(cable));
@@ -294,20 +233,13 @@ public class CableMiniGame : MonoBehaviour, ITask
// Completion Check
// ------------------------------
>>>>>>> origin/main
void CheckCompletion()
{
foreach (var cable in cables)
{
if (!cable.connected)
<<<<<<< HEAD
return;
}
Complete();
}
=======
{
Debug.Log($"[CheckCompletion] Cable '{cable.colorName}' not yet connected.");
return;
@@ -322,7 +254,7 @@ public class CableMiniGame : MonoBehaviour, ITask
// Helpers
// ------------------------------
>>>>>>> origin/main
Color GetColorFromName(string name)
{
switch (name.ToLower())
@@ -331,27 +263,11 @@ public class CableMiniGame : MonoBehaviour, ITask
case "blue": return Color.blue;
case "green": return Color.green;
case "yellow": return Color.yellow;
<<<<<<< HEAD
case "purple": return new Color(0.5f, 0, 0.5f);
=======
>>>>>>> origin/main
default: return Color.white;
}
}
<<<<<<< HEAD
IEnumerator BlinkAndExit(Image img)
{
Color original = img.color;
img.color = wrongAttemptColor;
yield return new WaitForSeconds(blinkDuration);
img.color = original;
ExitTask(_onExit);
SceneManager.LoadScene(previousSceneName);
=======
IEnumerator BlinkAndExit(Cable cable)
{
if (cable.lineObject == null) CreateLineUI(cable);
@@ -383,6 +299,5 @@ public class CableMiniGame : MonoBehaviour, ITask
states += $"'{cable.colorName}': {(cable.connected ? "Connected" : "Not Connected")}, ";
}
Debug.Log(states.TrimEnd(' ', ','));
>>>>>>> origin/main
}
}