private void OnEnable() { _self = (AntAIScenario)target; _rowStyleA = new GUIStyle(); _rowStyleA.alignment = TextAnchor.MiddleLeft; _rowStyleA.normal.background = CreateBG(0.225f); _rowStyleB = new GUIStyle(); _rowStyleB.alignment = TextAnchor.MiddleLeft; _rowStyleB.normal.background = CreateBG(0.255f); // 0.285f _rowStyleC = new GUIStyle(); _rowStyleC.alignment = TextAnchor.MiddleLeft; _rowStyleC.normal.background = CreateBG(0.295f); // 0.325f }
public void LoadScenario(AntAIScenario aScenario) { int atomIndex; _scenarioName = aScenario.name; // 0. Register all conditions. // --------------------------- for (int i = 0, n = aScenario.conditions.list.Length; i < n; i++) { GetAtomIndex(aScenario.conditions.list[i].name); } // 1. Read Action List. // -------------------- // string template = string.Empty; // if (DebugMode) // { // A.Log("<b>Action List</b>"); // } AntAIAction action; AntAIScenarioAction scenarioAction; for (int i = 0, n = aScenario.actions.Length; i < n; i++) { scenarioAction = aScenario.actions[i]; action = GetAction(scenarioAction.name); action.state = scenarioAction.state; action.cost = scenarioAction.cost; // if (DebugMode) // { // A.Log("<b>Action:</b> `{0}`", action.name); // A.Log(" Pre:"); // } // Read Pre Conditions. for (int j = 0, nj = scenarioAction.pre.Length; j < nj; j++) { atomIndex = GetAtomIndex(aScenario.conditions.GetName(scenarioAction.pre[j].id)); action.pre.Set(atomIndex, scenarioAction.pre[j].value); // if (DebugMode) // { // template = (scenarioAction.pre[j].value) // ? " `<color=green>{0} = {1}</color>`" // : " `<color=red>{0} = {1}</color>`"; // A.Log(template, // aScenario.conditions.GetName(scenarioAction.pre[j].id), // scenarioAction.pre[j].value); // } } // if (DebugMode) // { // A.Log(" Post:"); // } // Read Post Conditions. for (int j = 0, nj = scenarioAction.post.Length; j < nj; j++) { atomIndex = GetAtomIndex(aScenario.conditions.GetName(scenarioAction.post[j].id)); action.post.Set(atomIndex, scenarioAction.post[j].value); // if (DebugMode) // { // template = (scenarioAction.post[j].value) // ? " `<color=green>{0} = {1}</color>`" // : " `<color=red>{0} = {1}</color>`"; // A.Log(template, // aScenario.conditions.GetName(scenarioAction.post[j].id), // scenarioAction.post[j].value); // } } if (scenarioAction.isDefault) { _defActionIndex = actions.Count - 1; } } // 2. Read Goal List // ----------------- // if (DebugMode) // { // A.Log("<b>Goal List</b>"); // } AntAICondition goal; AntAIScenarioGoal scenarioGoal; for (int i = 0, n = aScenario.goals.Length; i < n; i++) { scenarioGoal = aScenario.goals[i]; goal = GetGoal(scenarioGoal.name); // if (DebugMode) // { // A.Log("<b>Goal:</b> {0}", goal.name); // A.Log(" Cond:"); // } // Read Conditions. for (int j = 0, nj = scenarioGoal.conditions.Length; j < nj; j++) { goal.Set(this, aScenario.conditions.GetName(scenarioGoal.conditions[j].id), scenarioGoal.conditions[j].value); // if (DebugMode) // { // template = (scenarioGoal.conditions[j].value) // ? " `<color=green>{0} = {1}</color>`" // : " `<color=red>{0} = {1}</color>`"; // A.Log(template, // aScenario.conditions.GetName(scenarioGoal.conditions[j].id), // scenarioGoal.conditions[j].value); // } } if (scenarioGoal.isDefault) { _defGoalIndex = goals.Count - 1; } } }
public AntAICondition debugConditions; // Used for AI Debugger only. #endif public void LoadScenario(AntAIScenario aScenario) { int atomIndex; // AntLog.Trace("<b>Action List</b>"); AntAIAction action; AntAIScenarioAction scenarioAction; for (int i = 0, n = aScenario.actions.Length; i < n; i++) { scenarioAction = aScenario.actions[i]; action = GetAction(scenarioAction.name); action.state = scenarioAction.state; action.cost = scenarioAction.cost; // AntLog.Trace("Action: {0}", action.name); for (int j = 0, nj = scenarioAction.pre.Length; j < nj; j++) { atomIndex = GetAtomIndex(aScenario.conditions.GetName(scenarioAction.pre[j].id)); action.pre.Set(atomIndex, scenarioAction.pre[j].value); /*AntLog.Trace("Pre -> {0}:{1}", * aScenario.conditions.GetName(scenarioAction.pre[j].id), * scenarioAction.pre[j].value);*/ } for (int j = 0, nj = scenarioAction.post.Length; j < nj; j++) { atomIndex = GetAtomIndex(aScenario.conditions.GetName(scenarioAction.post[j].id)); action.post.Set(atomIndex, scenarioAction.post[j].value); /*AntLog.Trace("Post -> {0} : {1}", * aScenario.conditions.GetName(scenarioAction.post[j].id), * scenarioAction.post[j].value);*/ } } // AntLog.Trace("<b>Goal List</b>"); AntAICondition goal; AntAIScenarioGoal scenarioGoal; for (int i = 0, n = aScenario.goals.Length; i < n; i++) { scenarioGoal = aScenario.goals[i]; goal = GetGoal(scenarioGoal.name); //AntLog.Trace("Goal: {0}", goal.name); for (int j = 0, nj = scenarioGoal.conditions.Length; j < nj; j++) { goal.Set(this, aScenario.conditions.GetName(scenarioGoal.conditions[j].id), scenarioGoal.conditions[j].value); /*AntLog.Trace("Cond -> {0} : {1}", * aScenario.conditions.GetName(scenarioGoal.conditions[j].id), * scenarioGoal.conditions[j].value);*/ } } }