124 lines
3.2 KiB
C#
124 lines
3.2 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using MyBT;
|
|||
|
|
|||
|
public class Test : MonoBehaviour {
|
|||
|
[Task]
|
|||
|
void Succeed () {
|
|||
|
if (Task.isDebugging)
|
|||
|
Debug.Log("Test.Succeed: " + Task.getState);
|
|||
|
if (Task.isStartingOrRunning) {
|
|||
|
Task.SetSucceeded();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void Fail() {
|
|||
|
if (Task.isDebugging)
|
|||
|
Debug.Log("Test.Fail: " + Task.getState);
|
|||
|
if (Task.isStartingOrRunning) {
|
|||
|
Task.SetFailed();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void Fail2() {
|
|||
|
if (Task.isDebugging)
|
|||
|
Debug.Log("Test.Fail: " + Task.getState);
|
|||
|
if (Task.isStartingOrRunning) {
|
|||
|
Task.SetFailed();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void Fail3() {
|
|||
|
if (Task.isDebugging)
|
|||
|
Debug.Log("Test.Fail: " + Task.getState);
|
|||
|
if (Task.isStartingOrRunning) {
|
|||
|
Task.SetFailed();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void Wait (float duration) {
|
|||
|
if (Task.isDebugging)
|
|||
|
Debug.Log("Test.Wait: " + Task.getState);
|
|||
|
if (Task.isStarting) {
|
|||
|
Task.data = Time.time;
|
|||
|
}
|
|||
|
if (Task.isRunning) {
|
|||
|
float startTime = (float)Task.data;
|
|||
|
float timePassed = (Time.time - startTime);
|
|||
|
Task.log = timePassed.ToString();
|
|||
|
if (timePassed > duration)
|
|||
|
Task.SetSucceeded();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void Print (string text) {
|
|||
|
if (Task.isDebugging)
|
|||
|
Debug.Log("Test.Wait: " + Task.getState);
|
|||
|
if (Task.isStarting) {
|
|||
|
Debug.Log(text);
|
|||
|
Task.SetSucceeded();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void Print (int number) {
|
|||
|
if (Task.isDebugging)
|
|||
|
Debug.Log("Test.Wait: " + Task.getState);
|
|||
|
if (Task.isStartingOrRunning) {
|
|||
|
Debug.Log(number.ToString());
|
|||
|
Task.SetSucceeded();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void CountTo3 () {
|
|||
|
if (Task.isStarting) {
|
|||
|
Task.data = 0;
|
|||
|
}
|
|||
|
if (Task.isStartingOrRunning) {
|
|||
|
Task.data = (int)Task.data + 1;
|
|||
|
Task.log = ((int)Task.data).ToString();
|
|||
|
if ((int)Task.data == 3) {
|
|||
|
Task.SetSucceeded();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
[Task]
|
|||
|
void CountToNumber (string label, int number) {
|
|||
|
// if (Task.isDebugging)
|
|||
|
// Debug.Log("debugging");
|
|||
|
if (Task.isStarting) {
|
|||
|
if (Task.isDebugging) {
|
|||
|
Debug.Log("Test.CountToNumber.isStarting: " + label);
|
|||
|
}
|
|||
|
Task.data = 0;
|
|||
|
}
|
|||
|
if (Task.isStartingOrRunning) {
|
|||
|
Task.data = (int)Task.data + 1;
|
|||
|
string output = label + " " + (int)Task.data;
|
|||
|
Task.log = output;
|
|||
|
//if (Task.isDebugging) {
|
|||
|
// Debug.Log(output);
|
|||
|
//}
|
|||
|
if (Task.isDebugging) {
|
|||
|
Debug.Log($"Test.CountToNumber.isStartingOrRunning: label {label} data {(int)Task.data} finished {((int)Task.data > number)}");
|
|||
|
}
|
|||
|
if ((int)Task.data >= number ) {
|
|||
|
Task.SetSucceeded();
|
|||
|
}
|
|||
|
}
|
|||
|
if (Task.isAborting) {
|
|||
|
if (Task.isDebugging) {
|
|||
|
Debug.Log("Test.CountToNumber.isAborting: " + label+" ");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|