示例#1
0
 public override void DeepClone(List<Action<Func<IntelligenceState, IntelligenceState>>> stateCloneCallbacks)
 {
     if (ifAction)
     {
         ifAction = Instantiate(ifAction);
         ifAction.DeepClone(stateCloneCallbacks);
     }
     if (thenAction)
     {
         thenAction = Instantiate(thenAction);
         thenAction.DeepClone(stateCloneCallbacks);
     }
     if (elseAction)
     {
         elseAction = Instantiate(elseAction);
         elseAction.DeepClone(stateCloneCallbacks);
     }
 }
示例#2
0
        public override void DrawGUI(IntelligenceState parentState, Intelligence intelligence, CallbackCollection callbacks)
        {
            #if UNITY_EDITOR
            GUILayout.Label("If:");
            if (ifAction == null)
            {
                Type res = callbacks.ConditionalActionPopup();
                if (res != null)
                {

                    ifAction = CreateInstance(res) as AIAction;
                    ifAction.name = res.Name;
                    callbacks.AddAsset(ifAction);
                }
            }
            else
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(ifAction.name);
                if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(20)))
                {
                    callbacks.RemoveAsset(ifAction);
                }
                EditorGUILayout.EndHorizontal();
                ifAction.DrawGUI(parentState, intelligence, callbacks);
                EditorGUILayout.EndVertical();
            }
            GUILayout.Label("Then:");
            if (thenAction == null)
            {
                Type res = callbacks.ContinuousActionPopup();
                if (res != null)
                {
                    thenAction = CreateInstance(res) as AIAction;
                    thenAction.name = res.Name;
                    callbacks.AddAsset(thenAction);
                }
            }
            else
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(thenAction.name);
                if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(20)))
                {
                    callbacks.RemoveAsset(thenAction);
                }
                EditorGUILayout.EndHorizontal();
                thenAction.DrawGUI(parentState, intelligence, callbacks);
                EditorGUILayout.EndVertical();
            }
            GUILayout.Label("Else:");
            if (elseAction == null)
            {
                Type res = callbacks.ContinuousActionPopup();
                if (res != null)
                {
                    elseAction = CreateInstance(res) as AIAction;
                    elseAction.name = res.Name;
                    callbacks.AddAsset(elseAction);
                }
            }
            else
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(elseAction.name);
                if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(20)))
                {
                    callbacks.RemoveAsset(elseAction);
                }
                EditorGUILayout.EndHorizontal();
                elseAction.DrawGUI(parentState, intelligence, callbacks);
                EditorGUILayout.EndVertical();
            }
            #endif
        }