void Start () {
			// Make sure you get these AnimationState and Skeleton references in Start or Later. Getting and using them in Awake is not guaranteed by default execution order.
			skeletonAnimation = GetComponent<SkeletonAnimation>();
			spineAnimationState = skeletonAnimation.state;
			skeleton = skeletonAnimation.skeleton;

			StartCoroutine(DoDemoRoutine());
		}
Example #2
0
 private void Start()
 {
     m_hActorController.actorData.m_hAnimation = this;
     // Make sure you get these AnimationState and Skeleton references in Start or Later.
     // Getting and using them in Awake is not guaranteed by default execution order.
     m_hSkeletonAnimation   = GetComponent <SkeletonAnimation>();
     m_hSpineAnimationState = m_hSkeletonAnimation.AnimationState;
     m_hSkeleton            = m_hSkeletonAnimation.Skeleton;
 }
Example #3
0
 void Start()
 {
     // Make sure you get these AnimationState and Skeleton references in Start or Later.
     // Getting and using them in Awake is not guaranteed by default execution order.
     skeletonAnimation   = GetComponent <SkeletonAnimation>();
     spineAnimationState = skeletonAnimation.AnimationState;
     skeleton            = skeletonAnimation.Skeleton;
     StartCoroutine(DoDemoRoutine());
 }
Example #4
0
 public override void Init()
 {
     m_lastStatus     = RoleStatus.None;
     m_animationState = m_dock.Anime.AnimationState;
     m_skeleton       = m_dock.Anime.skeleton;
     m_hangAnime      = m_skeleton.Data.FindAnimation(m_dock.HangAnimeName);
     m_moveAnime      = m_skeleton.Data.FindAnimation(m_dock.MoveAnimeName);
     m_landAnime      = m_skeleton.Data.FindAnimation(m_dock.LandAnimeName);
 }
Example #5
0
        public void SetDirection(int i)
        {
            if (GetDirection().charDirection == CharSpine.directions[i].charDirection)
            {
                return;
            }

            CharSpine.currentDirection = CharSpine.directions[i];
            CharSpine.skeletonAnimation.skeletonDataAsset = CharSpine.currentDirection.animation;
            CharSpine.skeletonAnimation.AnimationName     = null;
            CharSpine.skeletonAnimation.Initialize(true);

            Spine.Skeleton skeleton = CharSpine.skeletonAnimation.skeleton;
            skeleton.FlipX = GetDirection().flipX;

            if (SpineData != null)
            {
                switch (GetDirection().charDirection)
                {
                case CharDirection.Left:
                    SpineData.DirectionSetup_Left(skeleton);
                    break;

                case CharDirection.Right:
                    SpineData.DirectionSetup_Right(skeleton);
                    break;

                case CharDirection.Down:
                    SpineData.DirectionSetup_Down(skeleton);
                    break;

                case CharDirection.Up:
                    SpineData.DirectionSetup_Up(skeleton);
                    break;

                case CharDirection.DownLeft:
                    SpineData.DirectionSetup_DownLeft(skeleton);
                    break;

                case CharDirection.DownRight:
                    SpineData.DirectionSetup_DownRight(skeleton);
                    break;

                case CharDirection.UpLeft:
                    SpineData.DirectionSetup_UpLeft(skeleton);
                    break;

                case CharDirection.UpRight:
                    SpineData.DirectionSetup_UpRight(skeleton);
                    break;
                }
            }
        }
Example #6
0
        void Start()
        {
            // Make sure you get these AnimationState and Skeleton references in Start or Later.
            // Getting and using them in Awake is not guaranteed by default execution order.
            skeletonAnimation   = GetComponent <SkeletonAnimation>();
            spineAnimationState = skeletonAnimation.AnimationState;
            skeleton            = skeletonAnimation.Skeleton;
            spineAnimationState.SetAnimation(0, runToIdleAnimationName, false);
            spineAnimationState.AddAnimation(0, idleAnimationName, true, 0);
            skeletonAnimation.SetOrder(123456);

//			StartCoroutine(DoDemoRoutine());
//			StopCoroutine(DoDemoRoutine());
        }
Example #7
0
        void Start()
        {
            // Make sure you get these AnimationState and Skeleton references in Start or Later.
            // Getting and using them in Awake is not guaranteed by default execution order.

            skeletonAnimation   = GetComponent <SkeletonAnimation>();
            spineAnimationState = skeletonAnimation.AnimationState;
            skeleton            = skeletonAnimation.Skeleton;

            foreach (var animation in untriggeredRestState)
            {
                spineAnimationState.SetAnimation(0, animation, true);
            }
        }
