Skip to content

Instantly share code, notes, and snippets.

@markdekuijer
Created December 1, 2019 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markdekuijer/91ae7162400b2c1846a3858af06fa4e3 to your computer and use it in GitHub Desktop.
Save markdekuijer/91ae7162400b2c1846a3858af06fa4e3 to your computer and use it in GitHub Desktop.
public class Sequence : MonoBehaviour
{
public BuildSequenceData BuildData => buildData;
public Sprite SequenceExplainer => sequenceExplainer;
public Action OnSequenceComplete;
[SerializeField] private Sprite sequenceExplainer;
[SerializeField] private BuildSequenceData buildData;
[SerializeField] private GameObject screwSet;
private TaskSequence[] taskSequences;
private int currentCompletedSequences;
public void StartLoadSequence()
{
screwSet.transform.position = new Vector3(2.59f, 0.761f, 0.324f);
taskSequences = GetComponentsInChildren<TaskSequence>();
foreach (TaskSequence tasks in taskSequences)
{
tasks.OnCompleted += TaskSequenceComplete;
tasks.LoadSequence();
}
}
private void TaskSequenceComplete(TaskSequence completedSequence)
{
currentCompletedSequences++;
completedSequence.OnCompleted -= TaskSequenceComplete;
if (currentCompletedSequences >= taskSequences.Length)
{
OnSequenceComplete?.Invoke();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment