Ejemplo n.º 1
0
        /**
         * <summary>Adds a new ActionList, assumed to already be running, to the internal record of currently-running ActionLists, and sets the correct GameState in StateHandler.</summary>
         * <param name = "_list">The ActionList to run</param>
         * <param name = "addToSkipQueue">If True, then the ActionList will be added to the list of ActionLists to skip</param>
         * <param name = "_startIndex">The index number of the Action to start skipping from, if addToSkipQueue = True</param>
         */
        public void AddToList(ActionList _list, bool addToSkipQueue, int _startIndex)
        {
            if (skipQueue.Count == 0 && _list.IsSkippable ())
            {
                addToSkipQueue = true;
            }

            if (!IsListRunning (_list))
            {
                activeLists.Add (_list);

                if (addToSkipQueue && !ListIsInSkipQueue (_list) && _list.IsSkippable ())
                {
                    skipQueue.Add (new SkipList (_list, _startIndex));
                }
            }

            if (_list.conversation)
            {
                conversationOnEnd = _list.conversation;
            }

            if (_list is RuntimeActionList && _list.actionListType == ActionListType.PauseGameplay && !_list.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn (null))
            {
                // Don't affect the gamestate if we want to remain frozen
                return;
            }

            SetCorrectGameState ();
        }
 public ActionListEditorWindowData()
 {
     isLocked = false;
     targetID = 0;
     _target = null;
     targetAsset = null;
 }
