Exemple #1
0
        public override float Run()
        {
            if (runtimeChar != null)
            {
                if (renderLock_sorting == RenderLock.Set)
                {
                    if (mapType == SortingMapType.OrderInLayer)
                    {
                        runtimeChar.SetSorting(sortingOrder);
                    }
                    else if (mapType == SortingMapType.SortingLayer)
                    {
                        runtimeChar.SetSorting(sortingLayer);
                    }
                }
                else if (renderLock_sorting == RenderLock.Release)
                {
                    runtimeChar.ReleaseSorting();
                }

                if (runtimeChar.GetAnimEngine() != null)
                {
                    runtimeChar.GetAnimEngine().ActionCharRenderRun(this);
                }
            }

            return(0f);
        }
Exemple #2
0
        override public void Skip()
        {
            KickStarter.dialog.KillDialog(true, true);

            SpeechLog log = new SpeechLog();

            log.lineID   = lineID;
            log.fullText = messageText;

            if (runtimeSpeaker)
            {
                log.speakerName = runtimeSpeaker.name;
                if (!noAnimation)
                {
                    runtimeSpeaker.isTalking = false;

                    if (runtimeSpeaker.GetAnimEngine() != null)
                    {
                        runtimeSpeaker.GetAnimEngine().ActionSpeechSkip(this);
                    }
                }
            }

            KickStarter.runtimeVariables.AddToSpeechLog(log);
        }
        override public float Run()
        {
            if (_char)
            {
                if (_char.GetAnimEngine() != null && _char.GetAnimEngine().ActionCharHoldPossible())
                {
                    if (_char.HoldObject(GetObjectToHold(), hand))
                    {
                        if (rotate90)
                        {
                            GetObjectToHold().transform.localEulerAngles = new Vector3(0f, 0f, 90f);
                        }
                        else
                        {
                            GetObjectToHold().transform.localEulerAngles = Vector3.zero;
                        }
                    }
                }
            }
            else
            {
                ACDebug.LogWarning("Could not create animation engine!");
            }

            return(0f);
        }
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
            if (isPlayer)
            {
                if (Application.isPlaying)
                {
                    _char = KickStarter.player;
                }
                else if (AdvGame.GetReferences().settingsManager)
                {
                    _char = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                }
                else
                {
                    EditorGUILayout.HelpBox("A Settings Manager and player must be defined", MessageType.Warning);
                }
            }
            else
            {
                _char = (Char)EditorGUILayout.ObjectField("Character:", _char, typeof(Char), true);

                _charID = FieldToID <Char> (_char, _charID);
                _char   = IDToField <Char> (_char, _charID, true);
            }

            if (_char)
            {
                if (_char.GetAnimEngine() && _char.GetAnimEngine().ActionCharHoldPossible())
                {
                    objectToHoldParameterID = Action.ChooseParameterGUI("Object to hold:", parameters, objectToHoldParameterID, ParameterType.GameObject);
                    if (objectToHoldParameterID >= 0)
                    {
                        objectToHoldID = 0;
                        objectToHold   = null;
                    }
                    else
                    {
                        objectToHold = (GameObject)EditorGUILayout.ObjectField("Object to hold:", objectToHold, typeof(GameObject), true);

                        objectToHoldID = FieldToID(objectToHold, objectToHoldID);
                        objectToHold   = IDToField(objectToHold, objectToHoldID, false);
                    }

                    hand     = (Hand)EditorGUILayout.EnumPopup("Hand:", hand);
                    rotate90 = EditorGUILayout.Toggle("Rotate 90 degrees?", rotate90);
                }
                else
                {
                    EditorGUILayout.HelpBox("This Action is not compatible with this Character's Animation Engine.", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("This Action requires a Character before more options will show.", MessageType.Info);
            }

            AfterRunningOption();
        }
Exemple #5
0
        public override float Run()
        {
            if (runtimeChar)
            {
                if (runtimeChar.GetAnimEngine() != null && runtimeChar.GetAnimEngine().ActionCharHoldPossible())
                {
                    if (runtimeChar.HoldObject(GetObjectToHold(), hand))
                    {
                        GetObjectToHold().transform.localEulerAngles = localEulerAngles;
                    }
                }
            }
            else
            {
                LogWarning("Could not create animation engine!");
            }

            return(0f);
        }
        private float RunSelf(bool isSkipping)
        {
            if (runtimeChar != null)
            {
                if (runtimeChar.GetAnimEngine() != null && runtimeChar.GetAnimEngine().ActionCharHoldPossible())
                {
                    if (charHoldMethod == CharHoldMethod.MoveHandWithIK && runtimeChar.GetAnimEngine().IKEnabled)
                    {
                        if (GetObjectToHold() == null && ikHoldMethod == IKHoldMethod.SetTarget)
                        {
                            return(0f);
                        }

                        switch (hand)
                        {
                        case Hand.Left:
                            ApplyIK(runtimeChar.LeftHandIKController, isSkipping);
                            break;

                        case Hand.Right:
                            ApplyIK(runtimeChar.RightHandIKController, isSkipping);
                            break;

                        default:
                            break;
                        }
                    }
                    else if (charHoldMethod == CharHoldMethod.ParentObjectToHand)
                    {
                        if (runtimeChar.HoldObject(GetObjectToHold(), hand))
                        {
                            GetObjectToHold().transform.localEulerAngles = localEulerAngles;
                        }
                    }
                }
            }
            else
            {
                LogWarning("No character assigned!");
            }

            return(0f);
        }
Exemple #7
0
        override public float Run()
        {
            if (animChar != null)
            {
                if (animChar.GetAnimEngine() != null)
                {
                    return(animChar.GetAnimEngine().ActionCharAnimRun(this));
                }
                else
                {
                    ACDebug.LogWarning("Could not create animation engine for " + animChar.name, animChar);
                }
            }
            else
            {
                ACDebug.LogWarning("Could not create animation engine!");
            }

            return(0f);
        }
        override public float Run()
        {
            if (animChar)
            {
                if (animChar.GetAnimEngine() != null && animChar.GetAnimEngine() is AnimEngine_Spine)
                {
                    AnimEngine_Spine animEngine = animChar.GetAnimEngine() as AnimEngine_Spine;
                    return(animEngine.ActionCharAnimSpineRun(this));
                }
                else
                {
                    ACDebug.LogWarning("Could not create animation engine for " + animChar.name);
                }
            }
            else
            {
                ACDebug.LogWarning("Could not create animation engine!");
            }

            return(0f);
        }
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                if (charToMove)
                {
                    if (!isInstant)
                    {
                        charToMove.Halt();
                    }

                    charToMove.SetLookDirection(GetLookVector(), isInstant);
                    AnimEngine_Spine spineAnimEngine = (AnimEngine_Spine)charToMove.GetAnimEngine();
                    spineAnimEngine.SetDirection(charToMove.GetSpriteDirectionInt());

                    if (!isInstant)
                    {
                        if (willWait)
                        {
                            return(defaultPauseTime);
                        }
                    }
                }

                return(0f);
            }
            else
            {
                if (charToMove.IsTurning())
                {
                    return(defaultPauseTime);
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }
        }
