Ejemplo n.º 1
0
//	[MenuItem("Component/AI/EditCondition")]
//	public static void init ()
//	{
//		ConditionEditorWindow window = (ConditionEditorWindow)EditorWindow.GetWindow (typeof(ConditionEditorWindow));
//		window.title = "Root composite condition";
//	}

    public static void DisplayConditionEditorWindow(AIEditor aiEditor,
                                                    AIBehavior aiBehavior)
    {
        AlternateBehaviorEditorWindow window = (AlternateBehaviorEditorWindow)EditorWindow.GetWindow(typeof(AlternateBehaviorEditorWindow));

        window.aiBehavior = aiBehavior;
        window.aiEditor   = aiEditor;
        window.Show();
    }
Ejemplo n.º 2
0
    public virtual void EditAIBehavior(AIBehavior behavior)
    {
        behavior.Name = EditorGUILayout.TextField(new GUIContent("Behavior Name:", ""), behavior.Name);

        if (AIBehaviorEnableEditFlags.ContainsKey(behavior.Name) == false)
        {
            AIBehaviorEnableEditFlags [behavior.Name] = false;
        }
        AIBehaviorEnableEditFlags [behavior.Name] = EditorGUILayout.BeginToggleGroup(new GUIContent(
                                                                                         string.Format("------------- Edit AI Behavior: {0} ----------------------", behavior.Name), ""),
                                                                                     AIBehaviorEnableEditFlags [behavior.Name]);

        if (AIBehaviorEnableEditFlags [behavior.Name])
        {
            behavior.Type = (AIBehaviorType)EditorGUILayout.EnumPopup(new GUIContent("Behavior type:", ""), behavior.Type);

            AIBehavior[] AIBehaviors = this.AI.Behaviors;

            behavior.AlterBehaviorInterval = EditorGUILayout.FloatField("Alter behavior interval:", behavior.AlterBehaviorInterval);

            behavior.SelectTargetRule = (SelectTargetRule)EditorGUILayout.EnumPopup(new GUIContent("Select enemy rule:", "当这个行为生效的时候,选择敌人的规则, 默认是Closest,也就是选择最近的敌人做为当前目标."), behavior.SelectTargetRule);
            //Edit behavior data
            EditAIBehaviorData(behavior);

            //Edit End Condition Wrapper, for behavior type = SwitchToAI, it's not necessary to edit end condition.
            if (behavior.Type != AIBehaviorType.SwitchToAI)
            {
                EditorGUILayout.Space();
                if (GUILayout.Button("Edit alternate behavior data"))
                {
                    AlternateBehaviorEditorWindow.DisplayConditionEditorWindow(this, behavior);
                }
                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Delete " + behavior.Type.ToString() + " behavior: " + behavior.Name))
            {
                IList <AIBehavior> l = AI.Behaviors.ToList <AIBehavior> ();
                l.Remove(behavior);
                AI.Behaviors = l.ToArray <AIBehavior> ();
            }

            //Start and End message:
            behavior.MessageAtStart = EditorCommon.EditStringArray("Message sent when behavior start", behavior.MessageAtStart);
            behavior.MessageAtEnd   = EditorCommon.EditStringArray("Message sent when behavior end", behavior.MessageAtEnd);
        }
        EditorGUILayout.EndToggleGroup();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
    }