public Condition(GlobalCondition relatedGlobalCondition, bool satisfiedState) { globalCondition = relatedGlobalCondition; satisfied = satisfiedState; OnGlobalConditionChanged = new UnityEvent(); OnEqualToGlobalCondition = new UnityEvent(); OnNotEqualToGlobalCondition = new UnityEvent(); globalCondition.OnConditionChanged.AddListener(CheckChange); }
private void LoadGoals(Subtask parentSubtask, JsonGoal[] jsonGoals) { for (int i = 0; i < jsonGoals.Length; i++) { GlobalCondition currentGlobalCondition = AppController.instance.stateManager.FindGlobalConditionByName(jsonGoals[i].name); if (currentGlobalCondition != null) { Condition newGoal = new Condition(currentGlobalCondition, jsonGoals[i].satisfied); parentSubtask.AddGoal(newGoal); } } }
public GlobalCondition FindGlobalConditionByName(string name) { GlobalCondition globalCondition = null; int i = 0; Transform grandchild = null; while (grandchild == null && i < transform.childCount) { Transform child = transform.GetChild(i); grandchild = child.Find(name); i++; } if (grandchild != null) { globalCondition = grandchild.GetComponent <GlobalCondition>(); } return(globalCondition); }
public void AddNewGlobalCondition(string name, bool satisfied, string description, string messageSatisfied, string messageNotSatisfied) { Transform categoryObjectTransform = transform.Find(categoryName); if (categoryObjectTransform == null) { GameObject categoryObject = new GameObject(categoryName); categoryObject.transform.parent = transform; categoryObjectTransform = categoryObject.transform; } GameObject globalConditionObject = new GameObject(name); globalConditionObject.transform.parent = categoryObjectTransform; GlobalCondition globalCondition = globalConditionObject.AddComponent <GlobalCondition>(); globalCondition.description = description; globalCondition.messageSatisfied = messageSatisfied; globalCondition.messageNotSatisfied = messageNotSatisfied; globalCondition.Satisfied = satisfied; }