Ejemplo n.º 3
0
 public override void AssignValues(List<ActionParameter> parameters)
 {
     if (listSource == ListSource.InScene)
     {
         actionList = AssignFile <ActionList> (parameters, parameterID, constantID, actionList);
     }
 }
        public override void AssignValues(List<ActionParameter> parameters)
        {
            if (listSource == ListSource.InScene)
            {
                actionList = AssignFile <ActionList> (parameters, parameterID, constantID, actionList);
                jumpToAction = AssignInteger (parameters, jumpToActionParameterID, jumpToAction);
            }

            if (localParameters != null && localParameters.Count > 0)
            {
                for (int i=0; i<localParameters.Count; i++)
                {
                    if (parameterIDs.Count > i && parameterIDs[i] >= 0)
                    {
                        int ID = parameterIDs[i];
                        foreach (ActionParameter parameter in parameters)
                        {
                            if (parameter.ID == ID)
                            {
                                localParameters[i].CopyValues (parameter);
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /**
         * <summary>A Constructor that assigns the variables explicitly.</summary>
         * <param name = "_actionList">The ActionList this references. If it is a RuntimeActionList, its assetSource will be assigned to actionListAsset.</param>
         * <param name = "_startIndex">The index number of the Action to skip from</param>
         */
        public SkipList(ActionList _actionList, int _startIndex)
        {
            actionList = _actionList;
            startIndex = _startIndex;

            if (_actionList is RuntimeActionList)
            {
                RuntimeActionList runtimeActionList = (RuntimeActionList) _actionList;
                actionListAsset = runtimeActionList.assetSource;
            }
            else
            {
                actionListAsset = null;
            }
        }
        public ActionListEditorWindowData(ActionListAsset actionListAsset)
        {
            targetID = 0;
            _target = null;
            targetAsset = actionListAsset;

            if (actionListAsset != null)
            {
                isLocked = true;
            }
            else
            {
                isLocked = false;
            }
        }
        public ActionListEditorWindowData(ActionList actionList)
        {
            targetAsset = null;
            _target = actionList;

            if (actionList != null)
            {
                isLocked = true;
                targetID = actionList.GetInstanceID ();
            }
            else
            {
                isLocked = false;
                targetID = 0;
            }
        }
 public static void Init(ActionList actionList)
 {
     if (actionList.source == ActionListSource.AssetFile)
     {
         if (actionList.assetFile != null)
         {
             ActionListEditorWindow.Init (actionList.assetFile);
         }
         else
         {
             ACDebug.Log ("Cannot open ActionList Editor window, as no ActionList asset file has been assigned to " + actionList.gameObject.name + ".");
         }
     }
     else
     {
         ActionListEditorWindow window = CreateWindow ();
         window.AssignNewSource (new ActionListEditorWindowData (actionList));
     }
 }
Ejemplo n.º 9
0
        private void PausePath(ActionListAsset pauseAsset, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;
            pausePathTime = 0f;

            if (pauseAsset.useParameters && parameterID >= 0 && pauseAsset.parameters.Count > parameterID)
            {
                int idToSend = 0;
                if (this.gameObject.GetComponent <ConstantID>())
                {
                    idToSend = this.gameObject.GetComponent <ConstantID>().constantID;
                }
                else
                {
                    Debug.LogWarning (this.gameObject.name + " requires a ConstantID script component!");
                }
                pauseAsset.parameters [parameterID].SetValue (idToSend);
            }

            nodeActionList = AdvGame.RunActionListAsset (pauseAsset);
        }
Ejemplo n.º 10
0
 private void PausePath(float pauseTime)
 {
     charState = CharState.Decelerate;
     pausePath = true;
     pausePathTime = Time.time + pauseTime;
     nodeActionList = null;
 }
Ejemplo n.º 11
0
        private void PausePath(float pauseTime, Cutscene pauseCutscene, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;

            if (pauseCutscene.useParameters && parameterID >= 0 && pauseCutscene.parameters.Count > parameterID)
            {
                pauseCutscene.parameters [parameterID].SetValue (this.gameObject);
            }

            if (pauseTime > 0f)
            {
                pausePathTime = Time.time + pauseTime + 1f;
                StartCoroutine (DelayPathCutscene (pauseTime, pauseCutscene));
            }
            else
            {
                pausePathTime = 0f;
                pauseCutscene.Interact ();
                nodeActionList = pauseCutscene;
            }
        }
Ejemplo n.º 12
0
        private IEnumerator DelayPathActionList(float pauseTime, ActionListAsset pauseAsset)
        {
            yield return new WaitForSeconds (pauseTime);

            pausePathTime = 0f;
            nodeActionList = AdvGame.RunActionListAsset (pauseAsset);
        }
Ejemplo n.º 13
0
        private void ShowParametersGUI(ActionList _target)
        {
            if (_target is AC_Trigger)
            {
                if (_target.parameters.Count != 1)
                {
                    ActionParameter newParameter = new ActionParameter (0);
                    newParameter.parameterType = ParameterType.GameObject;
                    newParameter.label = "Collision object";
                    _target.parameters.Clear ();
                    _target.parameters.Add (newParameter);
                }
                return;
            }

            EditorGUILayout.Space ();
            EditorGUILayout.BeginVertical ("Button");
            EditorGUILayout.LabelField ("Parameters", EditorStyles.boldLabel);
            ActionListEditor.ShowParametersGUI (_target.parameters);

            EditorGUILayout.EndVertical ();
        }
Ejemplo n.º 14
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 ();
         _target.actions.Add (newAction);
     }
 }
 private bool ListIsInSkipQueue(ActionList _list)
 {
     foreach (SkipList skipList in skipQueue)
     {
         if (skipList.actionList == _list)
         {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 16
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            listSource = (ListSource)EditorGUILayout.EnumPopup("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    localParameters.Clear();
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList)EditorGUILayout.ObjectField("ActionList:", actionList, typeof(ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);

                    if (actionList != null)
                    {
                        if (actionList.actions.Contains(this))
                        {
                            EditorGUILayout.HelpBox("This Action cannot be used to run the ActionList it is in - use the Skip option below instead.", MessageType.Warning);
                        }
                        else if (actionList.source == ActionListSource.AssetFile && actionList.assetFile != null && actionList.assetFile.useParameters && actionList.assetFile.parameters.Count > 0)
                        {
                            SetParametersGUI(actionList.assetFile.parameters, parameters);
                        }
                        else if (actionList.source == ActionListSource.InScene && actionList.useParameters && actionList.parameters.Count > 0)
                        {
                            SetParametersGUI(actionList.parameters, parameters);
                        }
                    }
                }


                runFromStart = EditorGUILayout.Toggle("Run from start?", runFromStart);

                if (!runFromStart)
                {
                    jumpToActionParameterID = Action.ChooseParameterGUI("Action # to skip to:", parameters, jumpToActionParameterID, ParameterType.Integer);
                    if (jumpToActionParameterID == -1 && actionList != null && actionList.actions.Count > 1)
                    {
                        JumpToActionGUI(actionList.actions);
                    }
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                assetParameterID = Action.ChooseParameterGUI("ActionList asset:", parameters, assetParameterID, ParameterType.UnityObject);
                if (assetParameterID < 0)
                {
                    invActionList = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", invActionList, typeof(ActionListAsset), true);
                }

                if (invActionList != null)
                {
                    if (invActionList.actions.Contains(this))
                    {
                        EditorGUILayout.HelpBox("This Action cannot be used to run the ActionList it is in - use the Skip option below instead.", MessageType.Warning);
                    }
                    else if (invActionList.useParameters && invActionList.parameters.Count > 0)
                    {
                        SetParametersGUI(invActionList.parameters, parameters);
                    }
                }

                runFromStart = EditorGUILayout.Toggle("Run from start?", runFromStart);

                if (!runFromStart && invActionList != null && invActionList.actions.Count > 1)
                {
                    JumpToActionGUI(invActionList.actions);
                }
            }

            if (!runInParallel)
            {
                Upgrade();
            }

            willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            AfterRunningOption();
        }
Ejemplo n.º 17
0
 /**
  * <summary>Passes the ActionList that the Action is a part of to the Action class. This is run before the Action is called or displayed in an Editor.</summary>
  * <param name = "actionList">The ActionList that the Action is contained in</param>
  */
 public virtual void AssignParentList(ActionList actionList)
 {
 }
        /**
         * <summary>Restores the class's data from a saved string.</summary>
         * <param name = "data">The saved string to restore from</param>
         * <param name = "subScene">If set, only data for a given subscene will be loaded. If null, only data for the active scene will be loaded</param>
         * <returns>True if the data was successfully restored</returns>
         */
        public bool LoadData(string dataString, SubScene subScene = null)
        {
            if (string.IsNullOrEmpty(dataString))
            {
                return(false);
            }

            string[] dataArray = dataString.Split(SaveSystem.colon[0]);

            // ID
            string listName = AdvGame.PrepareStringForLoading(dataArray[0]);

            resumeIndices = new int[0];

            // Resume
            string[] resumeData = dataArray[1].Split("]"[0]);
            if (resumeData.Length > 0)
            {
                List <int> resumeIndexList = new List <int>();
                for (int i = 0; i < resumeData.Length; i++)
                {
                    int resumeIndex = -1;
                    if (int.TryParse(resumeData[i], out resumeIndex) && resumeIndex >= 0)
                    {
                        resumeIndexList.Add(resumeIndex);
                    }
                }
                resumeIndices = resumeIndexList.ToArray();
            }

            // StartIndex
            int.TryParse(dataArray[2], out startIndex);

            // Skip queue
            int j = 0;

            int.TryParse(dataArray[3], out j);
            inSkipQueue = (j == 1) ? true : false;

            // IsRunning
            j = 0;
            int.TryParse(dataArray[4], out j);
            isRunning = (j == 1) ? true : false;

            // Conversation on end
            int convID = 0;

            int.TryParse(dataArray[5], out convID);
            if (convID != 0)
            {
                conversationOnEnd = Serializer.returnComponent <Conversation> (convID, (subScene != null) ? subScene.gameObject : null);
            }

            // Parameter data
            parameterData = dataArray[6];

            // ActionList
            int ID = 0;

            if (int.TryParse(listName, out ID))
            {
                // Scene
                ConstantID constantID = Serializer.returnComponent <ConstantID> (ID, (subScene != null) ? subScene.gameObject : null);
                if (constantID != null && constantID.GetComponent <ActionList>() != null)
                {
                    actionList = constantID.GetComponent <ActionList>();
                    return(true);
                }
            }
            else
            {
                // Asset file
                ActionListAsset tempAsset = ScriptableObject.CreateInstance <ActionListAsset> ();
                actionListAsset = AssetLoader.RetrieveAsset <ActionListAsset> (tempAsset, listName);
                if (actionListAsset != null && actionListAsset != tempAsset)
                {
                    return(true);
                }

                ACDebug.LogWarning("Could not restore data related to the ActionList asset '" + listName + "' - to restore it correctly, the asset must be placed in a folder named Resources.");
            }
            return(false);
        }
Ejemplo n.º 19
0
 /**
  * <summary>A Constructor that copies the values of another SkipList.</summary>
  * <param name = "_skipList">The SkipList to copy</param>
  */
 public SkipList(SkipList _skipList)
 {
     actionList      = _skipList.actionList;
     actionListAsset = _skipList.actionListAsset;
     startIndex      = _skipList.startIndex;
 }
Ejemplo n.º 20
0
 /**
  * The default Constructor.
  */
 public SkipList()
 {
     actionList      = null;
     actionListAsset = null;
     startIndex      = 0;
 }
Ejemplo n.º 21
0
        override public void AssignValues(List <ActionParameter> parameters)
        {
            if (!changeOwn)
            {
                if (actionListSource == ActionListSource.InScene)
                {
                    actionList = AssignFile <ActionList> (actionListConstantID, actionList);
                    if (actionList != null)
                    {
                        if (actionList.source == ActionListSource.AssetFile && actionList.assetFile != null)
                        {
                            if (actionList.syncParamValues && actionList.assetFile.useParameters)
                            {
                                _parameter = GetParameterWithID(actionList.assetFile.parameters, parameterID);
                            }
                            else
                            {
                                _parameter = GetParameterWithID(actionList.parameters, parameterID);
                            }
                        }
                        else if (actionList.source == ActionListSource.InScene && actionList.useParameters)
                        {
                            _parameter = GetParameterWithID(actionList.parameters, parameterID);
                        }
                    }
                }
                else if (actionListSource == ActionListSource.AssetFile)
                {
                    if (actionListAsset != null)
                    {
                        _parameter = GetParameterWithID(actionListAsset.parameters, parameterID);

                        if (_parameter.parameterType == ParameterType.GameObject && !isAssetFile && gameobjectValue != null && gameObjectConstantID == 0)
                        {
                            if (gameobjectValue.GetComponent <ConstantID>())
                            {
                                gameObjectConstantID = gameobjectValue.GetComponent <ConstantID>().constantID;
                            }
                            else
                            {
                                ACDebug.LogWarning("The GameObject '" + gameobjectValue.name + "' must have a Constant ID component in order to be passed as a parameter to an asset file.", gameobjectValue);
                            }
                        }
                    }
                }
            }
            else
            {
                _parameter = GetParameterWithID(parameters, parameterID);

                if (_parameter.parameterType == ParameterType.GameObject && isAssetFile && gameobjectValue != null && gameObjectConstantID == 0)
                {
                    if (gameobjectValue.GetComponent <ConstantID>())
                    {
                        gameObjectConstantID = gameobjectValue.GetComponent <ConstantID>().constantID;
                    }
                    else
                    {
                        ACDebug.LogWarning("The GameObject '" + gameobjectValue.name + "' must have a Constant ID component in order to be passed as a parameter to an asset file.", gameobjectValue);
                    }
                }
            }

            gameobjectValue = AssignFile(gameObjectConstantID, gameobjectValue);
        }
Ejemplo n.º 22
0
 private void ProcessActionList(ActionList actionList, bool onlySeekNew)
 {
     if (actionList != null)
     {
         ProcessActions (actionList.actions, onlySeekNew, true);
         EditorUtility.SetDirty (actionList);
     }
 }
        /**
         * <summary>Resets and removes a ActionList from the internal record of currently-running ActionLists, and sets the correct GameState in StateHandler.</summary>
         * <param name = "_list">The ActionList to end</param>
         */
        public void EndList(ActionList _list)
        {
            if (_list == null)
            {
                return;
            }

            if (IsListRunning (_list))
            {
                activeLists.Remove (_list);
            }

            _list.ResetList ();

            if (_list.conversation == conversationOnEnd && _list.conversation != null)
            {
                if (KickStarter.stateHandler)
                {
                    KickStarter.stateHandler.gameState = GameState.Cutscene;
                }
                else
                {
                    ACDebug.LogWarning ("Could not set correct GameState!");
                }

                ResetSkipVars ();
                conversationOnEnd.Interact ();
                conversationOnEnd = null;
            }
            else
            {
                if (_list is RuntimeActionList && _list.actionListType == ActionListType.PauseGameplay && !_list.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn (null))
                {
                    // Don't affect the gamestate if we want to remain frozen
                    if (KickStarter.stateHandler.gameState != GameState.Cutscene)
                    {
                        ResetSkipVars ();
                    }
                }
                else
                {
                    SetCorrectGameStateEnd ();
                }
            }

            if (_list.autosaveAfter)
            {
                if (!IsGameplayBlocked ())
                {
                    SaveSystem.SaveAutoSave ();
                }
                else
                {
                    saveAfterCutscene = true;
                }
            }

            if (_list is RuntimeActionList)
            {
                RuntimeActionList runtimeActionList = (RuntimeActionList) _list;
                runtimeActionList.DestroySelf ();
            }
        }
Ejemplo n.º 24
0
        public override void Reset(ActionList actionList)
        {
            triggersToWait = 0;

            int ownIndex = actionList.actions.IndexOf(this);

            if (ownIndex == 0)
            {
                ACDebug.LogWarning("The Action '" + category.ToString() + ": " + title + "' should not be first in an ActionList, as it will prevent others from running!");
                return;
            }

            for (int i = 0; i < actionList.actions.Count; i++)
            {
                Action otherAction = actionList.actions[i];

                if (otherAction != this)
                {
                    if (otherAction is ActionCheck)
                    {
                        ActionCheck actionCheck = (ActionCheck)otherAction;
                        if ((actionCheck.resultActionFail == ResultAction.Skip && actionCheck.skipActionFail == ownIndex) ||
                            (actionCheck.resultActionFail == ResultAction.Continue && ownIndex == i + 1))
                        {
                            triggersToWait++;
                        }
                        else if ((actionCheck.resultActionTrue == ResultAction.Skip && actionCheck.skipActionTrue == ownIndex) ||
                                 (actionCheck.resultActionTrue == ResultAction.Continue && ownIndex == i + 1))
                        {
                            triggersToWait++;
                        }
                    }
                    else if (otherAction is ActionCheckMultiple)
                    {
                        ActionCheckMultiple actionCheckMultiple = (ActionCheckMultiple)otherAction;
                        foreach (ActionEnd ending in actionCheckMultiple.endings)
                        {
                            if ((ending.resultAction == ResultAction.Skip && ending.skipAction == ownIndex) ||
                                (ending.resultAction == ResultAction.Continue && ownIndex == i + 1))
                            {
                                triggersToWait++;
                                break;
                            }
                        }
                    }
                    else if (otherAction is ActionParallel)
                    {
                        ActionParallel actionParallel = (ActionParallel)otherAction;
                        foreach (ActionEnd ending in actionParallel.endings)
                        {
                            if ((ending.resultAction == ResultAction.Skip && ending.skipAction == ownIndex) ||
                                (ending.resultAction == ResultAction.Continue && ownIndex == i + 1))
                            {
                                triggersToWait++;
                                break;
                            }
                        }
                    }
                    else
                    {
                        if ((otherAction.endAction == ResultAction.Skip && otherAction.skipAction == ownIndex) ||
                            (otherAction.endAction == ResultAction.Continue && ownIndex == i + 1))
                        {
                            triggersToWait++;
                        }
                    }
                }
            }

            base.Reset(actionList);
        }
Ejemplo n.º 25
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            changeOwn = EditorGUILayout.Toggle("Change own?", changeOwn);
            if (changeOwn)
            {
                if (parameters == null || parameters.Count == 0)
                {
                    EditorGUILayout.HelpBox("This ActionList has no parameters defined!", MessageType.Warning);
                }

                parameterID = Action.ChooseParameterGUI(parameters, parameterID);
                SetParamGUI(parameters);
            }
            else
            {
                actionListSource = (ActionListSource)EditorGUILayout.EnumPopup("Source:", actionListSource);
                if (actionListSource == ActionListSource.InScene)
                {
                    actionList = (ActionList)EditorGUILayout.ObjectField("ActionList:", actionList, typeof(ActionList), true);

                    actionListConstantID = FieldToID <ActionList> (actionList, actionListConstantID);
                    actionList           = IDToField <ActionList> (actionList, actionListConstantID, true);

                    if (actionList != null)
                    {
                        if (actionList.source == ActionListSource.InScene)
                        {
                            if (actionList.useParameters && actionList.parameters.Count > 0)
                            {
                                parameterID = Action.ChooseParameterGUI(actionList.parameters, parameterID);
                                SetParamGUI(actionList.parameters);
                            }
                            else
                            {
                                EditorGUILayout.HelpBox("This ActionList has no parameters defined!", MessageType.Warning);
                            }
                        }
                        else if (actionList.source == ActionListSource.AssetFile && actionList.assetFile != null)
                        {
                            if (actionList.assetFile.useParameters && actionList.assetFile.parameters.Count > 0)
                            {
                                parameterID = Action.ChooseParameterGUI(actionList.assetFile.parameters, parameterID);
                                SetParamGUI(actionList.assetFile.parameters);
                            }
                            else
                            {
                                EditorGUILayout.HelpBox("This ActionList has no parameters defined!", MessageType.Warning);
                            }
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("This ActionList has no parameters defined!", MessageType.Warning);
                        }
                    }
                }
                else if (actionListSource == ActionListSource.AssetFile)
                {
                    actionListAsset = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", actionListAsset, typeof(ActionListAsset), true);

                    if (actionListAsset != null)
                    {
                        if (actionListAsset.useParameters && actionListAsset.parameters.Count > 0)
                        {
                            parameterID = Action.ChooseParameterGUI(actionListAsset.parameters, parameterID);
                            SetParamGUI(actionListAsset.parameters);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("This ActionList Asset has no parameters defined!", MessageType.Warning);
                        }
                    }
                }
            }

            AfterRunningOption();
        }
Ejemplo n.º 26
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;
                cutAction.name = cutAction.name.Replace("(Clone)", "");
                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.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":
                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;
            }
        }
Ejemplo n.º 27
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.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;
            }
        }
Ejemplo n.º 28
0
        protected void DrawSharedElements(ActionList _target)
        {
            if (PrefabUtility.GetPrefabType(_target) == PrefabType.Prefab && _target.source == ActionListSource.InScene)
            {
                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;
                }

                _target.actions[i].AssignParentList(_target);

                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);
        }
