Esempio n. 1
0
        public void Start()
        {
            string mode = GetParameter(0);

            bridge = DialogueManager.Instance.GetComponent <AdventureCreatorBridge>();
            if (DialogueDebug.LogInfo)
            {
                Debug.Log(string.Format("{0}: Sequencer: ACCam({1})", DialogueDebug.Prefix, mode));
            }
            if (bridge == null)
            {
                if (DialogueDebug.LogWarnings)
                {
                    Debug.LogWarning(string.Format("{0}: Sequencer: ACCam({1}): Can't find AdventureCreatorBridge", DialogueDebug.Prefix, mode));
                }
            }
            else if (string.Equals(mode, "on", System.StringComparison.OrdinalIgnoreCase))
            {
                bridge.EnableACCameraControl();
            }
            else if (string.Equals(mode, "off", System.StringComparison.OrdinalIgnoreCase))
            {
                bridge.DisableACCameraControl();
            }
            else if (string.Equals(mode, "idle", System.StringComparison.OrdinalIgnoreCase))
            {
                bridge.IdleACCameraControl();
            }
            else
            {
                SetGameCamera(mode, GetParameterAsFloat(1));
            }
            Stop();
        }
Esempio n. 2
0
 public override ActionEnd End(List <Action> actions)
 {
     if (bridge == null)
     {
         bridge = DialogueManager.Instance.GetComponent <AdventureCreatorBridge>();
     }
     if (bridge != null)
     {
         bridge.overrideBridge = false;
     }
     return(base.End(actions));
 }
Esempio n. 3
0
        override public float Run()
        {
            /*
             * This function is called when the action is performed.
             *
             * The float to return is the time that the game
             * should wait before moving on to the next action.
             * Return 0f to make the action instantenous.
             *
             * For actions that take longer than one frame,
             * you can return "defaultPauseTime" to make the game
             * re-run this function a short time later. You can
             * use the isRunning boolean to check if the action is
             * being run for the first time, eg:
             */

            if (!isRunning)
            {
                // Sync AC data to Lua:
                AdventureCreatorBridge bridge = DialogueManager.Instance.GetComponent <AdventureCreatorBridge>();
                if (bridge != null)
                {
                    bridge.SyncAdventureCreatorToLua();
                    bridge.skipSyncToLua = true;
                }

                // If the actor is null, use the player's transform:
                if (actor == null)
                {
                    GameObject actorGameObject = GameObject.FindGameObjectWithTag("Player");
                    if (actorGameObject != null)
                    {
                        actor = actorGameObject.transform;
                    }
                }

                // Start the conversation:
                DialogueManager.StartConversation(conversation, actor, conversant);

                isRunning = true;
                return(defaultPauseTime);
            }
            else
            {
                isRunning = DialogueManager.IsConversationActive;
                return(isRunning ? defaultPauseTime : 0);
            }
        }
Esempio n. 4
0
        override public float Run()
        {
            /*
             * This function is called when the action is performed.
             *
             * The float to return is the time that the game
             * should wait before moving on to the next action.
             * Return 0f to make the action instantenous.
             *
             * For actions that take longer than one frame,
             * you can return "defaultPauseTime" to make the game
             * re-run this function a short time later. You can
             * use the isRunning boolean to check if the action is
             * being run for the first time, eg:
             */

            AdventureCreatorBridge.LoadDialogueSystemFromGlobalVariable();

            return(0);
        }
Esempio n. 5
0
        override public float Run()
        {
            if (!isRunning)
            {
                // Sync AC data to Lua:
                if (bridge == null)
                {
                    bridge = DialogueManager.Instance.GetComponent <AdventureCreatorBridge>();
                }
                if (bridge != null)
                {
                    bridge.SyncAdventureCreatorToLua();
                    bridge.skipSyncToLua             = true;
                    bridge.overrideBridge            = overrideBridge;
                    bridge.overrideUseDialogState    = useDialogState;
                    bridge.overrideTakeCameraControl = takeCameraControl;
                }

                // If the actor is null, use the player's transform:
                if (actor == null)
                {
                    GameObject actorGameObject = GameObject.FindGameObjectWithTag("Player");
                    if (actorGameObject != null)
                    {
                        actor = actorGameObject.transform;
                    }
                }

                // Start the conversation:
                DialogueManager.StartConversation(conversation, actor, conversant);

                isRunning = true;
                return(waitUntilFinish ? defaultPauseTime : 0);
            }
            else
            {
                isRunning = DialogueManager.IsConversationActive;
                return((isRunning && waitUntilFinish) ? defaultPauseTime : 0);
            }
        }
