コード例 #1
0
        public void RunExampleOne()
        {
            // Get the ActionList component
            ActionList actionList = CreateActionList();

            // Make sure we're in gameplay and that no Actions are already running
            if (actionList.AreActionsRunning() || !Application.isPlaying)
            {
                Debug.LogWarning("Cannot run Actions at this time", this);
                return;
            }

            // Declare the Actions within it
            actionList.actions = new List <Action>
            {
                // Show a Console message
                ActionComment.CreateNew("Running Example 1 - move the player, say something, and add an inventory item"),

                // Move the Player to the Marker (note: uses pathfinding, so a NavMesh will need to be set up)
                ActionCharPathFind.CreateNew(KickStarter.player, markerToMoveTo),

                // Have the Player say something (Note: The 'translation ID' parameter is optional)
                ActionSpeech.CreateNew(KickStarter.player, playerSpeechText, playerSpeechTranslationID),

                // Add an item to the Player's inventory
                ActionInventorySet.CreateNew_Add(inventoryItemIDToAdd),

                // Show another Console message
                ActionComment.CreateNew("Example complete!"),
            };

            // Run it
            actionList.Interact();
        }
コード例 #2
0
ファイル: ActionSpeech.cs プロジェクト: ManuelAGC/StarEater
        /**
         * <summary>Creates a new instance of the 'Dialogue: Play speech' Action with key variables already set.</summary>
         * <param name = "characterToSpeak">The character to speak</param>
         * <param name = "subtitleText">What the character says</param>
         * <param name = "translationIDs">The line's translation ID numbers, as generated by the Speech Manager</param>
         * <param name = "waitUntilFinish">If True, the Action will wait until the character has finished speaking</param>
         * <returns>The generated Action</returns>
         */
        public static ActionSpeech CreateNew(Char characterToSpeak, string subtitleText, int[] translationIDs, bool waitUntilFinish = true)
        {
            ActionSpeech newAction = (ActionSpeech)CreateInstance <ActionSpeech>();

            newAction.speaker      = characterToSpeak;
            newAction.messageText  = subtitleText;
            newAction.isBackground = !waitUntilFinish;

            newAction.lineID = -1;
            if (translationIDs != null && translationIDs.Length > 0)
            {
                newAction.multiLineIDs = new int[translationIDs.Length - 1];
                for (int i = 0; i < translationIDs.Length; i++)
                {
                    if (i == 0)
                    {
                        newAction.lineID = translationIDs[i];
                    }
                    else
                    {
                        newAction.multiLineIDs[i - 1] = translationIDs[i];
                    }
                }
            }
            return(newAction);
        }
コード例 #3
0
        public static ActionSpeech New(Char charToSpeak, string subtitleText, bool waitUntilFinish = true, int translationID = -1)
        {
            ActionSpeech newAction = (ActionSpeech)CreateInstance <ActionSpeech>();

            newAction.speaker      = charToSpeak;
            newAction.messageText  = subtitleText;
            newAction.isBackground = !waitUntilFinish;
            newAction.lineID       = translationID;
            return(newAction);
        }
コード例 #4
0
        public override void ActionSpeechGUI(ActionSpeech action, Char speaker)
        {
                        #if UNITY_EDITOR
            action.headClip2D  = EditorGUILayout.TextField("Head animation:", action.headClip2D);
            action.mouthClip2D = EditorGUILayout.TextField("Mouth animation:", action.mouthClip2D);

            if (GUI.changed && action != null)
            {
                EditorUtility.SetDirty(action);
            }
                        #endif
        }
コード例 #5
0
        public override void ActionSpeechGUI(ActionSpeech action, Char speaker)
        {
                        #if UNITY_EDITOR
            if (speaker != null && speaker.talkingAnimation == TalkingAnimation.CustomFace)
            {
                action.headClip  = (AnimationClip)EditorGUILayout.ObjectField("Head animation:", action.headClip, typeof(AnimationClip), true);
                action.mouthClip = (AnimationClip)EditorGUILayout.ObjectField("Mouth animation:", action.mouthClip, typeof(AnimationClip), true);
            }

            if (GUI.changed && action != null)
            {
                EditorUtility.SetDirty(action);
            }
                        #endif
        }