Ejemplo n.º 29
0
        protected void DrawSharedElements(ActionList _target)
        {
            if (IsActionListPrefab(_target))
            {
                //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;
                    AddAction(ActionsManager.GetDefaultAction(), -1, _target);
                }
            }

            EditorGUILayout.Space();

            if (_target.source == ActionListSource.InScene)
            {
                ActionListEditor.ResetList(_target);
            }

            actionsManager = AdvGame.GetReferences().actionsManager;
            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 || _target.source == ActionListSource.AssetFile)
            {
                if (Application.isPlaying)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Edit Actions", GUILayout.Height(40f)))
                    {
                        ActionListEditorWindow.OpenForActionList(_target);
                    }

                    bool isRunning = false;
                    if (Application.isPlaying)
                    {
                        if (KickStarter.actionListManager != null)
                        {
                            isRunning = KickStarter.actionListManager.IsListRunning(_target);
                        }
                    }

                    if (isRunning)
                    {
                        if (GUILayout.Button("Stop", GUILayout.Height(40f)))
                        {
                            _target.Kill();
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Run now", GUILayout.Height(40f)))
                        {
                            _target.Interact();
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    if (GUILayout.Button("Edit Actions", GUILayout.Height(40f)))
                    {
                        ActionListEditorWindow.OpenForActionList(_target);
                    }
                }
                return;
            }
            else
            {
                EditorGUILayout.BeginHorizontal();

                GUI.enabled = (_target.source == ActionListSource.InScene);

                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))
                {
                    ActionListEditorWindow.OpenForActionList(_target);
                }
                GUI.enabled = Application.isPlaying;
                if (GUILayout.Button("Run now", EditorStyles.miniButtonRight))
                {
                    _target.Interact();
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.Space();
            }

            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);
                    _target.actions.RemoveAt(i);
                    numActions--;
                    continue;
                }

                _target.actions[i].AssignParentList(_target);

                CustomGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal();
                int typeIndex = actionsManager.GetActionTypeIndex(_target.actions[i]);

                string actionLabel = " (" + i.ToString() + ") " + actionsManager.GetActionTypeLabel(_target.actions[i], true);
                actionLabel = actionLabel.Replace("\r\n", "");
                actionLabel = actionLabel.Replace("\n", "");
                actionLabel = actionLabel.Replace("\r", "");
                if (actionLabel.Length > 40)
                {
                    actionLabel = actionLabel.Substring(0, 40) + "..)";
                }

                _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("", CustomStyles.IconCog))
                {
                    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 is not listed 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] = RebuildAction(_target.actions[i], newTypeIndex, _target, -1, _end);
                        }

                        if (_target.NumParameters > 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;

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

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

            _target = ActionListEditor.ResizeList(_target, numActions);
        }
