コード例 #1
0
        public static List <AC.Action> ResizeList(List <AC.Action> list, int listSize)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            string defaultAction = "";

            if (actionsManager)
            {
                defaultAction = actionsManager.GetDefaultAction();
            }

            if (list.Count < listSize)
            {
                // Increase size of list
                while (list.Count < listSize)
                {
                    List <int> idArray = new List <int>();

                    foreach (AC.Action _action in list)
                    {
                        if (_action == null)
                        {
                            continue;
                        }
                        idArray.Add(_action.id);
                    }

                    idArray.Sort();

                    AC.Action newAction = (AC.Action)CreateInstance(defaultAction);
                    newAction.name = defaultAction;
                    list.Add(newAction);

                    // Update id based on array
                    foreach (int _id in idArray.ToArray())
                    {
                        if (list [list.Count - 1].id == _id)
                        {
                            list [list.Count - 1].id++;
                        }
                    }
                }
            }
            else if (list.Count > listSize)
            {
                // Decrease size of list
                while (list.Count > listSize)
                {
                    list.RemoveAt(list.Count - 1);
                }
            }

            return(list);
        }
コード例 #2
0
        private void ActionSideMenu(int i)
        {
            ActionList _target = (ActionList)target;

            actionToAffect = _target.actions[i];
            GenericMenu menu = new GenericMenu();

            if (_target.actions[i].isEnabled)
            {
                menu.AddItem(new GUIContent("Disable"), false, Callback, "Disable");
            }
            else
            {
                menu.AddItem(new GUIContent("Enable"), false, Callback, "Enable");
            }
            menu.AddSeparator("");
            if (!Application.isPlaying)
            {
                if (_target.actions.Count > 1)
                {
                    menu.AddItem(new GUIContent("Cut"), false, Callback, "Cut");
                }
                menu.AddItem(new GUIContent("Copy"), false, Callback, "Copy");
            }
            if (AdvGame.copiedActions.Count > 0)
            {
                menu.AddItem(new GUIContent("Paste after"), false, Callback, "Paste after");
            }
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Insert after"), false, Callback, "Insert after");
            if (_target.actions.Count > 1)
            {
                menu.AddItem(new GUIContent("Delete"), false, Callback, "Delete");
            }
            if (i > 0 || i < _target.actions.Count - 1)
            {
                menu.AddSeparator("");
            }
            if (i > 0)
            {
                menu.AddItem(new GUIContent("Re-arrange/Move to top"), false, Callback, "Move to top");
                menu.AddItem(new GUIContent("Re-arrange/Move up"), false, Callback, "Move up");
            }
            if (i < _target.actions.Count - 1)
            {
                menu.AddItem(new GUIContent("Re-arrange/Move down"), false, Callback, "Move down");
                menu.AddItem(new GUIContent("Re-arrange/Move to bottom"), false, Callback, "Move to bottom");
            }

            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Toggle breakpoint"), false, Callback, "Toggle breakpoint");

            menu.ShowAsContext();
        }
コード例 #3
0
 public static void ResetList(ActionList _target)
 {
     if (_target.actions.Count == 0 || (_target.actions.Count == 1 && _target.actions[0] == null))
     {
         _target.actions.Clear();
         AC.Action newAction = ActionList.GetDefaultAction();
         if (newAction != null)
         {
             _target.actions.Add(newAction);
         }
     }
 }
コード例 #4
0
 private static string GetActionListSuffix(ActionList actionList, AC.Action action)
 {
     if (actionList && actionList.actions.Contains(action))
     {
         return("\n(From Action #" + actionList.actions.IndexOf(action) + " in ActionList '" + actionList.name + "')");
     }
     else if (action != null)
     {
         return("\n(From Action '" + action.category + ": " + action.title + "')");
     }
     return(string.Empty);
 }
コード例 #5
0
        /**
         * <summary>Update the Action's output sockets</summary>
         * <param name = "actionEndOnPass">A data container for the 'Condition is met' output socket</param>
         * <param name = "actionEndOnFail">A data container for the 'Condition is not met' output socket</param>
         */
        public void SetOutputs(ActionEnd actionEndOnPass, ActionEnd actionEndOnFail)
        {
            resultActionTrue     = actionEndOnPass.resultAction;
            skipActionTrue       = actionEndOnPass.skipAction;
            skipActionTrueActual = actionEndOnPass.skipActionActual;
            linkedCutsceneTrue   = actionEndOnPass.linkedCutscene;
            linkedAssetTrue      = actionEndOnPass.linkedAsset;

            resultActionFail     = actionEndOnFail.resultAction;
            skipActionFail       = actionEndOnFail.skipAction;
            skipActionFailActual = actionEndOnFail.skipActionActual;
            linkedCutsceneFail   = actionEndOnFail.linkedCutscene;
            linkedAssetFail      = actionEndOnFail.linkedAsset;
        }
コード例 #6
0
        public static AC.Action RebuildAction(AC.Action existingAction, int typeIndex, ActionList _target, int insertIndex = -1, ActionEnd _end = null)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;
            int            existingIndex  = _target.actions.IndexOf(existingAction);

            if (actionsManager)
            {
                string className = actionsManager.AllActions [typeIndex].fileName;

                if (existingAction.GetType().ToString() != className && existingAction.GetType().ToString() != ("AC." + className))
                {
                    bool       _showComment              = existingAction.showComment;
                    bool       _showOutputSockets        = existingAction.showOutputSockets;
                    string     _comment                  = existingAction.comment;
                    ActionList _parentActionListInEditor = existingAction.parentActionListInEditor;

                    AC.Action newAction = (AC.Action)CreateInstance(className);
                    newAction.name = className;

                    if (_end != null)
                    {
                        newAction.endAction      = _end.resultAction;
                        newAction.skipAction     = _end.skipAction;
                        newAction.linkedAsset    = _end.linkedAsset;
                        newAction.linkedCutscene = _end.linkedCutscene;
                    }

                    newAction.showComment              = _showComment;
                    newAction.showOutputSockets        = _showOutputSockets;
                    newAction.comment                  = _comment;
                    newAction.parentActionListInEditor = _parentActionListInEditor;

                    if (insertIndex >= 0)
                    {
                        _target.actions.Insert(insertIndex, newAction);
                    }
                    else if (existingIndex >= 0)
                    {
                        _target.actions[existingIndex] = newAction;
                    }

                    //SyncAssetObjects (_target);

                    return(newAction);
                }
            }

            return(existingAction);
        }