コード例 #6
0
        public override void ActionSpeechRun(ActionSpeech action)
        {
            if (character.GetAnimator() == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(action.headClip2D))
            {
                character.GetAnimator().CrossFade(action.headClip2D, 0.1f, character.headLayer);
            }
            if (!string.IsNullOrEmpty(action.mouthClip2D))
            {
                character.GetAnimator().CrossFade(action.mouthClip2D, 0.1f, character.mouthLayer);
            }
        }
コード例 #7
0
        public override void ActionSpeechSkip(ActionSpeech action)
        {
            if (action.Speaker && action.Speaker.talkingAnimation == TalkingAnimation.CustomFace && (action.headClip || action.mouthClip))
            {
                AdvGame.CleanUnusedClips(action.Speaker.GetAnimation());

                if (action.headClip)
                {
                    AdvGame.PlayAnimClipFrame(action.Speaker.GetAnimation(), AdvGame.GetAnimLayerInt(AnimLayer.Head), action.headClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, action.Speaker.neckBone, 1f);
                }

                if (action.mouthClip)
                {
                    AdvGame.PlayAnimClipFrame(action.Speaker.GetAnimation(), AdvGame.GetAnimLayerInt(AnimLayer.Mouth), action.mouthClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, action.Speaker.neckBone, 1f);
                }
            }
        }
コード例 #8
0
        public override void ActionSpeechRun(ActionSpeech action)
        {
            if (action.headClip2D != "" || action.mouthClip2D != "")
            {
                if (character.GetAnimator() == null)
                {
                    return;
                }

                if (action.headClip2D != "")
                {
                    character.GetAnimator().CrossFade(action.headClip2D, 0.1f, character.headLayer);
                }
                if (action.mouthClip2D != "")
                {
                    character.GetAnimator().CrossFade(action.mouthClip2D, 0.1f, character.mouthLayer);
                }
            }
        }
コード例 #9
0
        public override void ActionSpeechGUI(ActionSpeech action, Char speaker)
        {
                        #if UNITY_EDITOR
            if (speaker != null && speaker.talkingAnimation == TalkingAnimation.CustomFace)
            {
                action.play2DHeadAnim = EditorGUILayout.BeginToggleGroup("Custom head animation?", action.play2DHeadAnim);
                action.headClip2D     = EditorGUILayout.TextField("Head animation:", action.headClip2D);
                action.headLayer      = EditorGUILayout.IntField("Mecanim layer:", action.headLayer);
                EditorGUILayout.EndToggleGroup();

                action.play2DMouthAnim = EditorGUILayout.BeginToggleGroup("Custom mouth animation?", action.play2DMouthAnim);
                action.mouthClip2D     = EditorGUILayout.TextField("Mouth animation:", action.mouthClip2D);
                action.mouthLayer      = EditorGUILayout.IntField("Mecanim layer:", action.mouthLayer);
                EditorGUILayout.EndToggleGroup();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(action);
            }
                        #endif
        }
コード例 #10
0
        public override void ActionSpeechRun(ActionSpeech action)
        {
            if (action.Speaker.talkingAnimation == TalkingAnimation.CustomFace && action.Speaker.GetAnimator())
            {
                if (action.play2DHeadAnim && action.headClip2D != "")
                {
                    try
                    {
                        action.Speaker.GetAnimator().Play(action.headClip2D, action.headLayer);
                    }
                    catch {}
                }

                if (action.play2DMouthAnim && action.mouthClip2D != "")
                {
                    try
                    {
                        action.Speaker.GetAnimator().Play(action.mouthClip2D, action.mouthLayer);
                    }
                    catch {}
                }
            }
        }