Example #8
0
 public Bone(BoneData data, Spine.Skeleton skeleton, Bone parent)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data", "data cannot be null.");
     }
     if (skeleton == null)
     {
         throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
     }
     this.data     = data;
     this.skeleton = skeleton;
     this.parent   = parent;
     this.SetToSetupPose();
 }
Example #9
0
 public static Tweener DoColorTo(this Spine.Skeleton target, Color endValue, float duration)
 {
     return(DOTween.To(() =>
     {
         return new Color(target.r, target.g, target.b, target.a);
     },
                       (Color color) =>
     {
         // target.SetColor(color);
         target.r = color.r;
         target.g = color.g;
         target.b = color.b;
         target.a = color.a;
     }, endValue, duration));
 }
Example #10
0
        protected override void DoAction(CATContext context)
        {
            // Get unique skeletons
            var ors             = new List <SkeletonAnimator>();
            var tions           = new List <SkeletonAnimation>();
            var uniqueSkeletons = new HashSet <Spine.Skeleton>();

            if (includeChildren.GetValue(context))
            {
                target.WithTargets(context, gobj => {
                    ors.AddRange(gobj.GetComponentsInChildren <SkeletonAnimator>());
                    tions.AddRange(gobj.GetComponentsInChildren <SkeletonAnimation>());
                });
            }
            else
            {
                target.WithTargets(context, gobj => {
                    ors.Add(gobj.GetComponent <SkeletonAnimator>());
                    tions.Add(gobj.GetComponent <SkeletonAnimation>());
                });
            }
            for (var i = 0; i < ors.Count; ++i)
            {
                uniqueSkeletons.Add(ors[i].skeleton);
            }
            for (var i = 0; i < tions.Count; ++i)
            {
                uniqueSkeletons.Add(tions[i].skeleton);
            }

            // Flip all collected skeletons
            Spine.Skeleton[] skeletons = new Spine.Skeleton[uniqueSkeletons.Count];
            uniqueSkeletons.CopyTo(skeletons);
            for (var i = 0; i < uniqueSkeletons.Count; ++i)
            {
                var skel = skeletons[i];
                if (setFlipX.GetValue(context))
                {
                    skel.FlipX = flipXNewValue.GetValue(context);
                }
                if (setFlipY.GetValue(context))
                {
                    skel.FlipY = flipYNewValue.GetValue(context);
                }
            }
        }
Example #11
0
        public void Draw(SpineAnimator animator, Matrix world)
        {
            Spine.Skeleton skeleton = animator.Skeleton;

            if (skeleton != null)
            {
                if (animator.Position != Point.Zero)
                {
                    world *= Matrix.CreateTranslation(animator.Position.X, animator.Position.Y, 0);
                }

                spineRenderer.PremultipliedAlpha = animator.Data.PremultipliedAlpha;
                spineRenderer.Effect.World       = world;
                skeleton.X = 0;
                skeleton.Y = 0;
                spineRenderer.Begin();
                spineRenderer.Draw(animator.Skeleton);
                spineRenderer.End();
            }
        }
        public static void SetupAttachmentsUI(Spine.Skeleton skeleton, string[] configs)
        {
            if (skeleton == null)
            {
                return;
            }

            for (int i = 0; i < skeleton.Slots.Items.Length; ++i)
            {
                var slotData = skeleton.Slots.Items[i];
                slotData.Attachment = null;
            }

            for (int i = 0; i < configs.Length; ++i)
            {
                var data = configs[i].Split('/');
                if (data.Length < 3)
                {
                    continue;
                }
                skeleton.SetAttachment(data[1], data[2]);
            }
        }
Example #13
0
 private void AnimationAwake()
 {
     skeletonAnimation   = GameObject.Find("PlayerAnim").GetComponent <SkeletonAnimation>();
     spineAnimationState = skeletonAnimation.AnimationState;
     skeleton            = skeletonAnimation.Skeleton;
 }