コード例 #7
0
        public static int ShowTypePopup(AC.Action action, int typeIndex)
        {
            if (!KickStarter.actionsManager.IsActionTypeEnabled(typeIndex))
            {
                EditorGUILayout.LabelField("<b>This Action type has been disabled.</b>", CustomStyles.disabledActionType);
                //return typeIndex;
                return(-1);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Action type:", GUILayout.Width(80));

            ActionCategory oldCategory = KickStarter.actionsManager.GetActionCategory(typeIndex);
            ActionCategory category    = oldCategory;

            category = (ActionCategory)EditorGUILayout.EnumPopup(category);

            int subcategory = KickStarter.actionsManager.GetActionSubCategory(action);
            // This is for all, needs to be converted to enabled for that category

            int enabledSubcategory = -1;

            ActionType[] categoryTypes = KickStarter.actionsManager.GetActionTypesInCategory(category);
            for (int i = 0; i <= subcategory; i++)
            {
                if (i < categoryTypes.Length && categoryTypes[i].isEnabled)
                {
                    enabledSubcategory++;
                }
            }

            if (category != oldCategory)
            {
                subcategory        = 0;
                enabledSubcategory = 0;
            }

            enabledSubcategory = EditorGUILayout.Popup(enabledSubcategory, KickStarter.actionsManager.GetActionSubCategories(category));
            int newTypeIndex = KickStarter.actionsManager.GetEnabledActionTypeIndex(category, enabledSubcategory);

            EditorGUILayout.EndHorizontal();
            GUILayout.Space(4f);

            if (newTypeIndex != typeIndex)
            {
                return(newTypeIndex);
            }
            return(-1);
        }
コード例 #8
0
ファイル: Action.cs プロジェクト: IJkeB/Ekster1
 public virtual void FixLinkAfterDeleting(Action actionToDelete, Action targetAction, List <Action> actionList)
 {
     if ((endAction == ResultAction.Skip && skipActionActual == actionToDelete) || (endAction == ResultAction.Continue && actionList.IndexOf(actionToDelete) == (actionList.IndexOf(this) + 1)))
     {
         if (targetAction == null)
         {
             endAction = ResultAction.Stop;
         }
         else
         {
             endAction        = ResultAction.Skip;
             skipActionActual = targetAction;
         }
     }
 }
コード例 #9
0
 public static void LogError(object message, ActionList actionList, AC.Action action, UnityEngine.Object context = null)
 {
     if (Application.isPlaying && KickStarter.eventManager)
     {
         message = KickStarter.eventManager.Call_OnDebugLog(message, DebugLogType.Error, context, CanDisplay(DebugLogType.Error));
     }
     if (CanDisplay(DebugLogType.Error))
     {
         if (context == null)
         {
             context = actionList;
         }
         Debug.LogError(message + GetActionListSuffix(actionList, action) + hr, context);
     }
 }
コード例 #10
0
        public static Action AddAction(AC.Action newAction, int i, ActionListAsset _target)
        {
            if (i < 0)
            {
                _target.actions.Add(newAction);
            }
            else
            {
                _target.actions.Insert(i, newAction);
            }

            SyncAssetObjects(_target);

            return(newAction);
        }
コード例 #11
0
ファイル: ActionList.cs プロジェクト: sirmortimus/team9
 /**
  * <summary>Gets the default Action set within ActionsManager.</summary>
  * <returns>The default Action set within ActionsManager</returns>
  */
 public static AC.Action GetDefaultAction()
 {
     if (AdvGame.GetReferences().actionsManager)
     {
         string    defaultAction = AdvGame.GetReferences().actionsManager.GetDefaultAction();
         AC.Action newAction     = (AC.Action)ScriptableObject.CreateInstance(defaultAction);
         newAction.name = defaultAction;
         return(newAction);
     }
     else
     {
         ACDebug.LogError("Cannot create Action - no Actions Manager found.");
         return(null);
     }
 }
コード例 #12
0
ファイル: Cutscene.cs プロジェクト: cvkumar/out-of-body
        public void CopyFromAsset(ActionListAsset actionListAsset)
        {
            isSkippable    = actionListAsset.isSkippable;
            actionListType = actionListAsset.actionListType;
            useParameters  = actionListAsset.useParameters;

            // Copy parameters
            parameters = new List <ActionParameter>();
            parameters.Clear();
            foreach (ActionParameter parameter in actionListAsset.DefaultParameters)
            {
                parameters.Add(new ActionParameter(parameter, true));
            }

            // Actions
            actions = new List <Action>();
            actions.Clear();

            Vector2 firstPosition = new Vector2(14f, 14f);

            foreach (Action originalAction in actionListAsset.actions)
            {
                if (originalAction == null)
                {
                    continue;
                }

                AC.Action duplicatedAction = Object.Instantiate(originalAction) as AC.Action;

                if (actionListAsset.actions.IndexOf(originalAction) == 0)
                {
                    Rect newRect = new Rect(firstPosition, duplicatedAction.NodeRect.size);
                    duplicatedAction.NodeRect = newRect;
                }
                else
                {
                    Rect newRect = new Rect(originalAction.NodeRect.position, duplicatedAction.NodeRect.size);
                    duplicatedAction.NodeRect = newRect;
                }

                duplicatedAction.ClearIDs();
                duplicatedAction.isMarked    = false;
                duplicatedAction.isAssetFile = false;
                duplicatedAction.parentActionListInEditor = this;
                actions.Add(duplicatedAction);
            }
        }
コード例 #13
0
        private void ActionSideMenu(AC.Action action)
        {
            ActionListAsset _target = (ActionListAsset)target;

            int i = _target.actions.IndexOf(action);

            actionToAffect = action;
            GenericMenu menu = new GenericMenu();

            if (action.isEnabled)
            {
                menu.AddItem(new GUIContent("Disable"), false, Callback, "Disable");
            }
            else
            {
                menu.AddItem(new GUIContent("Enable"), false, Callback, "Enable");
            }
            menu.AddSeparator("");
            if (_target.actions.Count > 1)
            {
                menu.AddItem(new GUIContent("Cut"), false, Callback, "Cut");
            }
            menu.AddItem(new GUIContent("Copy"), false, Callback, "Copy");
            if (AdvGame.copiedActions.Count > 0)
            {
                menu.AddItem(new GUIContent("Paste after"), false, Callback, "Paste after");
            }
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Insert after"), false, Callback, "Insert after");
            menu.AddItem(new GUIContent("Delete"), false, Callback, "Delete");
            if (i > 0 || i < _target.actions.Count - 1)
            {
                menu.AddSeparator("");
            }
            if (i > 0)
            {
                menu.AddItem(new GUIContent("Re-arrange/Move to top"), false, Callback, "Move to top");
                menu.AddItem(new GUIContent("Re-arrange/Move up"), false, Callback, "Move up");
            }
            if (i < _target.actions.Count - 1)
            {
                menu.AddItem(new GUIContent("Re-arrange/Move down"), false, Callback, "Move down");
                menu.AddItem(new GUIContent("Re-arrange/Move to bottom"), false, Callback, "Move to bottom");
            }

            menu.ShowAsContext();
        }
コード例 #14
0
ファイル: Cutscene.cs プロジェクト: Ryanocerus/Mittens-McGraw
        public void CopyFromAsset(ActionListAsset actionListAsset)
        {
            isSkippable    = actionListAsset.isSkippable;
            actionListType = actionListAsset.actionListType;
            useParameters  = actionListAsset.useParameters;

            // Copy parameters
            parameters = new List <ActionParameter>();
            parameters.Clear();
            foreach (ActionParameter parameter in actionListAsset.parameters)
            {
                parameters.Add(new ActionParameter(parameter));
            }

            // Actions
            actions = new List <Action>();
            actions.Clear();

            Vector2 firstPosition = new Vector2(14f, 14f);

            foreach (Action originalAction in actionListAsset.actions)
            {
                if (originalAction == null)
                {
                    continue;
                }

                AC.Action duplicatedAction = Object.Instantiate(originalAction) as AC.Action;

                if (actionListAsset.actions.IndexOf(originalAction) == 0)
                {
                    duplicatedAction.nodeRect.x = firstPosition.x;
                    duplicatedAction.nodeRect.y = firstPosition.y;
                }
                else
                {
                    duplicatedAction.nodeRect.x = firstPosition.x + (originalAction.nodeRect.x - firstPosition.x);
                    duplicatedAction.nodeRect.y = firstPosition.y + (originalAction.nodeRect.y - firstPosition.y);
                }

                duplicatedAction.ClearIDs();
                duplicatedAction.isMarked    = false;
                duplicatedAction.isAssetFile = false;
                actions.Add(duplicatedAction);
            }
        }
コード例 #15
0
        private void JumpToActionGUI(List <Action> actions)
        {
            int           tempSkipAction = jumpToAction;
            List <string> labelList      = new List <string>();

            if (jumpToActionActual)
            {
                bool found = false;

                for (int i = 0; i < actions.Count; i++)
                {
                    //labelList.Add (i.ToString () + ": " + actions [i].title);
                    labelList.Add("(" + i.ToString() + ") " + ((KickStarter.actionsManager != null) ? KickStarter.actionsManager.GetActionTypeLabel(actions[i]) : string.Empty));

                    if (jumpToActionActual == actions [i])
                    {
                        jumpToAction = i;
                        found        = true;
                    }
                }

                if (!found)
                {
                    jumpToAction = tempSkipAction;
                }
            }

            if (jumpToAction < 0)
            {
                jumpToAction = 0;
            }

            if (jumpToAction >= actions.Count)
            {
                jumpToAction = actions.Count - 1;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("  Action to skip to:", GUILayout.Width(155f));
            tempSkipAction = EditorGUILayout.Popup(jumpToAction, labelList.ToArray());
            jumpToAction   = tempSkipAction;
            EditorGUILayout.EndHorizontal();
            jumpToActionActual = actions [jumpToAction];
        }
コード例 #16
0
ファイル: Action.cs プロジェクト: IJkeB/Ekster1
 public virtual void PrepareToCopy(int originalIndex, List <Action> actionList)
 {
     if (endAction == ResultAction.Continue)
     {
         if (originalIndex == actionList.Count - 1)
         {
             endAction = ResultAction.Stop;
         }
         else if (actionList [originalIndex + 1].isMarked)
         {
             endAction        = ResultAction.Skip;
             skipActionActual = actionList [originalIndex + 1];
         }
         else
         {
             endAction = ResultAction.Stop;
         }
     }
     if (endAction == ResultAction.Skip)
     {
         if (skipActionActual.isMarked)
         {
             int place = 0;
             foreach (Action _action in actionList)
             {
                 if (_action.isMarked)
                 {
                     if (_action == skipActionActual)
                     {
                         skipActionActual = null;
                         skipAction       = place;
                         break;
                     }
                     place++;
                 }
             }
         }
         else
         {
             endAction = ResultAction.Stop;
         }
     }
 }
コード例 #17
0
        private void JumpToActionGUI(List <Action> actions)
        {
            int           tempSkipAction = jumpToAction;
            List <string> labelList      = new List <string>();

            if (jumpToActionActual)
            {
                bool found = false;

                for (int i = 0; i < actions.Count; i++)
                {
                    labelList.Add(i.ToString() + ": " + actions [i].title);

                    if (jumpToActionActual == actions [i])
                    {
                        jumpToAction = i;
                        found        = true;
                    }
                }

                if (!found)
                {
                    jumpToAction = tempSkipAction;
                }
            }

            if (jumpToAction < 0)
            {
                jumpToAction = 0;
            }

            if (jumpToAction >= actions.Count)
            {
                jumpToAction = actions.Count - 1;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("  Action to skip to:");
            tempSkipAction = EditorGUILayout.Popup(jumpToAction, labelList.ToArray());
            jumpToAction   = tempSkipAction;
            EditorGUILayout.EndHorizontal();
            jumpToActionActual = actions [jumpToAction];
        }
コード例 #18
0
ファイル: ActionListEditor.cs プロジェクト: mcbodge/eidolon
        public static AC.Action RebuildAction(AC.Action action, int typeIndex, ResultAction _resultAction, int _skipAction, ActionListAsset _linkedAsset, Cutscene _linkedCutscene)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager)
            {
                string className = actionsManager.AllActions [typeIndex].fileName;

                if (action.GetType().ToString() != className && action.GetType().ToString() != ("AC." + className))
                {
                    action                = (AC.Action)CreateInstance(className);
                    action.endAction      = _resultAction;
                    action.skipAction     = _skipAction;
                    action.linkedAsset    = _linkedAsset;
                    action.linkedCutscene = _linkedCutscene;
                }
            }

            return(action);
        }
コード例 #19
0
        public static Action RebuildAction(AC.Action action, int typeIndex, ActionListAsset _target, int insertIndex = -1, ActionEnd _end = null)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager)
            {
                bool   _showComment       = action.showComment;
                bool   _showOutputSockets = action.showOutputSockets;
                string _comment           = action.comment;

                ActionListAssetEditor.DeleteAction(action, _target);

                string className = actionsManager.AllActions [typeIndex].fileName;

                AC.Action newAction = (AC.Action)CreateInstance(className);
                newAction.name = className;

                if (_end != null)
                {
                    newAction.endAction      = _end.resultAction;
                    newAction.skipAction     = _end.skipAction;
                    newAction.linkedAsset    = _end.linkedAsset;
                    newAction.linkedCutscene = _end.linkedCutscene;
                }

                newAction.showComment       = _showComment;
                newAction.comment           = _comment;
                newAction.showOutputSockets = _showOutputSockets;

                if (insertIndex >= 0)
                {
                    _target.actions.Insert(insertIndex, newAction);
                }

                SyncAssetObjects(_target);

                return(newAction);
            }

            return(action);
        }