Exemple #10
0
        override public void AssignValues(List <ActionParameter> parameters)
        {
            runtimeAnimChar = AssignFile <Char> (parameters, parameterID, constantID, animChar);
            newSound        = (AudioClip)AssignObject <AudioClip> (parameters, newSoundParameterID, newSound);
            parameterName   = AssignString(parameters, parameterNameID, parameterName);
            clip2D          = AssignString(parameters, clip2DParameterID, clip2D);

            if (isPlayer)
            {
                runtimeAnimChar = KickStarter.player;
            }

            if (runtimeAnimChar != null && runtimeAnimChar.GetAnimEngine() != null)
            {
                runtimeAnimChar.GetAnimEngine().ActionCharAnimAssignValues(this, parameters);
            }
        }
Exemple #11
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            if (lineID > -1)
            {
                if (multiLineIDs != null && multiLineIDs.Length > 0 && AdvGame.GetReferences().speechManager != null && AdvGame.GetReferences().speechManager.separateLines)
                {
                    string IDs = lineID.ToString();
                    foreach (int multiLineID in multiLineIDs)
                    {
                        IDs += ", " + multiLineID;
                    }

                    EditorGUILayout.LabelField("Speech Manager IDs:", IDs);
                }
                else
                {
                    EditorGUILayout.LabelField("Speech Manager ID:", lineID.ToString());
                }
            }

            if (Application.isPlaying && runtimeSpeaker == null)
            {
                AssignValues(parameters);
            }

            isPlayer = EditorGUILayout.Toggle("Player line?", isPlayer);
            if (!isPlayer)
            {
                if (Application.isPlaying)
                {
                    if (runtimeSpeaker)
                    {
                        EditorGUILayout.LabelField("Speaker: " + runtimeSpeaker.name);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("The speaker cannot be assigned while the game is running.", MessageType.Info);
                    }
                }
                else
                {
                    parameterID = Action.ChooseParameterGUI("Speaker:", parameters, parameterID, ParameterType.GameObject);
                    if (parameterID >= 0)
                    {
                        constantID = 0;
                        speaker    = null;
                    }
                    else
                    {
                        speaker = (Char)EditorGUILayout.ObjectField("Speaker:", speaker, typeof(Char), true);

                        constantID = FieldToID <Char> (speaker, constantID);
                        speaker    = IDToField <Char> (speaker, constantID, false);
                    }
                }
            }

            messageParameterID = Action.ChooseParameterGUI("Line text:", parameters, messageParameterID, ParameterType.String);
            if (messageParameterID < 0)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Line text:", GUILayout.Width(65f));
                EditorStyles.textField.wordWrap = true;
                messageText = EditorGUILayout.TextArea(messageText, GUILayout.MaxWidth(400f));
                EditorGUILayout.EndHorizontal();
            }

            Char _speaker = null;

            if (isPlayer)
            {
                if (Application.isPlaying)
                {
                    _speaker = KickStarter.player;
                }
                else if (AdvGame.GetReferences().settingsManager)
                {
                    _speaker = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                }
            }
            else
            {
                _speaker = (Application.isPlaying) ? runtimeSpeaker : speaker;
            }

            if (_speaker != null)
            {
                noAnimation = EditorGUILayout.Toggle("Don't animate speaker?", noAnimation);
                if (!noAnimation)
                {
                    if (_speaker.GetAnimEngine())
                    {
                        _speaker.GetAnimEngine().ActionSpeechGUI(this, _speaker);
                    }
                }
            }
            else if (!isPlayer && parameterID < 0)
            {
                EditorGUILayout.HelpBox("If no Character is set, this line\nwill be considered to be a Narration.", MessageType.Info);
            }

            isBackground = EditorGUILayout.Toggle("Play in background?", isBackground);
            if (!isBackground)
            {
                waitTimeOffset = EditorGUILayout.Slider("Wait time offset (s):", waitTimeOffset, 0f, 4f);
            }

            AfterRunningOption();
        }
