Beispiel #1
0
        /******
         * ANGLES
         *****/
        //gets the proper direction based on the given angle and returns the direction group
        DirectionGroup frameGroupFromAngle(float angle)
        {
            FaceDirection.Direction direction;

            if (angle < 0)
            {
                direction = FaceDirection.Direction.None;
            }
            else
            {
                direction = FaceDirection.GetDirectionFromAngle(angle, use8wayDir);
            }

            DirectionGroup groupToPlay = null;

            foreach (DirectionGroup frameGroup in frameGroups)
            {
                if (frameGroup.direction == direction)
                {
                    groupToPlay = frameGroup;
                    break;
                }
            }

            return(groupToPlay);
        }
Beispiel #2
0
        //plays an animation that is on this animator and creates a coroutine that can be yielded to
        public IEnumerator PlayClipYield(string clipName, float angle)
        {
            if (!animations.ContainsKey(clipName))
            {
                yield break;
            }

            //if same direction is already playing break out of coroutine
            if (currentAni != null && currentAni.name == clipName && currentAni.isPlaying)
            {
                if (currentAni.getCurrentDirGroup.direction == FaceDirection.GetDirectionFromAngle(angle, currentAni.use8wayDir))
                {
                    yield break;
                }
            }

            //stop whatever clip was already playing
            if (currentAni != null && currentAni.isPlaying && currentAni != animations[clipName])
            {
                currentAni.Stop();
            }

            currentAni = animations[clipName];

            yield return(StartCoroutine(currentAni.PlayAnimationYield(angle)));
        }