コード例 #20
0
        public static Action RebuildAction(AC.Action action, int typeIndex, ActionListAsset _target)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager)
            {
                ActionListAssetEditor.DeleteAction(action, _target);

                string className = actionsManager.AllActions [typeIndex].fileName;

                AC.Action newAction = (AC.Action)CreateInstance(className);
                newAction.hideFlags = HideFlags.HideInHierarchy;

                AssetDatabase.AddObjectToAsset(newAction, _target);
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newAction));
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();

                return(newAction);
            }

            return(action);
        }
コード例 #21
0
        public override void PrepareToCopy(int originalIndex, List <Action> actionList)
        {
            if (resultActionFail == ResultAction.Continue)
            {
                if (originalIndex == actionList.Count - 1)
                {
                    resultActionFail = ResultAction.Stop;
                }
                else if (actionList [originalIndex + 1].isMarked)
                {
                    resultActionFail     = ResultAction.Skip;
                    skipActionFailActual = actionList [originalIndex + 1];
                }
                else
                {
                    resultActionFail = ResultAction.Stop;
                }
            }
            if (resultActionFail == ResultAction.Skip)
            {
                if (skipActionFailActual.isMarked)
                {
                    int place = 0;
                    foreach (Action _action in actionList)
                    {
                        if (_action.isMarked)
                        {
                            if (_action == skipActionFailActual)
                            {
                                skipActionFailActual = null;
                                skipActionFail       = place;
                                break;
                            }
                            place++;
                        }
                    }
                }
                else
                {
                    resultActionFail = ResultAction.Stop;
                }
            }

            if (resultActionTrue == ResultAction.Continue)
            {
                if (originalIndex == actionList.Count - 1)
                {
                    resultActionTrue = ResultAction.Stop;
                }
                else if (actionList [originalIndex + 1].isMarked)
                {
                    resultActionTrue     = ResultAction.Skip;
                    skipActionTrueActual = actionList [originalIndex + 1];
                }
                else
                {
                    resultActionTrue = ResultAction.Stop;
                }
            }
            if (resultActionTrue == ResultAction.Skip)
            {
                if (skipActionTrueActual.isMarked)
                {
                    int place = 0;
                    foreach (Action _action in actionList)
                    {
                        if (_action.isMarked)
                        {
                            if (_action == skipActionTrueActual)
                            {
                                skipActionTrueActual = null;
                                skipActionTrue       = place;
                                break;
                            }
                            place++;
                        }
                    }
                }
                else
                {
                    resultActionTrue = ResultAction.Stop;
                }
            }
        }