コード例 #11
0
        public override void ActionSpeechGUI(ActionSpeech action)
        {
            #if UNITY_EDITOR

            if (action.speaker.talkingAnimation == TalkingAnimation.CustomFace)
            {
                action.play2DHeadAnim = EditorGUILayout.BeginToggleGroup ("Custom head animation?", action.play2DHeadAnim);
                action.headClip2D = EditorGUILayout.TextField ("Head animation:", action.headClip2D);
                action.headLayer = EditorGUILayout.IntField ("Mecanim layer:", action.headLayer);
                EditorGUILayout.EndToggleGroup ();

                action.play2DMouthAnim = EditorGUILayout.BeginToggleGroup ("Custom mouth animation?", action.play2DMouthAnim);
                action.mouthClip2D = EditorGUILayout.TextField ("Mouth animation:", action.mouthClip2D);
                action.mouthLayer = EditorGUILayout.IntField ("Mecanim layer:", action.mouthLayer);
                EditorGUILayout.EndToggleGroup ();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty (action);
            }

            #endif
        }
コード例 #12
0
        public override void ActionSpeechSkip(ActionSpeech action)
        {
            if (action.speaker.talkingAnimation == TalkingAnimation.CustomFace && (action.headClip || action.mouthClip))
            {
                AdvGame.CleanUnusedClips (action.speaker.GetComponent <Animation>());

                if (action.headClip)
                {
                    AdvGame.PlayAnimClipFrame (action.speaker.GetComponent <Animation>(), AdvGame.GetAnimLayerInt (AnimLayer.Head), action.headClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, action.speaker.neckBone, 1f);
                }

                if (action.mouthClip)
                {
                    AdvGame.PlayAnimClipFrame (action.speaker.GetComponent <Animation>(), AdvGame.GetAnimLayerInt (AnimLayer.Mouth), action.mouthClip, AnimationBlendMode.Additive, WrapMode.Once, 0f, action.speaker.neckBone, 1f);
                }
            }
        }
コード例 #13
0
        public override void ActionSpeechGUI(ActionSpeech action)
        {
            #if UNITY_EDITOR

            if (action.speaker.talkingAnimation == TalkingAnimation.CustomFace)
            {
                action.headClip = (AnimationClip) EditorGUILayout.ObjectField ("Head animation:", action.headClip, typeof (AnimationClip), true);
                action.mouthClip = (AnimationClip) EditorGUILayout.ObjectField ("Mouth animation:", action.mouthClip, typeof (AnimationClip), true);
            }

            if (GUI.changed)
            {
                try
                {
                    EditorUtility.SetDirty (action);
                } catch {}
            }

            #endif
        }
コード例 #14
0
 public override void ActionSpeechSkip(ActionSpeech action)
 {
 }
コード例 #15
0
 public override void ActionSpeechSkip(ActionSpeech action)
 {
 }
コード例 #16
0
 public virtual void ActionSpeechGUI(ActionSpeech action)
 {
     #if UNITY_EDITOR
     #endif
 }
