ButtonsMemoryMinigame #28
@@ -1,9 +1,11 @@
|
|||||||
using UnityEngine;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
|
||||||
using System.Data.SqlTypes;
|
using System.Data.SqlTypes;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TMPro;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
public enum GameState
|
public enum GameState
|
||||||
{
|
{
|
||||||
@@ -14,7 +16,7 @@ public enum GameState
|
|||||||
MinigameWon
|
MinigameWon
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ButtonsMinigame : MonoBehaviour
|
public class ButtonsMinigame : MonoBehaviour, ITask
|
||||||
{
|
{
|
||||||
public Light[] lights;
|
public Light[] lights;
|
||||||
public int round = 1;
|
public int round = 1;
|
||||||
@@ -28,12 +30,23 @@ public class ButtonsMinigame : MonoBehaviour
|
|||||||
private GameState state = GameState.Idle;
|
private GameState state = GameState.Idle;
|
||||||
private List<int> sequence = new List<int>();
|
private List<int> sequence = new List<int>();
|
||||||
|
|
||||||
|
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 System.Action<ITask> _onComplete;
|
||||||
|
private Action<ITask> _onExit;
|
||||||
void GenerateSequence()
|
void GenerateSequence()
|
||||||
{
|
{
|
||||||
sequence.Clear();
|
sequence.Clear();
|
||||||
for (int i = 0; i < round; i++)
|
for (int i = 0; i < round; i++)
|
||||||
{
|
{
|
||||||
int randomButton = Random.Range(0,5);
|
int randomButton = UnityEngine.Random.Range(0,5);
|
||||||
sequence.Add(randomButton);
|
sequence.Add(randomButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,6 +119,7 @@ public class ButtonsMinigame : MonoBehaviour
|
|||||||
if (round >= winRound)
|
if (round >= winRound)
|
||||||
{
|
{
|
||||||
SetState(GameState.MinigameWon);
|
SetState(GameState.MinigameWon);
|
||||||
|
Complete();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -123,4 +137,18 @@ public class ButtonsMinigame : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Initialize(System.Action<ITask> onCompleted)
|
||||||
|
{
|
||||||
|
_onComplete = onCompleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ExitTask(System.Action<ITask> onExit)
|
||||||
|
{
|
||||||
|
onExit.Invoke(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Complete()
|
||||||
|
{
|
||||||
|
_onComplete?.Invoke(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<Solution>
|
|
||||||
<Project Path="Assembly-CSharp.csproj" />
|
|
||||||
</Solution>
|
|
||||||
Reference in New Issue
Block a user