public IEnumerator ExecuteUpdate(UtilityAIClient client) { float nextInterval = 0f; //IEnumerator activeAction = null; yield return(new WaitForSeconds(Random.Range(client.startDelayMin, client.startDelayMax))); while (isExecuteRunning) { if (Time.time > nextInterval) { client.Execute(); nextInterval = Time.time + Random.Range(client.intervalMin - 0.5f, client.intervalMax + 1f); if (debugNextIntervalTime) { Debug.Log("Current Time: " + Time.time + " | Next interval in: " + (nextInterval - Time.time)); } //if (client.SelectAction()){ // activeAction = client.ExecuteAction(); // yield return StartCoroutine(activeAction); // activeAction = null; // nextInterval = Time.time + Random.Range(client.intervalMin - 0.5f, client.intervalMax + 1f); // if (debugNextIntervalTime) Debug.Log("Current Time: " + Time.time + " | Next interval in: " + (nextInterval - Time.time)); //} //else{ // //Debug.Log("client has not selected action."); //} } yield return(null); } }
void AddAIAsset(UtilityAIAsset aiAsset) { // Add asset and client to TaskNetwork UtilityAIClient client = new UtilityAIClient(aiAsset.configuration, taskNetwork.contextProvider); taskNetwork.clients.Add(client); taskNetwork.assets.Add(aiAsset); aiAsset.configuration.OnBeforeSerialize(); aiAsset.configuration.OnAfterDeserialize(); EditorUtility.SetDirty(taskNetwork); }
/// <summary> /// Client Inspector /// </summary> protected virtual void DrawTaskNetworkInspector() { // Displaying header options. using (new EditorGUILayout.HorizontalScope()){ EditorGUILayout.LabelField("AIs", EditorStyles.boldLabel); // Add a new UtilityAIClient if (GUILayout.Button("Add", EditorStyles.miniButton, GUILayout.Width(65f))) { InspectorUtility.ShowOptionsWindow <AddClientWindow>(taskNetwork); //ShowOptionsWindow<AddClientWindow>(); } } // Displaying the AI Clients using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { if (taskNetwork.clients.Count == 0) { EditorGUILayout.HelpBox("There are no AI's attached to this TaskNetworkComponent.", MessageType.Info); } for (int i = 0; i < taskNetwork.clients.Count; i++) { UtilityAIClient client = taskNetwork.clients[i]; UtilityAIAsset asset = taskNetwork.assets[i]; using (new EditorGUILayout.VerticalScope()) { if (asset != null && client != null) { // For Client Options using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.ToggleLeft(GUIContent.none, true); // GUILayout.Width(Screen.width * 0.6f) if (GUILayout.Button("Debug", EditorStyles.miniButton, GUILayout.Width(48f))) // GUILayout.Width(Screen.width * 0.15f) { Debug.Log(client.ai.name); Selection.activeObject = asset; } if (InspectorUtility.OptionsPopupButton(InspectorUtility.DeleteContent)) { RemoveUtilityAIAsset(i); } } using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(new GUIContent("AI: "), GUILayout.Width(Screen.width * 0.33f)); EditorGUILayout.LabelField(new GUIContent(asset.friendlyName)); //EditorGUILayout.LabelField(new GUIContent(client.ai.name)); // Name resets after scene reload } using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Interval: ", GUILayout.Width(Screen.width * 0.33f)); client.intervalMin = EditorGUILayout.FloatField(client.intervalMin, GUILayout.Width(35f)); EditorGUILayout.LabelField("to ", GUILayout.Width(20f)); client.intervalMax = EditorGUILayout.FloatField(client.intervalMax, GUILayout.Width(35f)); } // For Client StartDelay using (new EditorGUILayout.HorizontalScope()) { //EditorGUILayout.LabelField("Start Delay: ", GUILayout.Width(Screen.width * 0.33f)); //client.startDelayMin = EditorGUILayout.FloatField(client.startDelayMin, GUILayout.Width(35f)); //EditorGUILayout.LabelField("to ", GUILayout.Width(20f)); //client.startDelayMax = EditorGUILayout.FloatField(client.startDelayMax, GUILayout.Width(35f)); float min = client.startDelayMin; float max = client.startDelayMax; InspectorUtility.MinMaxInputField(ref min, ref max, new GUIContent("Start Delay: ")); } EditorGUILayout.Space(); } } } } // The group is now ended // -- Active Client Info if (taskNetwork.assets.Count > 0) { ContextMessageBox(); //ActiveClientMessageBox(); } using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Editor", EditorStyles.miniButton, GUILayout.Width(65f))) { AIAssetEditor.Init(); } } GUILayout.Space(8); }
public string ClientStatus(UtilityAIClient client) { string clientInfo = ""; return(clientInfo); }