Ejemplo n.º 30
0
        private void ShowPropertiesGUI(ActionList _target)
        {
            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("ActionList properties", EditorStyles.boldLabel);
            _target.source = (ActionListSource)CustomGUILayout.EnumPopup("Actions source:", _target.source, "", "Where the Actions are stored");
            if (_target.source == ActionListSource.AssetFile)
            {
                _target.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList asset:", _target.assetFile, false, "", "The ActionList asset that stores the Actions");
                if (_target.assetFile && _target.assetFile.NumParameters > 0)
                {
                    _target.syncParamValues = CustomGUILayout.Toggle("Sync parameter values?", _target.syncParamValues, "", "If True, the ActionList asset's parameter values will be shared amongst all linked ActionLists");
                }
            }
            _target.actionListType = (ActionListType)CustomGUILayout.EnumPopup("When running:", _target.actionListType, "", "The effect that running the Actions has on the rest of the game");
            if (_target.actionListType == ActionListType.PauseGameplay)
            {
                _target.isSkippable = CustomGUILayout.Toggle("Is skippable?", _target.isSkippable, "", "If True, the Actions will be skipped when the user presses the 'EndCutscene' Input button");
            }
            _target.tagID = ShowTagUI(_target.actions.ToArray(), _target.tagID);
            if (_target.source == ActionListSource.InScene)
            {
                _target.useParameters = CustomGUILayout.Toggle("Use parameters?", _target.useParameters, "", "If True, ActionParameters can be used to override values within the Action objects");
            }
            else if (_target.source == ActionListSource.AssetFile && _target.assetFile && !_target.syncParamValues && _target.assetFile.useParameters && !Application.isPlaying)
            {
                _target.useParameters = CustomGUILayout.Toggle("Set local parameter values?", _target.useParameters, "", "If True, parameter values set here will be assigned locally, and not on the ActionList asset");
            }
            CustomGUILayout.EndVertical();

            if (_target.source == ActionListSource.InScene)
            {
                EditorGUILayout.Space();
                CustomGUILayout.BeginVertical();

                EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel);
                ShowParametersGUI(_target, null, _target.parameters);

                CustomGUILayout.EndVertical();
            }
            else if (_target.source == ActionListSource.AssetFile && _target.assetFile && _target.assetFile.useParameters)
            {
                if (_target.syncParamValues)
                {
                    EditorGUILayout.Space();
                    CustomGUILayout.BeginVertical();
                    EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel);
                    ShowParametersGUI(null, _target.assetFile, _target.assetFile.GetParameters(), !Application.isPlaying);
                    CustomGUILayout.EndVertical();
                }
                else
                {
                    if (_target.useParameters)
                    {
                        bool isAsset = UnityVersionHandler.IsPrefabFile(_target.gameObject);

                        EditorGUILayout.Space();
                        CustomGUILayout.BeginVertical();

                        EditorGUILayout.LabelField("Local parameters", EditorStyles.boldLabel);
                        ShowLocalParametersGUI(_target.parameters, _target.assetFile.GetParameters(), isAsset);

                        CustomGUILayout.EndVertical();
                    }
                    else
                    {
                        // Use default from asset initially

                        EditorGUILayout.Space();
                        CustomGUILayout.BeginVertical();
                        EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel);
                        if (Application.isPlaying)
                        {
                            ShowParametersGUI(_target, null, _target.parameters);
                        }
                        else
                        {
                            ShowParametersGUI(null, _target.assetFile, _target.assetFile.DefaultParameters, true);
                        }
                        CustomGUILayout.EndVertical();
                    }
                }
            }
        }