コード例 #22
0
        private void SkipActionFailGUI(List <Action> actions, bool showGUI)
        {
            if (skipActionFail == -1)
            {
                // Set default
                int i = actions.IndexOf(this);
                if (actions.Count > i + 1)
                {
                    skipActionFail = i + 1;
                }
                else
                {
                    skipActionFail = i;
                }
            }

            int           tempSkipAction = skipActionFail;
            List <string> labelList      = new List <string>();

            if (skipActionFailActual)
            {
                bool found = false;

                for (int i = 0; i < actions.Count; i++)
                {
                    labelList.Add("(" + i.ToString() + ") " + ((KickStarter.actionsManager != null) ? KickStarter.actionsManager.GetActionTypeLabel(actions[i]) : string.Empty));

                    if (skipActionFailActual == actions [i])
                    {
                        skipActionFail = i;
                        found          = true;
                    }
                }

                if (!found)
                {
                    skipActionFail = tempSkipAction;
                }
            }

            if (skipActionFail >= actions.Count)
            {
                skipActionFail = actions.Count - 1;
            }

            if (showGUI)
            {
                if (actions.Count > 1)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("  Action to skip to:", GUILayout.Width(155f));
                    tempSkipAction = EditorGUILayout.Popup(skipActionFail, labelList.ToArray());
                    skipActionFail = tempSkipAction;
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.HelpBox("Cannot skip action - no further Actions available", MessageType.Warning);
                    return;
                }
            }

            skipActionFailActual = actions [skipActionFail];
        }
コード例 #23
0
        protected void DrawSharedElements(ActionList _target)
        {
            if (PrefabUtility.GetPrefabType(_target) == PrefabType.Prefab)
            {
                EditorGUILayout.HelpBox("Scene-based Actions can not live in prefabs - use ActionList assets instead.", MessageType.Info);
                return;
            }

            int numActions = 0;

            if (_target.source != ActionListSource.AssetFile)
            {
                numActions = _target.actions.Count;
                if (numActions < 1)
                {
                    numActions = 1;
                    AC.Action newAction = ActionList.GetDefaultAction();
                    _target.actions.Add(newAction);
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();

            if (_target.source == ActionListSource.AssetFile)
            {
                GUI.enabled = false;
            }

            if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft))
            {
                Undo.RecordObject(_target, "Expand actions");
                foreach (AC.Action action in _target.actions)
                {
                    action.isDisplayed = true;
                }
            }
            if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid))
            {
                Undo.RecordObject(_target, "Collapse actions");
                foreach (AC.Action action in _target.actions)
                {
                    action.isDisplayed = false;
                }
            }

            GUI.enabled = true;

            if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid))
            {
                if (_target.source == ActionListSource.AssetFile)
                {
                    if (_target.assetFile != null)
                    {
                        ActionListEditorWindow.Init(_target.assetFile);
                    }
                }
                else
                {
                    ActionListEditorWindow.Init(_target);
                }
            }
            if (!Application.isPlaying)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Run now", EditorStyles.miniButtonRight))
            {
                _target.Interact();
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (_target.source == ActionListSource.AssetFile)
            {
                return;
            }

            ActionListEditor.ResetList(_target);

            if (actionsManager == null)
            {
                EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning);
                OnEnable();
                return;
            }

            if (!actionsManager.displayActionsInInspector)
            {
                EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info);
                return;
            }

            for (int i = 0; i < _target.actions.Count; i++)
            {
                if (_target.actions[i] == null)
                {
                    ACDebug.LogWarning("An empty Action was found, and was deleted");
                    _target.actions.RemoveAt(i);
                    continue;
                }

                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.BeginHorizontal();
                int    typeIndex   = KickStarter.actionsManager.GetActionTypeIndex(_target.actions[i]);
                string actionLabel = " (" + (i).ToString() + ") " + actionsManager.EnabledActions[typeIndex].GetFullTitle() + _target.actions[i].SetLabel();
                _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel);
                if (!_target.actions[i].isEnabled)
                {
                    EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.MaxWidth(100f));
                }

                if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                {
                    ActionSideMenu(i);
                }

                _target.actions[i].isAssetFile = false;

                EditorGUILayout.EndHorizontal();

                if (_target.actions[i].isBreakPoint)
                {
                    EditorGUILayout.HelpBox("Break point", MessageType.None);
                }

                if (_target.actions[i].isDisplayed)
                {
                    GUI.enabled = _target.actions[i].isEnabled;

                    if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString()))
                    {
                        EditorGUILayout.HelpBox("This Action type has been disabled in the Actions Manager", MessageType.Warning);
                    }
                    else
                    {
                        int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex);
                        if (newTypeIndex >= 0)
                        {
                            // Rebuild constructor if Subclass and type string do not match
                            ActionEnd _end = new ActionEnd();
                            _end.resultAction   = _target.actions[i].endAction;
                            _end.skipAction     = _target.actions[i].skipAction;
                            _end.linkedAsset    = _target.actions[i].linkedAsset;
                            _end.linkedCutscene = _target.actions[i].linkedCutscene;

                            Undo.RecordObject(_target, "Change Action type");
                            _target.actions[i] = ActionListEditor.RebuildAction(_target.actions[i], newTypeIndex, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene);
                        }

                        if (_target.useParameters && _target.parameters != null && _target.parameters.Count > 0)
                        {
                            _target.actions[i].ShowGUI(_target.parameters);
                        }
                        else
                        {
                            _target.actions[i].ShowGUI(null);
                        }
                    }
                }

                if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i].numSockets == 2 || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel)
                {
                    _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed);
                }

                GUI.enabled = true;

                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();
            }

            if (GUILayout.Button("Add new action"))
            {
                Undo.RecordObject(_target, "Create action");
                numActions += 1;
            }

            _target.actions = ActionListEditor.ResizeList(_target.actions, numActions);
        }