Exemple #12
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    parameterID = ChooseParameterGUI("Player ID:", parameters, parameterID, ParameterType.Integer);
                    if (parameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }

                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    if (parameterID < 0 && playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        _char = (playerPrefab != null) ? playerPrefab.playerOb : null;
                    }
                    else
                    {
                        _char = KickStarter.settingsManager.GetDefaultPlayer();
                    }
                }
                else if (Application.isPlaying)
                {
                    _char = KickStarter.player;
                }
                else
                {
                    _char = KickStarter.settingsManager.GetDefaultPlayer();
                }
            }
            else
            {
                parameterID = Action.ChooseParameterGUI("Character:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    _char      = null;
                }
                else
                {
                    _char = (Char)EditorGUILayout.ObjectField("Character:", _char, typeof(Char), true);

                    constantID = FieldToID <Char> (_char, constantID);
                    _char      = IDToField <Char> (_char, constantID, false);
                }
            }

            if (_char)
            {
                EditorGUILayout.Space();
                renderLock_sorting = (RenderLock)EditorGUILayout.EnumPopup("Sorting:", renderLock_sorting);
                if (renderLock_sorting == RenderLock.Set)
                {
                    mapType = (SortingMapType)EditorGUILayout.EnumPopup("Sorting type:", mapType);
                    if (mapType == SortingMapType.OrderInLayer)
                    {
                        sortingOrderParameterID = Action.ChooseParameterGUI("New order:", parameters, sortingOrderParameterID, ParameterType.Integer);
                        if (sortingOrderParameterID < 0)
                        {
                            sortingOrder = EditorGUILayout.IntField("New order:", sortingOrder);
                        }
                    }
                    else if (mapType == SortingMapType.SortingLayer)
                    {
                        sortingLayerParameterID = Action.ChooseParameterGUI("New layer:", parameters, sortingLayerParameterID, ParameterType.String);
                        if (sortingLayerParameterID < 0)
                        {
                            sortingLayer = EditorGUILayout.TextField("New layer:", sortingLayer);
                        }
                    }
                }

                if (_char.GetAnimEngine())
                {
                    _char.GetAnimEngine().ActionCharRenderGUI(this, parameters);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("This Action requires a Character before more options will show.", MessageType.Info);
            }

            EditorGUILayout.Space();
            AfterRunningOption();
        }