Ejemplo n.º 31
0
        private IEnumerator DelayPathCutscene(float pauseTime, Cutscene pauseCutscene)
        {
            yield return new WaitForSeconds (pauseTime);

            pausePathTime = 0f;
            pauseCutscene.Interact ();
            nodeActionList = pauseCutscene;
        }
Ejemplo n.º 32
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);

                    if (newAction == null && !className.StartsWith("AC."))
                    {
                        newAction = (AC.Action)CreateInstance("AC." + className);
                    }
                    if (newAction == null)
                    {
                        newAction = (AC.Action)CreateInstance(ActionsManager.GetDefaultAction());
                    }

                    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);
        }
Ejemplo n.º 33
0
        private void PausePath(float pauseTime, ActionListAsset pauseAsset, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;

            if (pauseAsset.useParameters && parameterID >= 0 && pauseAsset.parameters.Count > parameterID)
            {
                int idToSend = 0;
                if (this.gameObject.GetComponent <ConstantID>())
                {
                    idToSend = this.gameObject.GetComponent <ConstantID>().constantID;
                }
                else
                {
                    ACDebug.LogWarning (this.gameObject.name + " requires a ConstantID script component!");
                }
                pauseAsset.parameters [parameterID].SetValue (idToSend);
            }

            if (pauseTime > 0f)
            {
                pausePathTime = Time.time + pauseTime + 1f;
                StartCoroutine (DelayPathActionList (pauseTime, pauseAsset));
            }
            else
            {
                pausePathTime = 0f;
                nodeActionList = AdvGame.RunActionListAsset (pauseAsset);
            }
        }