コード例 #24
0
        public static void ModifyAction(ActionList _target, AC.Action _action, string callback)
        {
            int i = -1;

            if (_action != null && _target.actions.IndexOf(_action) > -1)
            {
                i = _target.actions.IndexOf(_action);
            }

            switch (callback)
            {
            case "Enable":
                Undo.RecordObject(_target, "Enable action");
                _action.isEnabled = true;
                break;

            case "Disable":
                Undo.RecordObject(_target, "Disable action");
                _action.isEnabled = false;
                break;

            case "Cut":
                Undo.RecordObject(_target, "Cut action");
                List <AC.Action> cutList   = new List <AC.Action>();
                AC.Action        cutAction = Object.Instantiate(_action) as AC.Action;
                cutList.Add(cutAction);
                AdvGame.copiedActions = cutList;
                _target.actions.Remove(_action);
                break;

            case "Copy":
                List <AC.Action> copyList   = new List <AC.Action>();
                AC.Action        copyAction = Object.Instantiate(_action) as AC.Action;
                copyAction.ClearIDs();
                copyAction.nodeRect = new Rect(0, 0, 300, 60);
                copyList.Add(copyAction);
                AdvGame.copiedActions = copyList;
                break;

            case "Paste after":
                Undo.RecordObject(_target, "Paste actions");
                List <AC.Action> pasteList = AdvGame.copiedActions;
                _target.actions.InsertRange(i + 1, pasteList);
                AdvGame.DuplicateActionsBuffer();
                break;

            case "Insert end":
                Undo.RecordObject(_target, "Create action");
                AC.Action newAction = ActionList.GetDefaultAction();
                _target.actions.Add(newAction);
                break;

            case "Insert after":
                Undo.RecordObject(_target, "Create action");
                _target.actions.Insert(i + 1, ActionList.GetDefaultAction());
                break;

            case "Delete":
                Undo.RecordObject(_target, "Delete action");
                _target.actions.Remove(_action);
                break;

            case "Move to top":
                Undo.RecordObject(_target, "Move action to top");
                _target.actions[0].nodeRect.x += 30f;
                _target.actions[0].nodeRect.y += 30f;
                _target.actions.Remove(_action);
                _target.actions.Insert(0, _action);
                break;

            case "Move up":
                Undo.RecordObject(_target, "Move action up");
                _target.actions.Remove(_action);
                _target.actions.Insert(i - 1, _action);
                break;

            case "Move to bottom":
                Undo.RecordObject(_target, "Move action to bottom");
                _target.actions.Remove(_action);
                _target.actions.Insert(_target.actions.Count, _action);
                break;

            case "Move down":
                Undo.RecordObject(_target, "Move action down");
                _target.actions.Remove(_action);
                _target.actions.Insert(i + 1, _action);
                break;

            case "Toggle breakpoint":
                Undo.RecordObject(_target, "Toggle breakpoint");
                _action.isBreakPoint = !_action.isBreakPoint;
                break;
            }
        }
コード例 #25
0
ファイル: ActionCheck.cs プロジェクト: mcbodge/eidolon
        private void SkipActionTrueGUI(List<Action> actions, bool showGUI)
        {
            if (skipActionTrue == -1)
            {
                // Set default
                int i = actions.IndexOf (this);
                if (actions.Count > i+1)
                {
                    skipActionTrue = i+1;
                }
                else
                {
                    skipActionTrue = i;
                }
            }

            int tempSkipAction = skipActionTrue;
            List<string> labelList = new List<string>();

            if (skipActionTrueActual)
            {
                bool found = false;

                for (int i = 0; i < actions.Count; i++)
                {
                    labelList.Add (i.ToString () + ": " + actions [i].title);

                    if (skipActionTrueActual == actions [i])
                    {
                        skipActionTrue = i;
                        found = true;
                    }
                }

                if (!found)
                {
                    skipActionTrue = tempSkipAction;
                }
            }

            if (skipActionTrue >= actions.Count)
            {
                skipActionTrue = actions.Count - 1;
            }

            if (showGUI)
            {
                if (actions.Count > 1)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField ("  Action to skip to:");
                    tempSkipAction = EditorGUILayout.Popup (skipActionTrue, labelList.ToArray());
                    skipActionTrue = tempSkipAction;
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.HelpBox ("Cannot skip action - no further Actions available", MessageType.Warning);
                    return;
                }
            }

            skipActionTrueActual = actions [skipActionTrue];
        }
コード例 #26
0
ファイル: ActionCheck.cs プロジェクト: mcbodge/eidolon
 public override void FixLinkAfterDeleting(Action actionToDelete, Action targetAction, List<Action> actionList)
 {
     if ((resultActionFail == ResultAction.Skip && skipActionFailActual == actionToDelete) || (resultActionFail == ResultAction.Continue && actionList.IndexOf (actionToDelete) == (actionList.IndexOf (this) + 1)))
     {
         if (targetAction == null)
         {
             resultActionFail = ResultAction.Stop;
         }
         else
         {
             resultActionFail = ResultAction.Skip;
             skipActionFailActual = targetAction;
         }
     }
     if ((resultActionTrue == ResultAction.Skip && skipActionTrueActual == actionToDelete) || (resultActionTrue == ResultAction.Continue && actionList.IndexOf (actionToDelete) == (actionList.IndexOf (this) + 1)))
     {
         if (targetAction == null)
         {
             resultActionTrue = ResultAction.Stop;
         }
         else
         {
             resultActionTrue = ResultAction.Skip;
             skipActionTrueActual = targetAction;
         }
     }
 }
