Exemplo n.º 1
0
        private void SetWalkAnimation(AnimationClip walkClip)
        {
            if (mWalkState != null)
            {
                mWalkState.Dispose();
            }
            mWalkState = new AnimationSequence(walkClip.name);
            mWalkState.AddListing(new AnimationSequence.Listing(walkClip, new AnimationLoopCount()));

            foreach (XmlNode walkSpeed in mWalkSpeedDocument.SelectNodes("WalkSpeeds/WalkSpeed"))
            {
                if (walkSpeed.SelectSingleNode("ClipName").InnerText == walkClip.name)
                {
                    mWalkAnimationSpeed = float.Parse(walkSpeed.SelectSingleNode("Speed").InnerText);

                    mAvatarEntity.MaxWalkSpeed = mWalkAnimationSpeed;

                    CheckIfReadyToStartAnimation();
                    return;
                }
            }
            mWalkAnimationSpeed        = 1.0f;
            mAvatarEntity.MaxWalkSpeed = mWalkAnimationSpeed;
            CheckIfReadyToStartAnimation();
        }
        public override void HandleNotification(INotification notification)
        {
            switch (notification.Name)
            {
            case GameFacade.PLAY_EMOTE:
                string emoteName = notification.Body as string;
                if (emoteName == null)
                {
                    Console.LogError("Unable to parse notification.Body into emoteName");
                    return;
                }
                RigAnimationName animationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), emoteName);
                GameFacade.Instance.RetrieveProxy <AnimationProxy>().GetRigAnimation(animationName, delegate(AnimationClip animationClip)
                {
                    AnimationSequence emoteSequence = new AnimationSequence(animationClip.name, true);
                    emoteSequence.AddListing(new AnimationSequence.Listing(animationClip, new AnimationLoopCount(1, 1)));
                    Emote emote = new Emote(animationName, emoteSequence);

                    // Send emote message so other clients see us emoting
                    GameFacade.Instance.RetrieveProxy <LocalAvatarProxy>().LocalAvatarDistributedObject.SendEmoteUpdate(emote.Name.ToString());
                    PlayEmote(emote);
                });
                break;
            }
        }
Exemplo n.º 3
0
        public static AnimationSequence LoadAnimationsFromRig(string name, UnityEngine.Animation animationComponent)
        {
            AnimationSequence result = new AnimationSequence(name);

            foreach (AnimationState animationState in animationComponent)
            {
                string[] splitName = animationState.clip.name.Split(':');
                if (splitName.Length == 0)
                {
                    throw new Exception("AnimationState on " + animationComponent.gameObject.name + " does not follow the naming convention. (ex. 'Walk:Default:Loop')");
                }

                if (splitName[0] == name)
                {
                    if (splitName[2] == "Start")
                    {
                        result.AddFirstListing
                        (
                            new AnimationSequence.Listing
                            (
                                animationState.clip,
                                new AnimationLoopCount(1)
                            )
                        );
                    }
                    else if (splitName[2] == "End")
                    {
                        result.AddLastListing
                        (
                            new AnimationSequence.Listing
                            (
                                animationState.clip,
                                new AnimationLoopCount(1)
                            )
                        );
                    }
                    else
                    {
                        result.AddListing
                        (
                            new AnimationSequence.Listing
                            (
                                animationState.clip,
                                new AnimationLoopCount(1)
                            )
                        );
                    }
                }
            }

            if (result == null)
            {
                throw new Exception("Unable to find animation (" + name + ") on rig");
            }
            return(result);
        }
Exemplo n.º 4
0
 private void SetIdleAnimation(AnimationClip idleClip)
 {
     if (mIdleState != null)
     {
         mIdleState.Dispose();
     }
     mIdleState = new AnimationSequence(idleClip.name);
     mIdleState.AddListing(new AnimationSequence.Listing(idleClip, new AnimationLoopCount()));
     CheckIfReadyToStartAnimation();
 }
        public void PlayEmote(string emoteName)
        {
            RigAnimationName animationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), emoteName);

            GameFacade.Instance.RetrieveProxy <AnimationProxy>().GetRigAnimation(animationName, delegate(AnimationClip animationClip)
            {
                AnimationSequence emoteSequence = new AnimationSequence(animationClip.name, true);
                emoteSequence.AddListing(new AnimationSequence.Listing(animationClip, new AnimationLoopCount(1, 1)));
                Emote emote = new Emote(animationName, emoteSequence);
                this.PlayEmote(emote);
            });
        }