Ejemplo n.º 34
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":
                Vector2 newPosition = _target.actions[0].NodeRect.position + new Vector2(30, 30);
                _target.actions[0].NodeRect = new Rect(newPosition, _target.actions[0].NodeRect.size);
                _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;

            case "EditSource":
                var script = MonoScript.FromScriptableObject(_action);
                if (script != null)
                {
                    AssetDatabase.OpenAsset(script);
                }
                break;
            }

            if (doUndo)
            {
                Undo.RecordObjects(new UnityEngine.Object [] { _target }, callback);
                Undo.RecordObjects(_target.actions.ToArray(), callback);
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                EditorUtility.SetDirty(_target);
            }
        }
Ejemplo n.º 35
0
        private void PausePath(Cutscene pauseCutscene, int parameterID)
        {
            charState = CharState.Decelerate;
            pausePath = true;
            pausePathTime = 0f;

            if (pauseCutscene.useParameters && parameterID >= 0 && pauseCutscene.parameters.Count > parameterID)
            {
                pauseCutscene.parameters [parameterID].SetValue (this.gameObject);
            }

            pauseCutscene.Interact ();
            nodeActionList = pauseCutscene;
        }
Ejemplo n.º 36
0
        public static void ShowParametersGUI(ActionList actionList, ActionListAsset actionListAsset, List <ActionParameter> parameters, bool readOnly = false)
        {
            if (parameters.Count > 0)
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(parameters.Count * 22, 10 * 22) + 9));

                for (int i = 0; i < parameters.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();

                    string buttonLabel = parameters[i].label;
                    if (string.IsNullOrEmpty(buttonLabel))
                    {
                        buttonLabel = "(Untitled)";
                    }
                    if (GUILayout.Toggle(selectedParameterIndex == i, parameters[i].ID.ToString() + ": " + buttonLabel, "Button"))
                    {
                        selectedParameterIndex = i;
                    }

                    if (GUILayout.Button(string.Empty, CustomStyles.IconCog))
                    {
                        ParameterSideMenu(actionList, actionListAsset, parameters.Count, i);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndScrollView();
            }

            if (!Application.isPlaying && !readOnly)
            {
                if (GUILayout.Button("Create new parameter", EditorStyles.miniButton))
                {
                    ActionParameter newParameter = new ActionParameter(GetParameterIDArray(parameters));
                    newParameter.parameterType = ParameterType.Integer;
                    parameters.Add(newParameter);
                }
            }

            if (selectedParameterIndex >= 0 && selectedParameterIndex < parameters.Count)
            {
                EditorGUILayout.Space();
                ActionParameter parameter = parameters[selectedParameterIndex];

                if (Application.isPlaying)
                {
                    parameter.ShowGUI(actionListAsset != null);
                }
                else
                {
                    parameter.ShowGUI(actionListAsset != null, false, readOnly);
                }
            }

            /*for (int i=0; i<parameters.Count; i++)
             * {
             *      if (Application.isPlaying)
             *      {
             *              EditorGUILayout.LabelField ("Label " + parameters[i].ID + ":", parameters[i].label);
             *              parameters[i].ShowGUI (actionListAsset != null);
             *      }
             *      else
             *      {
             *              EditorGUILayout.BeginHorizontal ();
             *
             *              if (readOnly)
             *              {
             *                      EditorGUILayout.LabelField ("Label " + parameters[i].ID + ":", parameters[i].label);
             *              }
             *              else
             *              {
             *                      parameters[i].label = CustomGUILayout.TextField ("Label " + parameters[i].ID + ":", parameters[i].label, string.Empty, "The parameter's name");
             *              }
             *              if (GUILayout.Button (string.Empty, CustomStyles.IconCog))
             *              {
             *                      ParameterSideMenu (actionList, actionListAsset, parameters.Count, i);
             *              }
             *
             *              EditorGUILayout.EndHorizontal ();
             *
             *              parameters[i].ShowGUI (actionListAsset != null, false, readOnly);
             *      }
             *
             *      if (i < (parameters.Count - 1))
             *      {
             *              CustomGUILayout.DrawUILine ();
             *      }
             *
             *      if (parameters.Count > 0)
             *      {
             *              EditorGUILayout.Space ();
             *      }
             * }
             *
             * /*if (!Application.isPlaying && !readOnly)
             * {
             *      if (GUILayout.Button ("Create new parameter", EditorStyles.miniButton))
             *      {
             *              ActionParameter newParameter = new ActionParameter (ActionListEditor.GetParameterIDArray (parameters));
             *              newParameter.parameterType = ParameterType.Integer;
             *              parameters.Add (newParameter);
             *      }
             * }*/
        }