コード例 #27
0
        private void JumpToActionGUI(List<Action> actions)
        {
            int tempSkipAction = jumpToAction;
            List<string> labelList = new List<string>();

            if (jumpToActionActual)
            {
                bool found = false;

                for (int i = 0; i < actions.Count; i++)
                {
                    labelList.Add (i.ToString () + ": " + actions [i].title);

                    if (jumpToActionActual == actions [i])
                    {
                        jumpToAction = i;
                        found = true;
                    }
                }

                if (!found)
                {
                    jumpToAction = tempSkipAction;
                }
            }

            if (jumpToAction < 0)
            {
                jumpToAction = 0;
            }

            if (jumpToAction >= actions.Count)
            {
                jumpToAction = actions.Count - 1;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField ("  Action to skip to:");
            tempSkipAction = EditorGUILayout.Popup (jumpToAction, labelList.ToArray());
            jumpToAction = tempSkipAction;
            EditorGUILayout.EndHorizontal();
            jumpToActionActual = actions [jumpToAction];
        }
コード例 #28
0
        public static void ModifyAction(ActionList _target, AC.Action _action, string callback)
        {
            int i = -1;

            if (_action != null && _target.actions.IndexOf(_action) > -1)
            {
                i = _target.actions.IndexOf(_action);
            }

            bool doUndo = (callback != "Copy");

            if (doUndo)
            {
                Undo.SetCurrentGroupName(callback);
                Undo.RecordObjects(new UnityEngine.Object [] { _target }, callback);
                Undo.RecordObjects(_target.actions.ToArray(), callback);
            }

            switch (callback)
            {
            case "Enable":
                _action.isEnabled = true;
                break;

            case "Disable":
                _action.isEnabled = false;
                break;

            case "Cut":
                List <AC.Action> cutList   = new List <AC.Action>();
                AC.Action        cutAction = Object.Instantiate(_action) as AC.Action;
                cutAction.name = cutAction.name.Replace("(Clone)", "");
                cutList.Add(cutAction);
                AdvGame.copiedActions = cutList;
                DeleteAction(_action, _target);
                break;

            case "Copy":
                List <AC.Action> copyList   = new List <AC.Action>();
                AC.Action        copyAction = Object.Instantiate(_action) as AC.Action;
                copyAction.name = copyAction.name.Replace("(Clone)", "");
                copyAction.ClearIDs();
                copyAction.nodeRect = new Rect(0, 0, 300, 60);
                copyList.Add(copyAction);
                AdvGame.copiedActions = copyList;
                break;

            case "Paste after":
                List <AC.Action> pasteList = AdvGame.copiedActions;
                _target.actions.InsertRange(i + 1, pasteList);
                AdvGame.DuplicateActionsBuffer();
                break;

            case "Insert end":
                AddAction(ActionsManager.GetDefaultAction(), -1, _target);
                break;

            case "Insert after":
                Action insertAfterAction = AddAction(ActionsManager.GetDefaultAction(), i + 1, _target);
                insertAfterAction.endAction        = _action.endAction;
                insertAfterAction.skipAction       = -1;
                insertAfterAction.skipActionActual = _action.skipActionActual;
                break;

            case "Delete":
                Undo.RecordObject(_target, "Delete action");
                DeleteAction(_action, _target);
                break;

            case "Move to top":
                _target.actions[0].nodeRect.x += 30f;
                _target.actions[0].nodeRect.y += 30f;
                _target.actions.Remove(_action);
                _target.actions.Insert(0, _action);
                break;

            case "Move up":
                _target.actions.Remove(_action);
                _target.actions.Insert(i - 1, _action);
                break;

            case "Move to bottom":
                _target.actions.Remove(_action);
                _target.actions.Insert(_target.actions.Count, _action);
                break;

            case "Move down":
                _target.actions.Remove(_action);
                _target.actions.Insert(i + 1, _action);
                break;

            case "Toggle breakpoint":
                _action.isBreakPoint = !_action.isBreakPoint;
                break;
            }

            if (doUndo)
            {
                Undo.RecordObjects(new UnityEngine.Object [] { _target }, callback);
                Undo.RecordObjects(_target.actions.ToArray(), callback);
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                EditorUtility.SetDirty(_target);
            }
        }
コード例 #29
0
        private void ActionSideMenu(int i)
        {
            ActionList _target = (ActionList) target;
            actionToAffect = _target.actions[i];
            GenericMenu menu = new GenericMenu ();

            if (_target.actions[i].isEnabled)
            {
                menu.AddItem (new GUIContent ("Disable"), false, Callback, "Disable");
            }
            else
            {
                menu.AddItem (new GUIContent ("Enable"), false, Callback, "Enable");
            }
            menu.AddSeparator ("");
            if (!Application.isPlaying)
            {
                if (_target.actions.Count > 1)
                {
                    menu.AddItem (new GUIContent ("Cut"), false, Callback, "Cut");
                }
                menu.AddItem (new GUIContent ("Copy"), false, Callback, "Copy");
            }
            if (AdvGame.copiedActions.Count > 0)
            {
                menu.AddItem (new GUIContent ("Paste after"), false, Callback, "Paste after");
            }
            menu.AddSeparator ("");
            menu.AddItem (new GUIContent ("Insert after"), false, Callback, "Insert after");
            if (_target.actions.Count > 1)
            {
                menu.AddItem (new GUIContent ("Delete"), false, Callback, "Delete");
            }
            if (i > 0 || i < _target.actions.Count-1)
            {
                menu.AddSeparator ("");
            }
            if (i > 0)
            {
                menu.AddItem (new GUIContent ("Re-arrange/Move to top"), false, Callback, "Move to top");
                menu.AddItem (new GUIContent ("Re-arrange/Move up"), false, Callback, "Move up");
            }
            if (i < _target.actions.Count-1)
            {
                menu.AddItem (new GUIContent ("Re-arrange/Move down"), false, Callback, "Move down");
                menu.AddItem (new GUIContent ("Re-arrange/Move to bottom"), false, Callback, "Move to bottom");
            }

            menu.AddSeparator ("");
            menu.AddItem (new GUIContent ("Toggle breakpoint"), false, Callback, "Toggle breakpoint");

            menu.ShowAsContext ();
        }
コード例 #30
0
        public static void ModifyAction(ActionListAsset _target, AC.Action _action, string callback)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager == null)
            {
                return;
            }

            int i = -1;

            if (_action != null && _target.actions.IndexOf(_action) > -1)
            {
                i = _target.actions.IndexOf(_action);
            }

            bool doUndo = (callback != "Copy");

            if (doUndo)
            {
                Undo.SetCurrentGroupName(callback);
                Undo.RecordObjects(new UnityEngine.Object [] { _target }, callback);
                Undo.RecordObjects(_target.actions.ToArray(), callback);
            }

            switch (callback)
            {
            case "Enable":
                _target.actions [i].isEnabled = true;
                break;

            case "Disable":
                _target.actions [i].isEnabled = false;
                break;

            case "Cut":
                List <AC.Action> cutList   = new List <AC.Action>();
                AC.Action        cutAction = Object.Instantiate(_action) as AC.Action;
                cutAction.name = cutAction.name.Replace("(Clone)", "");
                cutList.Add(cutAction);
                AdvGame.copiedActions = cutList;
                DeleteAction(_action, _target);
                break;

            case "Copy":
                List <AC.Action> copyList   = new List <AC.Action>();
                AC.Action        copyAction = Object.Instantiate(_action) as AC.Action;
                copyAction.ClearIDs();
                copyAction.name = copyAction.name.Replace("(Clone)", string.Empty);
                copyList.Add(copyAction);
                AdvGame.copiedActions = copyList;
                break;

            case "Paste after":
                List <AC.Action> pasteList = AdvGame.copiedActions;
                int j = i + 1;
                foreach (AC.Action action in pasteList)
                {
                    if (action == null)
                    {
                        ACDebug.LogWarning("Error when pasting Action - cannot find original. Did you change scene before pasting? If you need to transfer Actions between scenes, copy them to an ActionList asset first.");
                        continue;
                    }

                    AC.Action pastedAction = Object.Instantiate(action) as AC.Action;
                    pastedAction.name = pastedAction.name.Replace("(Clone)", string.Empty);
                    AddAction(pastedAction, j, _target);
                    j++;
                }
                break;

            case "Insert after":
                Action newAction = AddAction(ActionsManager.GetDefaultAction(), i + 1, _target);
                newAction.endAction        = _action.endAction;
                newAction.skipAction       = -1;
                newAction.skipActionActual = _action.skipActionActual;
                break;

            case "Delete":
                DeleteAction(_action, _target);
                break;

            case "Move to top":
                _target.actions.Remove(_action);
                _target.actions.Insert(0, _action);
                break;

            case "Move up":
                _target.actions.Remove(_action);
                _target.actions.Insert(i - 1, _action);
                break;

            case "Move to bottom":
                _target.actions.Remove(_action);
                _target.actions.Insert(_target.actions.Count, _action);
                break;

            case "Move down":
                _target.actions.Remove(_action);
                _target.actions.Insert(i + 1, _action);
                break;
            }

            if (doUndo)
            {
                Undo.RecordObjects(new UnityEngine.Object [] { _target }, callback);
                Undo.RecordObjects(_target.actions.ToArray(), callback);
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                EditorUtility.SetDirty(_target);
            }
        }
