/// <summary> /// The Initializer for the <seealso cref="PerceptionGUI"/> /// </summary> /// <param name="type"></param> public void InitPerceptionGUI(perceptionType type) { identificator = UniqueID(); this.type = type; timerNumber = 0; customName = "CustomName"; openFoldout = false; if (type == perceptionType.IsInState) { elemName = "Select a FSM"; } else if (type == perceptionType.BehaviourTreeStatus) { elemName = "Select a BT"; } else { elemName = ""; } stateName = "Select a State"; status = ReturnValues.Succeed; if (type == perceptionType.And || type == perceptionType.Or) { firstChild = CreateInstance <PerceptionGUI>(); firstChild.InitPerceptionGUI(perceptionType.Push); secondChild = CreateInstance <PerceptionGUI>(); secondChild.InitPerceptionGUI(perceptionType.Push); } else { firstChild = null; secondChild = null; } }
/// <summary> /// Recursive function for <see cref="ChangeType(object)"/> /// </summary> /// <param name="perception"></param> /// <param name="id"></param> /// <param name="newType"></param> public void ChangeTypeRecursive(ref PerceptionGUI perception, string id, perceptionType newType) { if (perception.identificator == id) { switch (perception.type) { case perceptionType.Timer: if (newType != perceptionType.Timer) { perception.InitPerceptionGUI(newType); } break; case perceptionType.Value: if (newType != perceptionType.Value) { perception.InitPerceptionGUI(newType); } break; case perceptionType.IsInState: if (newType != perceptionType.IsInState) { perception.InitPerceptionGUI(newType); } break; case perceptionType.BehaviourTreeStatus: if (newType != perceptionType.BehaviourTreeStatus) { perception.InitPerceptionGUI(newType); } break; case perceptionType.And: case perceptionType.Or: if (newType == perceptionType.And || newType == perceptionType.Or) { perception.type = newType; } else { perception.InitPerceptionGUI(newType); } break; default: perception.InitPerceptionGUI(newType); break; } perception.openFoldout = true; } else { if (perception.firstChild != null && perception.secondChild != null) { ChangeTypeRecursive(ref perception.firstChild, id, newType); ChangeTypeRecursive(ref perception.secondChild, id, newType); } } }