Ejemplo n.º 37
0
        private void SetNextNodes()
        {
            pausePath = false;
            nodeActionList = null;

            int tempPrev = targetNode;

            if (this is Player && KickStarter.stateHandler.gameState == GameState.Normal)
            {
                targetNode = activePath.GetNextNode (targetNode, prevNode, true);
            }
            else
            {
                targetNode = activePath.GetNextNode (targetNode, prevNode, false);
            }

            prevNode = tempPrev;

            if (targetNode == 0 && activePath.pathType == AC_PathType.Loop && activePath.teleportToStart)
            {
                Teleport (activePath.transform.position);

                // Set rotation if there is more than one node
                if (activePath.nodes.Count > 1)
                {
                    SetLookDirection (activePath.nodes[1] - activePath.nodes[0], true);
                }
                SetNextNodes ();
                return;
            }

            if (targetNode == -1)
            {
                EndPath ();
            }
        }
Ejemplo n.º 38
0
 /**
  * <summary>A Constructor that copies the values of another SkipList.</summary>
  * <param name = "_skipList">The SkipList to copy</param>
  */
 public SkipList(SkipList _skipList)
 {
     actionList = _skipList.actionList;
     actionListAsset = _skipList.actionListAsset;
     startIndex = _skipList.startIndex;
 }
Ejemplo n.º 39
0
 private void ClearLinesFromActionList(ActionList actionList)
 {
     if (actionList != null)
     {
         ClearLines (actionList.actions);
         EditorUtility.SetDirty (actionList);
     }
 }