コード例 #31
0
		public override void AfterCopy (List<Action> copyList)
		{
			if (resultActionFail == ResultAction.Skip && skipActionFailActual == null && copyList.Count > skipActionFail)
			{
				skipActionFailActual = copyList[skipActionFail];
			}
			if (resultActionTrue == ResultAction.Skip && skipActionTrueActual == null && copyList.Count > skipActionTrue)
			{
				skipActionTrueActual = copyList[skipActionTrue];
			}
		}
コード例 #32
0
        private void ActionSideMenu(AC.Action action)
        {
            ActionListAsset _target = (ActionListAsset) target;

            int i = _target.actions.IndexOf (action);
            actionToAffect = action;
            GenericMenu menu = new GenericMenu ();

            if (action.isEnabled)
            {
                menu.AddItem (new GUIContent ("Disable"), false, Callback, "Disable");
            }
            else
            {
                menu.AddItem (new GUIContent ("Enable"), false, Callback, "Enable");
            }
            menu.AddSeparator ("");
            if (_target.actions.Count > 1)
            {
                menu.AddItem (new GUIContent ("Cut"), false, Callback, "Cut");
            }
            menu.AddItem (new GUIContent ("Copy"), false, Callback, "Copy");
            if (AdvGame.copiedActions.Count > 0)
            {
                menu.AddItem (new GUIContent ("Paste after"), false, Callback, "Paste after");
            }
            menu.AddSeparator ("");
            menu.AddItem (new GUIContent ("Insert after"), false, Callback, "Insert after");
            menu.AddItem (new GUIContent ("Delete"), false, Callback, "Delete");
            if (i > 0 || i < _target.actions.Count-1)
            {
                menu.AddSeparator ("");
            }
            if (i > 0)
            {
                menu.AddItem (new GUIContent ("Re-arrange/Move to top"), false, Callback, "Move to top");
                menu.AddItem (new GUIContent ("Re-arrange/Move up"), false, Callback, "Move up");
            }
            if (i < _target.actions.Count-1)
            {
                menu.AddItem (new GUIContent ("Re-arrange/Move down"), false, Callback, "Move down");
                menu.AddItem (new GUIContent ("Re-arrange/Move to bottom"), false, Callback, "Move to bottom");
            }

            menu.ShowAsContext ();
        }
コード例 #33
0
ファイル: ActionCheck.cs プロジェクト: mcbodge/eidolon
        public override void PrepareToCopy(int originalIndex, List<Action> actionList)
        {
            if (resultActionFail == ResultAction.Continue)
            {
                if (originalIndex == actionList.Count - 1)
                {
                    resultActionFail = ResultAction.Stop;
                }
                else if (actionList [originalIndex + 1].isMarked)
                {
                    resultActionFail = ResultAction.Skip;
                    skipActionFailActual = actionList [originalIndex + 1];
                }
                else
                {
                    resultActionFail = ResultAction.Stop;
                }
            }
            if (resultActionFail == ResultAction.Skip)
            {
                if (skipActionFailActual.isMarked)
                {
                    int place = 0;
                    foreach (Action _action in actionList)
                    {
                        if (_action.isMarked)
                        {
                            if (_action == skipActionFailActual)
                            {
                                skipActionFailActual = null;
                                skipActionFail = place;
                                break;
                            }
                            place ++;
                        }
                    }
                }
                else
                {
                    resultActionFail = ResultAction.Stop;
                }
            }

            if (resultActionTrue == ResultAction.Continue)
            {
                if (originalIndex == actionList.Count - 1)
                {
                    resultActionTrue = ResultAction.Stop;
                }
                else if (actionList [originalIndex + 1].isMarked)
                {
                    resultActionTrue = ResultAction.Skip;
                    skipActionTrueActual = actionList [originalIndex + 1];
                }
                else
                {
                    resultActionTrue = ResultAction.Stop;
                }
            }
            if (resultActionTrue == ResultAction.Skip)
            {
                if (skipActionTrueActual.isMarked)
                {
                    int place = 0;
                    foreach (Action _action in actionList)
                    {
                        if (_action.isMarked)
                        {
                            if (_action == skipActionTrueActual)
                            {
                                skipActionTrueActual = null;
                                skipActionTrue = place;
                                break;
                            }
                            place ++;
                        }
                    }
                }
                else
                {
                    resultActionTrue = ResultAction.Stop;
                }
            }
        }