コード例 #17
0
ファイル: SpeechManager.cs プロジェクト: IJkeB/Ekster_Final
        private void ExtractSpeech(ActionSpeech action, bool onlySeekNew, bool isInScene)
        {
            string speaker = "";
            bool isPlayer = action.isPlayer;

            if (action.isPlayer)
            {
                if (KickStarter.settingsManager && KickStarter.settingsManager.player)
                {
                    speaker = KickStarter.settingsManager.player.name;
                }
                else
                {
                    speaker = "Player";
                }
            }
            else
            {
                if (!isInScene)
                {
                    action.SetSpeaker ();
                }

                if (action.speaker)
                {
                    speaker = action.speaker.name;
                }
                else
                {
                    speaker = "Narrator";
                }
            }

            if (speaker != "" && action.messageText != "")
            {
                if (onlySeekNew && action.lineID == -1)
                {
                    // Assign a new ID on creation
                    string _scene = "";
                    SpeechLine newLine;
                    if (isInScene)
                    {
                        _scene = EditorApplication.currentScene;
                    }
                    newLine = new SpeechLine (GetIDArray(), _scene, speaker, action.messageText, languages.Count - 1, AC_TextType.Speech, isPlayer);

                    action.lineID = newLine.lineID;
                    lines.Add (newLine);
                }

                else if (!onlySeekNew && action.lineID > -1)
                {
                    // Already has an ID, so don't replace
                    string _scene = "";
                    SpeechLine existingLine;
                    if (isInScene)
                    {
                        _scene = EditorApplication.currentScene;
                    }
                    existingLine = new SpeechLine (action.lineID, _scene, speaker, action.messageText, languages.Count - 1, AC_TextType.Speech, isPlayer);

                    int lineID = SmartAddLine (existingLine);
                    if (lineID >= 0) action.lineID = lineID;
                }
            }
            else
            {
                // Remove from SpeechManager
                action.lineID = -1;
            }
        }
コード例 #18
0
ファイル: AnimEngine.cs プロジェクト: mcbodge/eidolon
 public virtual void ActionSpeechRun(ActionSpeech action)
 {
 }
コード例 #19
0
ファイル: AnimEngine.cs プロジェクト: mcbodge/eidolon
 public virtual void ActionSpeechGUI(ActionSpeech action, Char speaker)
 {
     #if UNITY_EDITOR
     #endif
 }
コード例 #20
0
ファイル: SpeechManager.cs プロジェクト: mcbodge/eidolon
        private void ExtractSpeech(ActionSpeech action, bool onlySeekNew, bool isInScene)
        {
            string speaker = "";
            bool isPlayer = action.isPlayer;
            if (!isPlayer && action.speaker != null && action.speaker is Player)
            {
                isPlayer = true;
            }

            if (isPlayer)
            {
                speaker = "Player";

                if (action.isPlayer && KickStarter.settingsManager != null && KickStarter.settingsManager.player)
                {
                    speaker = KickStarter.settingsManager.player.name;
                }
                else if (action.speaker != null)
                {
                    speaker = action.speaker.name;
                }
            }
            else
            {
                if (!isInScene)
                {
                    action.SetSpeaker ();
                }

                if (action.speaker)
                {
                    speaker = action.speaker.name;
                }
                else
                {
                    speaker = "Narrator";
                }
            }

            if (speaker != "" && action.messageText != "")
            {
                if (separateLines)
                {
                    string[] messages = action.GetSpeechArray ();
                    if (messages != null && messages.Length > 0)
                    {
                        action.lineID = ProcessSpeechLine (onlySeekNew, isInScene, action.lineID, speaker, messages[0], isPlayer);

                        if (messages.Length > 1)
                        {
                            if (action.multiLineIDs == null || action.multiLineIDs.Length != (messages.Length - 1))
                            {
                                List<int> lineIDs = new List<int>();
                                for (int i=1; i<messages.Length; i++)
                                {
                                    if (action.multiLineIDs != null && action.multiLineIDs.Length > (i-1))
                                    {
                                        lineIDs.Add (action.multiLineIDs[i-1]);
                                    }
                                    else
                                    {
                                        lineIDs.Add (-1);
                                    }
                                }
                                action.multiLineIDs = lineIDs.ToArray ();
                            }

                            for (int i=1; i<messages.Length; i++)
                            {
                                action.multiLineIDs [i-1] = ProcessSpeechLine (onlySeekNew, isInScene, action.multiLineIDs [i-1], speaker, messages[i], isPlayer);
                            }
                        }
                    }
                }
                else
                {
                    action.lineID = ProcessSpeechLine (onlySeekNew, isInScene, action.lineID, speaker, action.messageText, isPlayer);
                }
            }
            else
            {
                // Remove from SpeechManager
                action.lineID = -1;
                action.multiLineIDs = null;
            }
        }
