Example #1
0
    private void PlayStandardAnim(AnimationClip clip, bool doLoop, bool reverse)
    {
        if (character == null)
        {
            return;
        }

        Animation animation = null;

        if (character.spriteChild && character.spriteChild.GetComponent <Animation>())
        {
            animation = character.spriteChild.GetComponent <Animation>();
        }
        if (character.GetComponent <Animation>())
        {
            animation = character.GetComponent <Animation>();
        }

        if (animation != null)
        {
            if (clip != null && animation[clip.name] != null)
            {
                if (!animation [clip.name].enabled)
                {
                    if (doLoop)
                    {
                        AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Loop, character.animCrossfadeSpeed, null, reverse);
                    }
                    else
                    {
                        AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Once, character.animCrossfadeSpeed, null, reverse);
                    }
                }
            }
            else
            {
                if (doLoop)
                {
                    AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Loop, character.animCrossfadeSpeed, null, reverse);
                }
                else
                {
                    AdvGame.PlayAnimClip(animation, AdvGame.GetAnimLayerInt(AnimLayer.Base), clip, AnimationBlendMode.Blend, WrapMode.Once, character.animCrossfadeSpeed, null, reverse);
                }
            }
        }
    }
Example #2
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);
            }
        }
    }
Example #3
0
    public override void TurnHead(Vector2 angles)
    {
        if (character == null)
        {
            return;
        }

        Animation animation = null;

        if (character.spriteChild && character.spriteChild.GetComponent <Animation>())
        {
            animation = character.spriteChild.GetComponent <Animation>();
        }
        if (character.GetComponent <Animation>())
        {
            animation = character.GetComponent <Animation>();
        }

        if (animation == null)
        {
            return;
        }

        // Horizontal
        if (character.headLookLeftAnim && character.headLookRightAnim)
        {
            if (angles.x < 0f)
            {
                animation.Stop(character.headLookRightAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck), character.headLookLeftAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookLeftAnim.name].weight = -angles.x;
                animation [character.headLookLeftAnim.name].speed  = 0f;
            }
            else if (angles.x > 0f)
            {
                animation.Stop(character.headLookLeftAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck), character.headLookRightAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookRightAnim.name].weight = angles.x;
                animation [character.headLookRightAnim.name].speed  = 0f;
            }
            else
            {
                animation.Stop(character.headLookLeftAnim.name);
                animation.Stop(character.headLookRightAnim.name);
            }
        }

        // Vertical
        if (character.headLookUpAnim && character.headLookDownAnim)
        {
            if (angles.y < 0f)
            {
                animation.Stop(character.headLookUpAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck) + 1, character.headLookDownAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookDownAnim.name].weight = -angles.y;
                animation [character.headLookDownAnim.name].speed  = 0f;
            }
            else if (angles.y > 0f)
            {
                animation.Stop(character.headLookDownAnim.name);
                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(AnimLayer.Neck) + 1, character.headLookUpAnim, AnimationBlendMode.Additive, WrapMode.ClampForever, 0f, character.neckBone, 1f);
                animation [character.headLookUpAnim.name].weight = angles.y;
                animation [character.headLookUpAnim.name].speed  = 0f;
            }
            else
            {
                animation.Stop(character.headLookDownAnim.name);
                animation.Stop(character.headLookUpAnim.name);
            }
        }
    }
Example #4
0
    public override void ActionCharAnimSkip(ActionCharAnim action)
    {
        if (action.animChar == null)
        {
            return;
        }

        Animation animation = null;

        if (action.animChar.spriteChild && action.animChar.spriteChild.GetComponent <Animation>())
        {
            animation = action.animChar.spriteChild.GetComponent <Animation>();
        }
        if (character._animation)
        {
            animation = action.animChar._animation;
        }

        if (action.method == ActionCharAnim.AnimMethodChar.PlayCustom && action.clip)
        {
            if (action.layer == AnimLayer.Base)
            {
                action.animChar.charState = CharState.Custom;
                action.blendMode          = AnimationBlendMode.Blend;
                action.playMode           = (AnimPlayMode)action.playModeBase;
            }

            if (action.playMode == AnimPlayMode.PlayOnce)
            {
                if (action.layer == AnimLayer.Base && action.method == ActionCharAnim.AnimMethodChar.PlayCustom)
                {
                    action.animChar.charState = CharState.Idle;
                    action.animChar.ResetBaseClips();
                }
            }
            else
            {
                AdvGame.CleanUnusedClips(animation);

                WrapMode  wrap            = WrapMode.Once;
                Transform mixingTransform = null;

                if (action.layer == AnimLayer.UpperBody)
                {
                    mixingTransform = action.animChar.upperBodyBone;
                }
                else if (action.layer == AnimLayer.LeftArm)
                {
                    mixingTransform = action.animChar.leftArmBone;
                }
                else if (action.layer == AnimLayer.RightArm)
                {
                    mixingTransform = action.animChar.rightArmBone;
                }
                else if (action.layer == AnimLayer.Neck || action.layer == AnimLayer.Head || action.layer == AnimLayer.Face || action.layer == AnimLayer.Mouth)
                {
                    mixingTransform = action.animChar.neckBone;
                }

                if (action.playMode == AnimPlayMode.PlayOnceAndClamp)
                {
                    wrap = WrapMode.ClampForever;
                }
                else if (action.playMode == AnimPlayMode.Loop)
                {
                    wrap = WrapMode.Loop;
                }

                AdvGame.PlayAnimClipFrame(animation, AdvGame.GetAnimLayerInt(action.layer), action.clip, action.blendMode, wrap, action.fadeTime, mixingTransform, 1f);
            }

            AdvGame.CleanUnusedClips(animation);
        }

        else if (action.method == ActionCharAnim.AnimMethodChar.StopCustom && action.clip)
        {
            if (action.clip != action.animChar.idleAnim && action.clip != action.animChar.walkAnim)
            {
                animation.Blend(action.clip.name, 0f, 0f);
            }
        }

        else if (action.method == ActionCharAnim.AnimMethodChar.ResetToIdle)
        {
            action.animChar.ResetBaseClips();

            action.animChar.charState = CharState.Idle;
            AdvGame.CleanUnusedClips(animation);
        }

        else if (action.method == ActionCharAnim.AnimMethodChar.SetStandard)
        {
            if (action.clip != null)
            {
                if (action.standard == AnimStandard.Idle)
                {
                    action.animChar.idleAnim = action.clip;
                }
                else if (action.standard == AnimStandard.Walk)
                {
                    action.animChar.walkAnim = action.clip;
                }
                else if (action.standard == AnimStandard.Run)
                {
                    action.animChar.runAnim = action.clip;
                }
                else if (action.standard == AnimStandard.Talk)
                {
                    action.animChar.talkAnim = action.clip;
                }
            }

            if (action.changeSpeed)
            {
                if (action.standard == AnimStandard.Walk)
                {
                    action.animChar.walkSpeedScale = action.newSpeed;
                }
                else if (action.standard == AnimStandard.Run)
                {
                    action.animChar.runSpeedScale = action.newSpeed;
                }
            }

            if (action.changeSound)
            {
                if (action.standard == AnimStandard.Walk)
                {
                    if (action.newSound != null)
                    {
                        action.animChar.walkSound = action.newSound;
                    }
                    else
                    {
                        action.animChar.walkSound = null;
                    }
                }
                else if (action.standard == AnimStandard.Run)
                {
                    if (action.newSound != null)
                    {
                        action.animChar.runSound = action.newSound;
                    }
                    else
                    {
                        action.animChar.runSound = null;
                    }
                }
            }
        }
    }