Exemple #13
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            if (!Application.isPlaying)
            {
                return;
            }
            character = playerData as AC.Char;

            if (character == null)
            {
                GameObject characterObject = playerData as GameObject;
                if (characterObject != null)
                {
                    character = characterObject.GetComponent <AC.Char>();
                }
            }

            if (character != null)
            {
                if (character.GetAnimEngine() == null)
                {
                    ACDebug.LogWarning("The 2D character animation track requires that " + character + "'s has an animation engine.");
                    return;
                }

                if (!character.GetAnimEngine().isSpriteBased)
                {
                    ACDebug.LogWarning("The 2D character animation track requires that " + character + "'s animation is sprite-based.");
                    return;
                }

                if (character.turn2DCharactersIn3DSpace)
                {
                    ACDebug.LogWarning("For the 2D character animation track to work, " + character + "'s 'Turn root object in 3D?' must be unchecked.");
                    return;
                }

                if (forceDirection)
                {
                    Vector3 lookVector = AdvGame.GetCharLookVector(charDirection);
                    character.SetLookDirection(lookVector, turnInstantly);
                }

                if (lastFramePosition != Vector3.zero)
                {
                    Vector3 deltaPosition = character.transform.position - lastFramePosition;
                    if (Mathf.Approximately(deltaPosition.sqrMagnitude, 0f))
                    {
                        if (character.isTalking && (character.talkingAnimation == TalkingAnimation.Standard || character.animationEngine == AnimationEngine.Custom))
                        {
                            character.GetAnimEngine().PlayTalk();
                        }
                        else
                        {
                            character.GetAnimEngine().PlayIdle();
                        }
                        SetOverrideState(false);
                    }
                    else
                    {
                        SetOverrideState(true);

                        switch (moveSpeed)
                        {
                        case PathSpeed.Walk:
                            character.GetAnimEngine().PlayWalk();
                            break;

                        case PathSpeed.Run:
                            character.GetAnimEngine().PlayRun();
                            break;

                        default:
                            break;
                        }

                        if (!forceDirection)
                        {
                            Vector3 lookVector = new Vector3(deltaPosition.x, 0f, deltaPosition.y);
                            character.SetLookDirection(lookVector, turnInstantly);
                        }
                    }
                }

                lastFramePosition = character.transform.position;
            }
        }
Exemple #14
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is Player?", isPlayer);
            if (isPlayer)
            {
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow)
                {
                    playerParameterID = ChooseParameterGUI("Player ID:", parameters, playerParameterID, ParameterType.Integer);
                    if (playerParameterID < 0)
                    {
                        playerID = ChoosePlayerGUI(playerID, true);
                    }
                }

                if (playerParameterID < 0)
                {
                    if (playerID >= 0)
                    {
                        PlayerPrefab playerPrefab = KickStarter.settingsManager.GetPlayerPrefab(playerID);
                        if (playerPrefab != null)
                        {
                            _char = (Application.isPlaying) ? playerPrefab.GetSceneInstance() : playerPrefab.playerOb;
                        }
                    }
                    else
                    {
                        _char = (Application.isPlaying) ? KickStarter.player : AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                    }
                }
            }
            else
            {
                _char = (Char)EditorGUILayout.ObjectField("Character:", _char, typeof(Char), true);

                _charID = FieldToID <Char> (_char, _charID);
                _char   = IDToField <Char> (_char, _charID, true);
            }

            if (_char != null)
            {
                if (_char.GetAnimEngine() && _char.GetAnimEngine().ActionCharHoldPossible())
                {
                    if (_char.GetAnimEngine().IKEnabled)
                    {
                        charHoldMethod = (CharHoldMethod)EditorGUILayout.EnumPopup("Hold method:", charHoldMethod);
                        if (charHoldMethod == CharHoldMethod.MoveHandWithIK)
                        {
                            ikHoldMethod = (IKHoldMethod)EditorGUILayout.EnumPopup("IK command:", ikHoldMethod);
                        }
                    }
                    else
                    {
                        charHoldMethod = CharHoldMethod.ParentObjectToHand;
                    }

                    if (charHoldMethod == CharHoldMethod.ParentObjectToHand || ikHoldMethod == IKHoldMethod.SetTarget)
                    {
                        objectToHoldParameterID = Action.ChooseParameterGUI("Object to hold:", parameters, objectToHoldParameterID, ParameterType.GameObject);
                        if (objectToHoldParameterID >= 0)
                        {
                            objectToHoldID = 0;
                            objectToHold   = null;
                        }
                        else
                        {
                            objectToHold = (GameObject)EditorGUILayout.ObjectField("Object to hold:", objectToHold, typeof(GameObject), true);

                            objectToHoldID = FieldToID(objectToHold, objectToHoldID);
                            objectToHold   = IDToField(objectToHold, objectToHoldID, false);
                        }
                    }

                    hand = (Hand)EditorGUILayout.EnumPopup("Hand:", hand);

                    if (charHoldMethod == CharHoldMethod.ParentObjectToHand)
                    {
                        localEulerAnglesParameterID = Action.ChooseParameterGUI("Object local angles:", parameters, localEulerAnglesParameterID, ParameterType.Vector3);
                        if (localEulerAnglesParameterID < 0)
                        {
                            localEulerAngles = EditorGUILayout.Vector3Field("Object local angles:", localEulerAngles);
                        }
                    }
                    else if (charHoldMethod == CharHoldMethod.MoveHandWithIK && ikHoldMethod == IKHoldMethod.SetTarget)
                    {
                        ikTransitionCurve = EditorGUILayout.CurveField("Transition curve:", ikTransitionCurve);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("This Action is not compatible with this Character's Animation Engine.", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("This Action requires a Character before more options will show.", MessageType.Info);
            }

            AfterRunningOption();
        }