コード例 #34
0
        public static void ModifyAction(ActionListAsset _target, AC.Action _action, string callback)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager == null)
            {
                return;
            }

            int i = -1;

            if (_action != null && _target.actions.IndexOf(_action) > -1)
            {
                i = _target.actions.IndexOf(_action);
            }

            switch (callback)
            {
            case "Enable":
                Undo.RecordObject(_target, "Enable action");
                _target.actions [i].isEnabled = true;
                break;

            case "Disable":
                Undo.RecordObject(_target, "Disable action");
                _target.actions [i].isEnabled = false;
                break;

            case "Cut":
                Undo.RecordObject(_target, "Cut action");
                List <AC.Action> cutList   = new List <AC.Action>();
                AC.Action        cutAction = Object.Instantiate(_action) as AC.Action;
                cutAction.name = cutAction.name.Replace("(Clone)", "");
                cutList.Add(cutAction);
                AdvGame.copiedActions = cutList;
                _target.actions.Remove(_action);
                Undo.DestroyObjectImmediate(_action);
                //UnityEngine.Object.DestroyImmediate (_action, true);
                AssetDatabase.SaveAssets();
                break;

            case "Copy":
                List <AC.Action> copyList   = new List <AC.Action>();
                AC.Action        copyAction = Object.Instantiate(_action) as AC.Action;
                copyAction.ClearIDs();
                copyAction.name = copyAction.name.Replace("(Clone)", "");
                copyList.Add(copyAction);
                AdvGame.copiedActions = copyList;
                break;

            case "Paste after":
                Undo.RecordObject(_target, "Paste actions");
                List <AC.Action> pasteList = AdvGame.copiedActions;
                int j = i + 1;
                foreach (AC.Action action in pasteList)
                {
                    if (action == null)
                    {
                        ACDebug.LogWarning("Error when pasting Action - cannot find original. Did you change scene before pasting? If you need to transfer Actions between scenes, copy them to an ActionList asset first.");
                        continue;
                    }

                    AC.Action pastedAction = Object.Instantiate(action) as AC.Action;
                    pastedAction.name      = pastedAction.name.Replace("(Clone)", "");
                    pastedAction.hideFlags = HideFlags.HideInHierarchy;
                    _target.actions.Insert(j, pastedAction);
                    j++;
                    AssetDatabase.AddObjectToAsset(pastedAction, _target);
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(pastedAction));
                }
                AssetDatabase.SaveAssets();
                break;

            case "Insert after":
                Undo.RecordObject(_target, "Create action");
                Action newAction = ActionListAssetEditor.AddAction(actionsManager.GetDefaultAction(), i + 1, _target);
                newAction.endAction        = _action.endAction;
                newAction.skipAction       = -1;
                newAction.skipActionActual = _action.skipActionActual;
                break;

            case "Delete":
                Undo.RecordObject(_target, "Delete action");
                _target.actions.Remove(_action);
                Undo.DestroyObjectImmediate(_action);
                //UnityEngine.Object.DestroyImmediate (_action, true);
                AssetDatabase.SaveAssets();
                break;

            case "Move to top":
                Undo.RecordObject(_target, "Move action to top");
                _target.actions.Remove(_action);
                _target.actions.Insert(0, _action);
                break;

            case "Move up":
                Undo.RecordObject(_target, "Move action up");
                _target.actions.Remove(_action);
                _target.actions.Insert(i - 1, _action);
                break;

            case "Move to bottom":
                Undo.RecordObject(_target, "Move action to bottom");
                _target.actions.Remove(_action);
                _target.actions.Insert(_target.actions.Count, _action);
                break;

            case "Move down":
                Undo.RecordObject(_target, "Move action down");
                _target.actions.Remove(_action);
                _target.actions.Insert(i + 1, _action);
                break;
            }
        }
コード例 #35
0
        public static void ModifyAction(ActionListAsset _target, AC.Action _action, string callback)
        {
            ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;

            if (actionsManager == null)
            {
                return;
            }

            int i = -1;

            if (_action != null && _target.actions.IndexOf(_action) > -1)
            {
                i = _target.actions.IndexOf(_action);
            }

            switch (callback)
            {
            case "Enable":
                Undo.RecordObject(_target, "Enable action");
                _target.actions [i].isEnabled = true;
                break;

            case "Disable":
                Undo.RecordObject(_target, "Disable action");
                _target.actions [i].isEnabled = false;
                break;

            case "Cut":
                Undo.RecordObject(_target, "Cut action");
                List <AC.Action> cutList   = new List <AC.Action>();
                AC.Action        cutAction = Object.Instantiate(_action) as AC.Action;
                cutList.Add(cutAction);
                AdvGame.copiedActions = cutList;
                _target.actions.Remove(_action);
                Undo.DestroyObjectImmediate(_action);
                //UnityEngine.Object.DestroyImmediate (_action, true);
                AssetDatabase.SaveAssets();
                break;

            case "Copy":
                List <AC.Action> copyList   = new List <AC.Action>();
                AC.Action        copyAction = Object.Instantiate(_action) as AC.Action;
                copyAction.name = copyAction.name.Replace("(Clone)", "");
                copyList.Add(copyAction);
                AdvGame.copiedActions = copyList;
                break;

            case "Paste after":
                Undo.RecordObject(_target, "Paste actions");
                List <AC.Action> pasteList = AdvGame.copiedActions;
                int j = i + 1;
                foreach (AC.Action action in pasteList)
                {
                    AC.Action pastedAction = Object.Instantiate(action) as AC.Action;
                    pastedAction.name      = pastedAction.name.Replace("(Clone)", "");
                    pastedAction.hideFlags = HideFlags.HideInHierarchy;
                    _target.actions.Insert(j, pastedAction);
                    j++;
                    AssetDatabase.AddObjectToAsset(pastedAction, _target);
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(pastedAction));
                }
                AssetDatabase.SaveAssets();
                break;

            case "Insert after":
                Undo.RecordObject(_target, "Create action");
                ActionListAssetEditor.AddAction(actionsManager.GetDefaultAction(), i + 1, _target);
                break;

            case "Delete":
                Undo.RecordObject(_target, "Delete action");
                _target.actions.Remove(_action);
                Undo.DestroyObjectImmediate(_action);
                //UnityEngine.Object.DestroyImmediate (_action, true);
                AssetDatabase.SaveAssets();
                break;

            case "Move to top":
                Undo.RecordObject(_target, "Move action to top");
                _target.actions.Remove(_action);
                _target.actions.Insert(0, _action);
                break;

            case "Move up":
                Undo.RecordObject(_target, "Move action up");
                _target.actions.Remove(_action);
                _target.actions.Insert(i - 1, _action);
                break;

            case "Move to bottom":
                Undo.RecordObject(_target, "Move action to bottom");
                _target.actions.Remove(_action);
                _target.actions.Insert(_target.actions.Count, _action);
                break;

            case "Move down":
                Undo.RecordObject(_target, "Move action down");
                _target.actions.Remove(_action);
                _target.actions.Insert(i + 1, _action);
                break;
            }
        }
        private void SkipActionTrueGUI(List <Action> actions, bool showGUI)
        {
            if (skipActionTrue == -1)
            {
                // Set default
                int i = actions.IndexOf(this);
                if (actions.Count > i + 1)
                {
                    skipActionTrue = i + 1;
                }
                else
                {
                    skipActionTrue = i;
                }
            }

            int           tempSkipAction = skipActionTrue;
            List <string> labelList      = new List <string>();

            if (skipActionTrueActual)
            {
                bool found = false;

                for (int i = 0; i < actions.Count; i++)
                {
                    labelList.Add(i.ToString() + ": " + actions [i].title);

                    if (skipActionTrueActual == actions [i])
                    {
                        skipActionTrue = i;
                        found          = true;
                    }
                }

                if (!found)
                {
                    skipActionTrue = tempSkipAction;
                }
            }

            if (skipActionTrue >= actions.Count)
            {
                skipActionTrue = actions.Count - 1;
            }

            if (showGUI)
            {
                if (actions.Count > 1)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("  Action to skip to:");
                    tempSkipAction = EditorGUILayout.Popup(skipActionTrue, labelList.ToArray());
                    skipActionTrue = tempSkipAction;
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.HelpBox("Cannot skip action - no further Actions available", MessageType.Warning);
                    return;
                }
            }

            skipActionTrueActual = actions [skipActionTrue];
        }