Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
TaskSequence.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
5 using UnityEngine;
6 
7 namespace droid.Runtime.Prototyping.Evaluation.Tasks {
8  //[ExecuteInEditMode]
11  public class TaskSequence : NeodroidTask {
12  [SerializeField] GoalCellSensor _current_goal_cell;
13 
14  [SerializeField] Stack<GoalCellSensor> _goal_stack;
15 
16  [SerializeField] GoalCellSensor[] _sequence;
17 
18  public GoalCellSensor CurrentGoalCell {
19  get { return this._current_goal_cell; }
20  private set { this._current_goal_cell = value; }
21  }
22 
23  void Start() {
24  if (this._sequence == null || this._sequence.Length == 0) {
25  this._sequence = FindObjectsOfType<GoalCellSensor>();
26  Array.Sort(this._sequence, (g1, g2) => g1.OrderIndex.CompareTo(g2.OrderIndex));
27  }
28 
29  Array.Reverse(this._sequence);
30  this._goal_stack = new Stack<GoalCellSensor>(this._sequence);
31  this.CurrentGoalCell = this.PopGoal();
32  }
33 
34  public GoalCellSensor[] GetSequence() { return this._sequence; }
35 
37  this.CurrentGoalCell = this._goal_stack.Pop();
38  return this.CurrentGoalCell;
39  }
40  }
41 }