Esempio n. 6
0
        override public float Run()
        {
            /*
             * This function is called when the action is performed.
             *
             * The float to return is the time that the game
             * should wait before moving on to the next action.
             * Return 0f to make the action instantenous.
             *
             * For actions that take longer than one frame,
             * you can return "defaultPauseTime" to make the game
             * re-run this function a short time later. You can
             * use the isRunning boolean to check if the action is
             * being run for the first time, eg:
             */

            if (actor == null)
            {
                GameObject actorGameObject = GameObject.FindGameObjectWithTag("Player");
                if (actorGameObject != null)
                {
                    actor = actorGameObject.transform;
                }
            }
            AdventureCreatorBridge bridge = DialogueManager.Instance.GetComponent <AdventureCreatorBridge>();

            if (syncData && (bridge != null))
            {
                bridge.SyncAdventureCreatorToLua();
            }
            DialogueManager.Bark(conversation, actor, conversant);
            if (syncData && (bridge != null))
            {
                bridge.SyncAdventureCreatorToLua();
            }

            return(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 loading it as an asset:
            if (actionList == null)
            {
                DialogueManager.LoadAsset(actionListSpecifier, typeof(ActionListAsset),
                                          (asset) =>
                {
                    var actionListAsset = asset as ActionListAsset;
                    if (actionListAsset != null)
                    {
                        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);
                        }
                        mustDestroyAsset = true;
                    }
                    else
                    {
                        // Failing that, look for an ActionListAsset in all resources of the project:
                        foreach (ActionListAsset anAsset in Resources.FindObjectsOfTypeAll(typeof(ActionListAsset)) as ActionListAsset[])
                        {
                            if (string.Equals(actionListSpecifier, anAsset.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(anAsset);
                                }
                                else
                                {
                                    actionList = AdvGame.RunActionListAsset(anAsset, 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();
                    }
                    else
                    {
                        if (!wait)
                        {
                            Stop();
                        }
                    }
                });
            }
            else
            {
                if (!wait)
                {
                    Stop();
                }
            }
        }
Esempio n. 8
0
        override public float Run()
        {
            if (!isRunning)
            {
                // If StopConversation, just stop and exit immediately:
                if (actionMode == ActionMode.StopConversation)
                {
                    DialogueManager.StopConversation();
                    return(0);
                }

                // Sync AC data to Lua:
                if (bridge == null)
                {
                    bridge = DialogueManager.Instance.GetComponent <AdventureCreatorBridge>();
                }
                if (bridge != null)
                {
                    bridge.SyncAdventureCreatorToLua();
                    bridge.skipSyncToLua             = true;
                    bridge.overrideBridge            = overrideBridge;
                    bridge.overrideUseDialogState    = useDialogState;
                    bridge.overrideTakeCameraControl = takeCameraControl;
                }

                // If the actor is null, use the player's transform:
                if (actor == null)
                {
                    GameObject actorGameObject = GameObject.FindGameObjectWithTag("Player");
                    if (actorGameObject != null)
                    {
                        actor = actorGameObject.transform;
                    }
                }

                // Start the conversation:
                if (specifyEntryID)
                {
                    DialogueManager.StartConversation(conversation, actor, conversant, entryID);
                }
                else
                {
                    DialogueManager.StartConversation(conversation, actor, conversant);
                }

                // Get the active conversation record, in case we're running multiple simultaneous conversations:
                activeConversationRecord = null;
                if (waitUntilFinish && DialogueManager.allowSimultaneousConversations)
                {
                    if (DialogueManager.Instance.activeConversations != null && DialogueManager.Instance.activeConversations.Count > 0)
                    {
                        activeConversationRecord = DialogueManager.instance.activeConversations[DialogueManager.instance.activeConversations.Count - 1];
                    }
                }

                isRunning = true;
                return(waitUntilFinish ? defaultPauseTime : 0);
            }
            else
            {
                isRunning = (activeConversationRecord != null) ? activeConversationRecord.isConversationActive : DialogueManager.IsConversationActive;
                return((isRunning && waitUntilFinish) ? defaultPauseTime : 0);
            }
        }