Example #14
0
        public void UpdateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY)
        {
            float num17;

            this.ax           = x;
            this.ay           = y;
            this.arotation    = rotation;
            this.ascaleX      = scaleX;
            this.ascaleY      = scaleY;
            this.ashearX      = shearX;
            this.ashearY      = shearY;
            this.appliedValid = true;
            Spine.Skeleton skeleton = this.skeleton;
            Bone           parent   = this.parent;

            if (parent == null)
            {
                float num  = (rotation + 90f) + shearY;
                float num2 = MathUtils.CosDeg(rotation + shearX) * scaleX;
                float num3 = MathUtils.CosDeg(num) * scaleY;
                float num4 = MathUtils.SinDeg(rotation + shearX) * scaleX;
                float num5 = MathUtils.SinDeg(num) * scaleY;
                if (skeleton.flipX)
                {
                    x    = -x;
                    num2 = -num2;
                    num3 = -num3;
                }
                if (skeleton.flipY != yDown)
                {
                    y    = -y;
                    num4 = -num4;
                    num5 = -num5;
                }
                this.a      = num2;
                this.b      = num3;
                this.c      = num4;
                this.d      = num5;
                this.worldX = x + skeleton.x;
                this.worldY = y + skeleton.y;
                return;
            }
            float a = parent.a;
            float b = parent.b;
            float c = parent.c;
            float d = parent.d;

            this.worldX = ((a * x) + (b * y)) + parent.worldX;
            this.worldY = ((c * x) + (d * y)) + parent.worldY;
            switch (this.data.transformMode)
            {
            case TransformMode.Normal:
            {
                float num10 = (rotation + 90f) + shearY;
                float num11 = MathUtils.CosDeg(rotation + shearX) * scaleX;
                float num12 = MathUtils.CosDeg(num10) * scaleY;
                float num13 = MathUtils.SinDeg(rotation + shearX) * scaleX;
                float num14 = MathUtils.SinDeg(num10) * scaleY;
                this.a = (a * num11) + (b * num13);
                this.b = (a * num12) + (b * num14);
                this.c = (c * num11) + (d * num13);
                this.d = (c * num12) + (d * num14);
                return;
            }

            case TransformMode.NoRotationOrReflection:
            {
                float num16 = (a * a) + (c * c);
                if (num16 <= 0.0001f)
                {
                    a     = 0f;
                    c     = 0f;
                    num17 = 90f - (MathUtils.Atan2(d, b) * 57.29578f);
                    break;
                }
                num16 = Math.Abs((float)((a * d) - (b * c))) / num16;
                b     = c * num16;
                d     = a * num16;
                num17 = MathUtils.Atan2(c, a) * 57.29578f;
                break;
            }

            case TransformMode.NoScale:
            case TransformMode.NoScaleOrReflection:
            {
                float num24 = MathUtils.CosDeg(rotation);
                float num25 = MathUtils.SinDeg(rotation);
                float num26 = (a * num24) + (b * num25);
                float num27 = (c * num24) + (d * num25);
                float num28 = (float)Math.Sqrt((double)((num26 * num26) + (num27 * num27)));
                if (num28 > 1E-05f)
                {
                    num28 = 1f / num28;
                }
                num26 *= num28;
                num27 *= num28;
                num28  = (float)Math.Sqrt((double)((num26 * num26) + (num27 * num27)));
                float radians = 1.570796f + MathUtils.Atan2(num27, num26);
                float num30   = MathUtils.Cos(radians) * num28;
                float num31   = MathUtils.Sin(radians) * num28;
                float num32   = MathUtils.CosDeg(shearX) * scaleX;
                float num33   = MathUtils.CosDeg(90f + shearY) * scaleY;
                float num34   = MathUtils.SinDeg(shearX) * scaleX;
                float num35   = MathUtils.SinDeg(90f + shearY) * scaleY;
                if ((this.data.transformMode == TransformMode.NoScaleOrReflection) ? (skeleton.flipX != skeleton.flipY) : (((a * d) - (b * c)) < 0f))
                {
                    num30 = -num30;
                    num31 = -num31;
                }
                this.a = (num26 * num32) + (num30 * num34);
                this.b = (num26 * num33) + (num30 * num35);
                this.c = (num27 * num32) + (num31 * num34);
                this.d = (num27 * num33) + (num31 * num35);
                return;
            }

            case TransformMode.OnlyTranslation:
            {
                float num15 = (rotation + 90f) + shearY;
                this.a = MathUtils.CosDeg(rotation + shearX) * scaleX;
                this.b = MathUtils.CosDeg(num15) * scaleY;
                this.c = MathUtils.SinDeg(rotation + shearX) * scaleX;
                this.d = MathUtils.SinDeg(num15) * scaleY;
                goto Label_04CC;
            }

            default:
                goto Label_04CC;
            }
            float degrees = (rotation + shearX) - num17;
            float num19   = ((rotation + shearY) - num17) + 90f;
            float num20   = MathUtils.CosDeg(degrees) * scaleX;
            float num21   = MathUtils.CosDeg(num19) * scaleY;
            float num22   = MathUtils.SinDeg(degrees) * scaleX;
            float num23   = MathUtils.SinDeg(num19) * scaleY;

            this.a = (a * num20) - (b * num22);
            this.b = (a * num21) - (b * num23);
            this.c = (c * num20) + (d * num22);
            this.d = (c * num21) + (d * num23);
Label_04CC:
            if (skeleton.flipX)
            {
                this.a = -this.a;
                this.b = -this.b;
            }
            if (skeleton.flipY != yDown)
            {
                this.c = -this.c;
                this.d = -this.d;
            }
        }