コード例 #21
0
        public override void ActionSpeechGUI(ActionSpeech action)
        {
            #if UNITY_EDITOR

            action.headClip2D = EditorGUILayout.TextField ("Head animation:", action.headClip2D);
            action.mouthClip2D = EditorGUILayout.TextField ("Mouth animation:", action.mouthClip2D);

            if (GUI.changed)
            {
                try
                {
                    EditorUtility.SetDirty (action);
                } catch {}
            }

            #endif
        }
コード例 #22
0
        public override void ActionSpeechRun(ActionSpeech action)
        {
            if (action.speaker.talkingAnimation == TalkingAnimation.CustomFace && action.speaker.GetAnimator ())
            {
                if (action.play2DHeadAnim && action.headClip2D != "")
                {
                    try
                    {
                        action.speaker.GetAnimator ().Play (action.headClip2D, action.headLayer);
                    }
                    catch {}
                }

                if (action.play2DMouthAnim && action.mouthClip2D != "")
                {
                    try
                    {
                        action.speaker.GetAnimator ().Play (action.mouthClip2D, action.mouthLayer);
                    }
                    catch {}
                }
            }
        }
 public virtual void ActionSpeechRun(ActionSpeech action)
 {
 }
 public virtual void ActionSpeechSkip(ActionSpeech action)
 {
     ActionSpeechRun(action);
 }
コード例 #25
0
ファイル: AnimEngine.cs プロジェクト: mcbodge/eidolon
 public virtual void ActionSpeechSkip(ActionSpeech action)
 {
     ActionSpeechRun (action);
 }
コード例 #26
0
        public override void ActionSpeechRun(ActionSpeech action)
        {
            if (action.headClip2D != "" || action.mouthClip2D != "")
            {
                if (character.GetAnimator () == null)
                {
                    return;
                }

                if (action.headClip2D != "")
                {
                    character.GetAnimator ().CrossFade (action.headClip2D, 0.1f, character.headLayer);
                }
                if (action.mouthClip2D != "")
                {
                    character.GetAnimator ().CrossFade (action.mouthClip2D, 0.1f, character.mouthLayer);
                }
            }
        }
 public virtual void ActionSpeechGUI(ActionSpeech action, Char speaker)
 {
                 #if UNITY_EDITOR
                 #endif
 }
コード例 #28
0
		private void ExtractSpeech (ActionSpeech action, bool onlySeekNew, bool isInScene)
		{
			string speaker = "";
			
			if (action.isPlayer)
			{
				speaker = "Player";
			}
			else if (action.speaker)
			{
				speaker = action.speaker.name;
			}
			else
			{
				speaker = "Narrator";
			}
			
			if (speaker != "" && action.messageText != "")
			{
				if (onlySeekNew && action.lineID == -1)
				{
					// Assign a new ID on creation
					SpeechLine newLine;
					if (isInScene)
					{
						newLine = new SpeechLine (GetIDArray(), EditorApplication.currentScene, speaker, action.messageText, languages.Count - 1, AC_TextType.Speech);
					}
					else
					{
						newLine = new SpeechLine (GetIDArray(), "", speaker, action.messageText, languages.Count - 1, AC_TextType.Speech);
					}
					action.lineID = newLine.lineID;
					lines.Add (newLine);
				}
				
				else if (!onlySeekNew && action.lineID > -1)
				{
					// Already has an ID, so don't replace
					if (isInScene)
					{
						lines.Add (new SpeechLine (action.lineID, EditorApplication.currentScene, speaker, action.messageText, languages.Count - 1, AC_TextType.Speech));
					}
					else
					{
						lines.Add (new SpeechLine (action.lineID, "", speaker, action.messageText, languages.Count - 1, AC_TextType.Speech));
					}
				}
			}
			else
			{
				// Remove from SpeechManager
				action.lineID = -1;
			}
		}