Ejemplo n.º 40
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            listSource = (ListSource)EditorGUILayout.EnumPopup("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    localParameters.Clear();
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList)EditorGUILayout.ObjectField("ActionList:", actionList, typeof(ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }

                if (actionList != null && actionList.useParameters && actionList.parameters.Count > 0)
                {
                    SetParametersGUI(actionList.parameters);
                }

                runFromStart = EditorGUILayout.Toggle("Run from start?", runFromStart);

                if (!runFromStart)
                {
                    jumpToActionParameterID = Action.ChooseParameterGUI("Action # to skip to:", parameters, jumpToActionParameterID, ParameterType.Integer);
                    if (jumpToActionParameterID == -1 && actionList != null && actionList.actions.Count > 1)
                    {
                        JumpToActionGUI(actionList.actions);
                    }
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                invActionList = (ActionListAsset)EditorGUILayout.ObjectField("ActionList asset:", invActionList, typeof(ActionListAsset), true);

                if (invActionList != null && invActionList.useParameters && invActionList.parameters.Count > 0)
                {
                    SetParametersGUI(invActionList.parameters);
                }

                runFromStart = EditorGUILayout.Toggle("Run from start?", runFromStart);

                if (!runFromStart && invActionList != null && invActionList.actions.Count > 1)
                {
                    JumpToActionGUI(invActionList.actions);
                }
            }

            if (!runInParallel)
            {
                Upgrade();
            }

            willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            AfterRunningOption();
        }
        /**
         * <summary>Checks if a particular ActionList is running.</summary>
         * <param name = "_list">The ActionList to search for</param>
         * <returns>True if the ActionList is currently running</returns>
         */
        public bool IsListRunning(ActionList _list)
        {
            foreach (ActionList list in activeLists)
            {
                if (list == _list)
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 42
0
 /**
  * The default Constructor.
  */
 public SkipList()
 {
     actionList = null;
     actionListAsset = null;
     startIndex = 0;
 }
Ejemplo n.º 43
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            listSource = (ListSource) EditorGUILayout.EnumPopup ("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI ("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList) EditorGUILayout.ObjectField ("ActionList:", actionList, typeof (ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                actionListAsset = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList asset:", actionListAsset, typeof (ActionListAsset), true);
            }
        }
Ejemplo n.º 44
0
        public void Start()
        {
            bridge = DialogueManager.Instance.GetComponent<AdventureCreatorBridge>();
            actionListManager = KickStarter.actionListManager;
            string actionListSpecifier = GetParameter(0);
            bool wait = !string.Equals(GetParameter(1), "nowait");
            int startAt = GetParameterAsInt(2);
            bool addToSkipQueue = true;

            // Look for a GameObject in the scene matching the specified name:
            GameObject actionListObject = GameObject.Find(actionListSpecifier);
            if (actionListObject != null) {
                actionList = actionListObject.GetComponent<ActionList>();
                if (actionList != null) {
                    if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: AC({1},{2},startAt={3}) starting action list", DialogueDebug.Prefix, actionListSpecifier, (wait ? "wait" : "nowait"), startAt), actionListObject);
                    if (bridge != null && DialogueManager.IsConversationActive) bridge.SyncLuaToAdventureCreator();
                    if (startAt == 0) {
                        actionList.Interact();
                    } else {
                        actionList.Interact(startAt, addToSkipQueue);
                    }
                }
            }

            // Failing that, look for other GameObjects in the scene matching the name:
            if (actionList == null) {
                foreach (GameObject go in GameObject.FindObjectsOfType<GameObject>()) {
                    if (string.Equals(go.name, actionListSpecifier)) {
                        actionList = go.GetComponent<ActionList>();
                        if (actionList != null) {
                            if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: AC({1},{2},startAt={3}) starting action list", DialogueDebug.Prefix, actionListSpecifier, (wait ? "wait" : "nowait"), startAt), go);
                            if (bridge != null && DialogueManager.IsConversationActive) bridge.SyncLuaToAdventureCreator();
                            if (startAt == 0) {
                                actionList.Interact();
                            } else {
                                actionList.Interact(startAt, addToSkipQueue);
                            }
                            break;
                        }
                    }
                }
            }

            // Failing that, try Resources.Load:
            if (actionList == null) {
                var actionListAsset = Resources.Load(actionListSpecifier) as ActionListAsset;
                if (actionListAsset) {
                    if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: AC({1},{2},startAt={3}) starting action list asset", DialogueDebug.Prefix, actionListSpecifier, (wait ? "wait" : "nowait"), startAt));
                    if (bridge != null && DialogueManager.IsConversationActive) bridge.SyncLuaToAdventureCreator();
                    if (startAt == 0) {
                        actionList = AdvGame.RunActionListAsset(actionListAsset);
                    } else {
                        actionList = AdvGame.RunActionListAsset(actionListAsset, startAt, addToSkipQueue);
                    }
                }
            }

            // Failing that, look for an ActionListAsset in all resources of the project:
            if (actionList == null) {
                foreach (ActionListAsset actionListAsset in Resources.FindObjectsOfTypeAll(typeof(ActionListAsset)) as ActionListAsset[]) {
                    if (string.Equals(actionListSpecifier, actionListAsset.name, System.StringComparison.OrdinalIgnoreCase)) {
                        if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: AC({1},{2},startAt={3}) starting action list asset", DialogueDebug.Prefix, actionListSpecifier, (wait ? "wait" : "nowait"), startAt));
                        if (bridge != null && DialogueManager.IsConversationActive) bridge.SyncLuaToAdventureCreator();
                        if (startAt == 0) {
                            actionList = AdvGame.RunActionListAsset(actionListAsset);
                        } else {
                            actionList = AdvGame.RunActionListAsset(actionListAsset, startAt, addToSkipQueue);
                        }
                        break;
                    }
                }
            }

            if (actionList == null) {
                if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: AC(): Can't find action list '{1}'", DialogueDebug.Prefix, actionListSpecifier));
                Stop();
            }
            if (!wait) Stop();
        }
Ejemplo n.º 45
0
        public void CopyFromActionList(ActionList actionList)
        {
            isSkippable = actionList.isSkippable;
            actionListType = actionList.actionListType;
            useParameters = actionList.useParameters;

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

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

            Vector2 firstPosition = new Vector2 (14f, 14f);
            foreach (Action originalAction in actionList.actions)
            {
                if (originalAction == null)
                {
                    continue;
                }

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

                if (actionList.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.isAssetFile = true;
                duplicatedAction.AssignConstantIDs ();
                duplicatedAction.isMarked = false;

                duplicatedAction.hideFlags = HideFlags.HideInHierarchy;

                AssetDatabase.AddObjectToAsset (duplicatedAction, this);
                AssetDatabase.ImportAsset (AssetDatabase.GetAssetPath (duplicatedAction));
                AssetDatabase.SaveAssets ();
                AssetDatabase.Refresh ();

                actions.Add (duplicatedAction);
            }
        }
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            listSource = (ListSource) EditorGUILayout.EnumPopup ("Source:", listSource);
            if (listSource == ListSource.InScene)
            {
                parameterID = Action.ChooseParameterGUI ("ActionList:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    localParameters.Clear ();
                    constantID = 0;
                    actionList = null;
                }
                else
                {
                    actionList = (ActionList) EditorGUILayout.ObjectField ("ActionList:", actionList, typeof (ActionList), true);

                    constantID = FieldToID <ActionList> (actionList, constantID);
                    actionList = IDToField <ActionList> (actionList, constantID, true);
                }

                if (actionList != null && actionList.useParameters && actionList.parameters.Count > 0)
                {
                    SetParametersGUI (actionList.parameters, parameters);
                }

                runFromStart = EditorGUILayout.Toggle ("Run from start?", runFromStart);

                if (!runFromStart)
                {
                    jumpToActionParameterID = Action.ChooseParameterGUI ("Action # to skip to:", parameters, jumpToActionParameterID, ParameterType.Integer);
                    if (jumpToActionParameterID == -1 && actionList != null && actionList.actions.Count > 1)
                    {
                        JumpToActionGUI (actionList.actions);
                    }
                }
            }
            else if (listSource == ListSource.AssetFile)
            {
                invActionList = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList asset:", invActionList, typeof (ActionListAsset), true);

                if (invActionList != null && invActionList.useParameters && invActionList.parameters.Count > 0)
                {
                    SetParametersGUI (invActionList.parameters, parameters);
                }

                runFromStart = EditorGUILayout.Toggle ("Run from start?", runFromStart);

                if (!runFromStart && invActionList != null && invActionList.actions.Count > 1)
                {
                    JumpToActionGUI (invActionList.actions);
                }
            }

            if (!runInParallel)
            {
                Upgrade ();
            }

            willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);
            AfterRunningOption ();
        }