added ITask
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public enum GameState
|
||||
{
|
||||
@@ -14,7 +16,7 @@ public enum GameState
|
||||
MinigameWon
|
||||
}
|
||||
|
||||
public class ButtonsMinigame : MonoBehaviour
|
||||
public class ButtonsMinigame : MonoBehaviour, ITask
|
||||
{
|
||||
public Light[] lights;
|
||||
public int round = 1;
|
||||
@@ -28,12 +30,23 @@ public class ButtonsMinigame : MonoBehaviour
|
||||
private GameState state = GameState.Idle;
|
||||
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()
|
||||
{
|
||||
sequence.Clear();
|
||||
for (int i = 0; i < round; i++)
|
||||
{
|
||||
int randomButton = Random.Range(0,5);
|
||||
int randomButton = UnityEngine.Random.Range(0,5);
|
||||
sequence.Add(randomButton);
|
||||
}
|
||||
}
|
||||
@@ -106,6 +119,7 @@ public class ButtonsMinigame : MonoBehaviour
|
||||
if (round >= winRound)
|
||||
{
|
||||
SetState(GameState.MinigameWon);
|
||||
Complete();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user