Exemplo n.º 1
0
    /// <summary>This is an infinitely repeating Unity Coroutine. Read the Unity documentation on Coroutines to learn more.</summary>
    IEnumerator DoDemoRoutine()
    {
        while (true)
        {
            // SetAnimation is the basic way to set an animation.
            // SetAnimation sets the animation and starts playing it from the beginning.
            // Common Mistake: If you keep calling it in Update, it will keep showing the first pose of the animation, do don't do that.

            spineAnimationState.SetAnimation(0, walkAnimationName, true);
            yield return(new WaitForSeconds(1.5f));

            // skeletonAnimation.AnimationName = runAnimationName; // this line also works for quick testing/simple uses.
            spineAnimationState.SetAnimation(0, runAnimationName, true);
            yield return(new WaitForSeconds(1.5f));

            spineAnimationState.SetAnimation(0, idleAnimationName, true);
            yield return(new WaitForSeconds(1f));

            skeleton.FlipX = true;                      // skeleton allows you to flip the skeleton.
            yield return(new WaitForSeconds(0.5f));

            skeleton.FlipX = false;
            yield return(new WaitForSeconds(0.5f));
        }
    }
    IEnumerator DoDemoRoutine()
    {
        while (true)
        {
            animationState.SetAnimation(0, walkAnimation, true);
            yield return(new WaitForSeconds(runDuration));

            animationState.SetAnimation(0, runAnimation, true);
            yield return(new WaitForSeconds(runDuration));

            animationState.SetAnimation(0, runToIdleAnimation, false);
            animationState.AddAnimation(0, idleAnimation, false, 0);
            yield return(new WaitForSeconds(1f));

            skeletonAnimation.skeleton.flipX = true;
            animationState.SetAnimation(0, idleTurnAnimation, false);
            animationState.AddAnimation(0, idleAnimation, false, 0);
            yield return(new WaitForSeconds(0.5f));

            animationState.SetAnimation(0, idleTurnAnimation, false);
            animationState.AddAnimation(0, idleAnimation, false, 0);
            skeletonAnimation.skeleton.flipX = false;
            yield return(new WaitForSeconds(0.5f));
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        AnimCounter        += Time.deltaTime;
        LifeTimeCounter    += Time.deltaTime;
        transform.position += Direction * Speed;
        if (AnimCounter > AnimDuration)
        {
            AnimCounter = 0;

            var animationRange = Random.Range(0f, 1f);

            if (animationRange > 0.5f)
            {
                spineAnimationState.SetAnimation(0, "flap", true);
            }
            else
            {
                spineAnimationState.SetAnimation(0, "idle", true);
            }
        }
        //if (LifeTimeCounter > LifeTime)
        //{
        //    Object.Destroy(this.gameObject);
        //}
    }
    public void walk()
    {
//        print("PlayerAnimationController walk");


        //mAnimationState.SetAnimation(1, walkName, true);
        // mSkeletonAnimation.AnimationName = walkName;
        // if(mAnimationState.GetCurrent(1).)
        mAnimationState.TimeScale = 2f;


        //if (state != walkName)
        //{
        Spine.TrackEntry now = mAnimationState.GetCurrent(1);
        if (now != null && now.animation != null && now.animation.name == walkName && !now.IsComplete)
        {
            //此时请动画正在执行。
        }
        else
        {
            Spine.TrackEntry entry = mAnimationState.SetAnimation(1, walkName, false);
        }



        //  print("entry is "+entry);
        //}


        // entry.

        state = walkName;
    }
Exemplo n.º 5
0
                private void PlayAnimation(Spine3DAnimationSet animationSet, AnimationState animationState, TrackEntry[] trackEntries, int trackIndex, ChannelAnimationData animation)
                {
                    //Proxy Animation
                    if (animation._proxyAnimation != null)
                    {
                        //Valid for this animation set (matches orientations)
                        if ((animationSet._orientation & animation._proxyAnimationOrientations) != 0)
                        {
                            TrackEntry trackEntry = trackEntries[trackIndex];

                            if (trackEntry == null || trackEntry.Animation != animation._proxyAnimation)
                            {
                                animationState.ClearTrack(trackIndex);
                                trackEntry = animationState.SetAnimation(trackIndex, animation._proxyAnimation, true);
                            }

                            if (trackEntry != null)
                            {
                                trackEntry.TrackTime = animation._animationTime * animation._animationSpeed;
                                trackEntry.Alpha     = animation._animationWeight;
                                trackEntry.TimeScale = animation._animationSpeed;
                            }
                        }
                        else
                        {
                            animationState.ClearTrack(trackIndex);
                        }
                    }
                    //Normal animation
                    else if (!string.IsNullOrEmpty(animation._animationId))
                    {
                        string     animationId = _trackBinding.GetAnimNameForAnimationSet(animationSet, animation._animationId);
                        TrackEntry trackEntry  = trackEntries[trackIndex];

                        if (trackEntry == null || trackEntry.Animation == null || trackEntry.Animation.Name != animationId)
                        {
                            animationState.ClearTrack(trackIndex);

                            Animation anim = animationState.Data.SkeletonData.FindAnimation(animationId);
                            if (anim != null)
                            {
                                trackEntry = animationState.SetAnimation(trackIndex, anim, true);
                            }
                        }

                        if (trackEntry != null)
                        {
                            trackEntry.TrackTime = animation._animationTime * animation._animationSpeed;
                            trackEntry.Alpha     = animation._animationWeight;
                            trackEntry.TimeScale = animation._animationSpeed;
                        }
                    }
                    //Nothing playing
                    else
                    {
                        animationState.ClearTrack(trackIndex);
                    }
                }
Exemplo n.º 6
0
 IEnumerator DoWalk()
 {
     //if (gameObject.tag == "Player")
     //{
     //    spineAnimationState.SetAnimation(0, "walk", true);
     //    yield return new WaitForSeconds(1.5f);
     //}
     spineAnimationState.SetAnimation(0, "walk", true);
     yield return(new WaitForSeconds(1.5f));
 }
Exemplo n.º 7
0
    public virtual void AnimationComplete(TrackEntry trackEntry)
    {
        string curAni        = trackEntry.ToString();
        string animationName = "idle";

        if (curAni != animationName)
        {
            spineAnimationState.SetAnimation(0, animationName, true);
        }
    }
Exemplo n.º 8
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = true;

            // String name = "spineboy";
            String name = "goblins-ffd";

            Atlas        atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json  = new SkeletonJson(atlas);

            if (name == "spineboy")
            {
                json.Scale = 0.6f;
            }
            skeleton = new Skeleton(json.ReadSkeletonData(assetsFolder + name + ".json"));
            if (name == "goblins-ffd")
            {
                skeleton.SetSkin("goblin");
            }

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            if (name == "spineboy")
            {
                stateData.SetMix("run", "jump", 0.2f);
                stateData.SetMix("jump", "run", 0.4f);

                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "test", false);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "run", true, 0);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X = 400;
            skeleton.Y = 590;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Exemplo n.º 9
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = true;

            String name = "spineboy";             // "goblins";

            Atlas        atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json  = new SkeletonJson(atlas);

            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins")
            {
                skeleton.SetSkin("goblingirl");
            }
            skeleton.SetSlotsToSetupPose();             // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            if (name == "spineboy")
            {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);

            if (true)
            {
                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "drawOrder", true);
            }
            else
            {
                state.SetAnimation(0, "walk", false);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "walk", true, 0);
            }

            skeleton.X = 320;
            skeleton.Y = 440;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Exemplo n.º 10
0
 public virtual bool SetTransition(Animator animator, TrackEntry current, float timeScale, int layerIndex)
 {
     foreach (var t in fromTransitions)
     {
         if (t.from.Animation == current.Animation)
         {
             var transitionEntry = state.SetAnimation(layerIndex, t.transition.Animation, false);
             transitionEntry.TimeScale = timeScale;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 11
0
    public void SetAnim(CharacterAnimationStateType anim, bool loop, float transition)
    {
        if (anim == CharacterAnimationStateType.Atk1_IdleToAtk)
        {
            //Debug.Log("Arriving start");
        }
        Loop = loop;
        //Debug.Log(anim.ToString());

        SpineAnimationState.SetAnimation(0, anim.ToString(), loop).MixDuration = transition;
        //StartCoroutine(ClearAnim(transition));
        CurrentAnim = anim.ToString();
    }
Exemplo n.º 12
0
    IEnumerator DoDemoRoutine()
    {
        while (true)
        {
            spineAnimationState.SetAnimation(0, aniName1, true);
            yield return(new WaitForSeconds(3.5f));

            //spineAnimationState.SetAnimation(0, aniName1, false);
            spineAnimationState.SetAnimation(0, aniName2, true);
            yield return(new WaitForSeconds(3));

            //spineAnimationState.SetEmptyAnimation(0, 4);
            //yield return new WaitForSeconds(4);
        }
    }
Exemplo n.º 13
0
    override public void UpdateSkeleton()
    {
        if (useAnimationName)
        {
            // Keep AnimationState in sync with animationName and loop fields.
            if (animationName == null || animationName.Length == 0)
            {
                if (state.Animation != null)
                {
                    state.ClearAnimation();
                }
            }
            else if (state.Animation == null || animationName != state.Animation.Name)
            {
                Spine.Animation animation = skeleton.Data.FindAnimation(animationName);
                if (animation != null)
                {
                    state.SetAnimation(animation, loop);
                }
            }
            state.Loop = loop;
        }

        // Apply the animation.
        state.Update(Time.deltaTime * timeScale);
        state.Apply(skeleton);

        // Call overridden method to call skeleton Update and UpdateWorldTransform.
        base.UpdateSkeleton();
    }
Exemplo n.º 14
0
 // play the animation name, and if it should loop or not
 public void Play(string name, bool loop = true)
 {
     if (DoesContainAnimation(name))
     {
         animation.SetAnimation(name, loop);
     }
 }
Exemplo n.º 15
0
    private void UpdateAnimation()
    {
        // Check if we need to stop current animation
        if (state.Animation != null && animationName == null)
        {
            state.ClearAnimation();
        }

        // Check for different animation name or animation end
        else if (state.Animation == null || animationName != state.Animation.Name)
        {
            Spine.Animation animation = cachedSpineSkeleton.skeleton.Data.FindAnimation(animationName);
            if (animation != null)
            {
                state.SetAnimation(animation, loop);
            }
        }

        state.Loop = loop;

        // Update animation
        cachedSpineSkeleton.skeleton.Update(Time.deltaTime * animationSpeed);
        state.Update(Time.deltaTime * animationSpeed);
        state.Apply(cachedSpineSkeleton.skeleton);
    }
Exemplo n.º 16
0
    IEnumerator CorDamage()
    {
        yield return(new WaitForSeconds(0.5f));

        missileLauncher.LaunchAll();
        yield return(new WaitForSeconds(1.2f));

        spine_Boss.gameObject.SetActive(false);
        spine_BossAttack.gameObject.SetActive(false);
        spine_BossDamage.gameObject.SetActive(true);
        spine_BossDie.gameObject.SetActive(false);

        var track = state_BossDamage.SetAnimation(0, damage, false);

        spine_BossDamage.skeleton.FlipX = Random.value > .5f;
        //var track = state_BossDamage.AddAnimation(0, idle, true, 0.5f * duration);
        //track.MixDuration = 0.5f * duration;
        //LogManager.Log("track.TrackTime = " , track.AnimationEnd);

        yield return(new WaitForSeconds(track.AnimationEnd));

        spine_BossDamage.skeleton.FlipX = false;


        spine_Boss.gameObject.SetActive(true);
        spine_BossAttack.gameObject.SetActive(false);
        spine_BossDamage.gameObject.SetActive(false);
        spine_BossDie.gameObject.SetActive(false);

        CorePlayBossWar.BossAttackFinishEvent.Invoke();
        missileLauncher.Reset();
    }
Exemplo n.º 17
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            String name = "spineboy";             // "goblins";

            Atlas        atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json  = new SkeletonJson(atlas);

            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins")
            {
                skeleton.SetSkin("goblingirl");
            }
            skeleton.SetSlotsToBindPose();             // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            if (name == "spineboy")
            {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);
            state.SetAnimation("walk", false);
            state.AddAnimation("jump", false);
            state.AddAnimation("walk", true);

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
    //  Spine.TrackEntry

    void Start()
    {
        //mSkeletonAnimation = gameObject.GetComponent<SkeletonAnimation> ();
        //mSkeletonAnimation.AnimationName = walkName;
        mAnimationState = mSkeletonAnimation.state;
        mAnimationState.SetAnimation(0, blinkName, true);
    }
Exemplo n.º 19
0
        public SpineboyScreen(Example game) : base(game)
        {
            atlas = new Atlas("data/spineboy.atlas", new XnaTextureLoader(game.GraphicsDevice));

            SkeletonBinary binary = new SkeletonBinary(atlas);

            binary.Scale = 0.5f;
            SkeletonData skeletonData = binary.ReadSkeletonData("data/spineboy-pro.skel");

            skeleton = new Skeleton(skeletonData);
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            skeleton.X = game.GraphicsDevice.Viewport.Width / 2;
            skeleton.Y = game.GraphicsDevice.Viewport.Height;

            // We want 0.2 seconds of mixing time when transitioning from
            // any animation to any other animation.
            stateData.DefaultMix = 0.2f;

            // Set the "walk" animation on track one and let it loop forever
            state.SetAnimation(0, "walk", true);

            // Queue another animation after 2 seconds to let Spineboy jump
            state.AddAnimation(0, "jump", false, 2);

            // After the jump is complete, let Spineboy walk
            state.AddAnimation(0, "run", true, 0);
        }
Exemplo n.º 20
0
    private void onFsmStateChange(object ss)
    {
        state = (int)ss;


//		/Debug.Log("onFsmMove value is " + arg0);
        //if(state
        if (state == STATE_MOVE)
        {
            //isMove = true;
            //mAnimationState.TimeScale = 2f;


            //if (state != walkName)
            //{
//			Spine.TrackEntry now = mAnimationState.GetCurrent(1);
//			if (now != null &&now.animation != null && now.animation.name == moveName && !now.IsComplete)
//			{
//				//此时请动画正在执行。
//
//			}
//			else
//			{
            Spine.TrackEntry entry = mAnimationState.SetAnimation(1, moveName, true);
//			}
        }
        else if (state == STATE_NAP)
        {
            //isNap = true;
        }

        // cb.stateMachine.SetVariable("move", false);
    }
Exemplo n.º 21
0
    public override void Initialize()
    {
        base.Initialize(); // Call overridden method to initialize the skeleton.

        state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
        if (_animationName != null && _animationName.Length > 0) state.SetAnimation(0, _animationName, loop);
    }
Exemplo n.º 22
0
        public TankScreen(Example game) : base(game)
        {
            // Instantiate and configure the two color tinting effect and
            // assign it to the skeleton renderer
            var twoColorTintEffect = game.Content.Load <Effect>("Content\\SpineEffect");

            twoColorTintEffect.Parameters["World"].SetValue(Matrix.Identity);
            twoColorTintEffect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up));
            skeletonRenderer.Effect = twoColorTintEffect;

            // The remaining code loads the atlas and skeleton data as in the raptor screen
            atlas = new Atlas("data/tank.atlas", new XnaTextureLoader(game.GraphicsDevice));
            SkeletonJson json = new SkeletonJson(atlas);

            json.Scale = 0.25f;
            SkeletonData skeletonData = json.ReadSkeletonData("data/tank-pro.json");

            skeleton = new Skeleton(skeletonData);
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            skeleton.X = game.GraphicsDevice.Viewport.Width / 2 + 200;
            skeleton.Y = game.GraphicsDevice.Viewport.Height;

            state.SetAnimation(0, "shoot", true);
        }
Exemplo n.º 23
0
		public void Initialize (bool overwrite) {
			if (this.IsValid && !overwrite) return;

			// Make sure none of the stuff is null
			if (this.skeletonDataAsset == null) return;
			var skeletonData = this.skeletonDataAsset.GetSkeletonData(false);
			if (skeletonData == null) return;

			if (skeletonDataAsset.atlasAssets.Length <= 0 || skeletonDataAsset.atlasAssets[0].materials.Length <= 0) return;

			this.state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
			if (state == null) {
				Clear();
				return;
			}

			this.skeleton = new Skeleton(skeletonData) {
				flipX = this.initialFlipX,
				flipY = this.initialFlipY
			};

			meshBuffers = new DoubleBuffered<MeshRendererBuffers.SmartMesh>();
			canvasRenderer.SetTexture(this.mainTexture); // Needed for overwriting initializations.

			// Set the initial Skin and Animation
			if (!string.IsNullOrEmpty(initialSkinName))
				skeleton.SetSkin(initialSkinName);

			#if UNITY_EDITOR
			if (!string.IsNullOrEmpty(startingAnimation)) {
				if (Application.isPlaying) {
					state.SetAnimation(0, startingAnimation, startingLoop);
				} else {
					// Assume SkeletonAnimation is valid for skeletonData and skeleton. Checked above.
					var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(startingAnimation);
					if (animationObject != null)
						animationObject.PoseSkeleton(skeleton, 0);
				}
				Update(0);
			}
			#else
			if (!string.IsNullOrEmpty(startingAnimation)) {
				state.SetAnimation(0, startingAnimation, startingLoop);
				Update(0);
			}
			#endif
		}
Exemplo n.º 24
0
	override public void Initialize () {
		if (Initialized) return;

		base.Initialize();
		
		state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
		if (_animationName != null && _animationName.Length > 0) state.SetAnimation(0, _animationName, loop);
	}
Exemplo n.º 25
0
 public void PlayAnimation(string name, bool isLoop)
 {
     if (!string.IsNullOrEmpty(name))
     {
         state.SetAnimation(0, name, isLoop);
         Update(0);
     }
 }
Exemplo n.º 26
0
 public void SetState(string state)
 {
     if (currentState != state)
     {
         spineAnimationState.SetAnimation(0, state, state == run);
         currentState = state;
     }
 }
Exemplo n.º 27
0
 public void SetAnimation(string animationName, bool loop)
 {
     if (!AnimationExists(animationName))
     {
         return;
     }
     Spine.TrackEntry animationEntry = _animState.SetAnimation(0, animationName, loop);
 }
Exemplo n.º 28
0
    public IEnumerator Idle(float duration)
    {
        yield return(new WaitForSeconds(duration));

        spineAnimationState = skeletonAnimation.AnimationState;
        spineAnimationState.SetAnimation(0, "idle", false);
        yield break;
    }
                public void Play(int channel, string animName, WrapMode wrapMode = WrapMode.Default, float blendTime = 0, InterpolationType easeType = InterpolationType.InOutSine, float weight = 1, bool queued = false)
                {
                    ChannelGroup channelGroup = GetChannelGroup(channel);

                    //If queued then store the animation queued after, wait for it to be -blend time from end then play non queued with blend time.
                    if (queued)
                    {
                        if (channelGroup != null && IsTrackPlaying(channelGroup._primaryTrack))
                        {
                            channelGroup._queuedAnimation          = animName;
                            channelGroup._queuedAnimationWeight    = weight;
                            channelGroup._queuedAnimationBlendTime = blendTime;
                            channelGroup._queuedAnimationEase      = easeType;
                            channelGroup._queuedAnimationWrapMode  = wrapMode;
                            return;
                        }
                    }

                    //If not blending stop relevant animations
                    if (blendTime <= 0.0f)
                    {
                        //Stop all others from channel group if ePlayMode.Additive, stop all others if Singular
                        StopChannel(channelGroup);
                    }

                    //If no group exists, add new one and return first track index
                    if (channelGroup == null)
                    {
                        channelGroup = AddNewChannelGroup(channel);
                    }
                    //Otherwise check an animation is currently playing on this group
                    else if (channelGroup._state != ChannelGroup.eState.Stopped)
                    {
                        MovePrimaryAnimationToBackgroundTrack(channelGroup);
                    }

                    //Start animation on primary track
                    int trackIndex = channelGroup._primaryTrack._trackIndex;

                    _animationState.ClearTrack(trackIndex);
                    TrackEntry trackEntry = _animationState.SetAnimation(trackIndex, animName, wrapMode == WrapMode.Loop);

                    //if blending start with weight of zero
                    if (blendTime > 0.0f)
                    {
                        channelGroup._state        = ChannelGroup.eState.BlendingIn;
                        trackEntry.Alpha           = 0.0f;
                        channelGroup._lerpT        = 0.0f;
                        channelGroup._targetWeight = weight;
                        channelGroup._lerpSpeed    = 1.0f / blendTime;
                        channelGroup._lerpEase     = easeType;
                    }
                    else
                    {
                        channelGroup._state = ChannelGroup.eState.Playing;
                        trackEntry.Alpha    = weight;
                    }
                }
Exemplo n.º 30
0
 //播放动画
 void playAnimation(string animation)
 {
     if (curAnimationName != animation)
     {
         Debug.Log("player animation" + animation);
         spineAnimationState.SetAnimation(0, animation, true);
         curAnimationName = animation;
     }
 }
    void doAttack()
    {
        attackEndTime = Time.time + attackDuration;
        doingAttack   = true;
        spineAnimationState.SetAnimation(0, attackName, false);
        spineAnimationState.AddAnimation(0, idleName, true, 0);

        //skeletonAnimation
    }
Exemplo n.º 32
0
    public override void OnBossEnter()
    {
        if (gameEnd == true)
        {
            return;
        }

        //LogManager.Log("Go = OnBossEnter");

        audio_Source.Play();
        float enterTalkDuration = audio_Source.clip.length;

        state_Boss.SetAnimation(0, enterTalk, true);
        var track = state_Boss.AddAnimation(0, enter, false, enterTalkDuration);

        track.AnimationStart = 2f;
        //spine_Boss.transform.DOMoveY(-5f, 1.3f);
    }
	public override void Reset () {
		base.Reset();
		if (!valid) return;

		state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
		if (_animationName != null && _animationName.Length > 0) {
			state.SetAnimation(0, _animationName, loop);
			Update(0);
		}
	}
Exemplo n.º 34
0
 void Start()
 {
     clock = GetComponent<SkeletonAnimation>();
     clockState = clock.state;
     clockState.TimeScale = 1.0f;
     clockState.SetAnimation(0, "loop", true);
     armLong = clock.skeleton.FindBone ("arm-long");
     armShort = clock.skeleton.FindBone ("arm-short");
     needle = clock.skeleton.FindBone ("needle");
     Debug.Log (armLong);
     Debug.Log (armShort);
     Debug.Log (needle);
 }
Exemplo n.º 35
0
        protected override void LoadContent()
        {
            Effect spriteBatchEffect = Content.Load<Effect>("SpriteBatchEffect");
            spriteBatch = new SpriteBatchEx(GraphicsDevice, spriteBatchEffect);

            Bone.yDown = true;
            skeletonData = Content.Load<SkeletonData>("spineboy/spineboy");
            skeleton = new Skeleton(skeletonData);
            skeleton.SetSlotsToSetupPose();

            AnimationStateData stateData = new AnimationStateData(skeleton.Data);
            animationState = new AnimationState(stateData);
            animationState.SetAnimation(0, "walk", true);

            skeleton.UpdateWorldTransform();
        }
Exemplo n.º 36
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            String name = "spineboy"; // "goblins";

            Atlas atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins") skeleton.SetSkin("goblingirl");
            skeleton.SetSlotsToSetupPose(); // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);
            if (name == "spineboy") {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);

            if (true) {
                // Event handling for all animations.
                state.Start += new EventHandler(Start);
                state.End += new EventHandler(End);
                state.Complete += new EventHandler<CompleteArgs>(Complete);
                state.Event += new EventHandler<EventTriggeredArgs>(Event);

                state.SetAnimation("drawOrder", true);
            } else {
                state.SetAnimation("walk", false);
                QueueEntry entry = state.AddAnimation("jump", false);
                entry.End += new EventHandler(End); // Event handling for queued animations.
                state.AddAnimation("walk", true);
            }

            skeleton.X = 320;
            skeleton.Y = 440;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Exemplo n.º 37
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            String name = "spineboy"; // "goblins";

            Atlas atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins") skeleton.SetSkin("goblingirl");
            skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);
            if (name == "spineboy") {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);
            state.SetAnimation("walk", false);
            state.AddAnimation("jump", false);
            state.AddAnimation("walk", true);

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
Exemplo n.º 38
0
		protected override void LoadContent () {
			skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
			skeletonRenderer.PremultipliedAlpha = true;

			// String name = "spineboy";
			// String name = "goblins-mesh";
			String name = "raptor";
			bool binaryData = true;

			Atlas atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));

			float scale = 1;
			if (name == "spineboy") scale = 0.6f;
			if (name == "raptor") scale = 0.5f;

			SkeletonData skeletonData;
			if (binaryData) {
				SkeletonBinary binary = new SkeletonBinary(atlas);
				binary.Scale = scale;
				skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
			} else {
				SkeletonJson json = new SkeletonJson(atlas);
				json.Scale = scale;
				skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
			}
			skeleton = new Skeleton(skeletonData);
			if (name == "goblins-mesh") skeleton.SetSkin("goblin");

			// Define mixing between animations.
			AnimationStateData stateData = new AnimationStateData(skeleton.Data);
			state = new AnimationState(stateData);

			if (name == "spineboy") {
				stateData.SetMix("run", "jump", 0.2f);
				stateData.SetMix("jump", "run", 0.4f);

				// Event handling for all animations.
				state.Start += Start;
				state.End += End;
				state.Complete += Complete;
				state.Event += Event;

				state.SetAnimation(0, "test", false);
				TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
				entry.End += End; // Event handling for queued animations.
				state.AddAnimation(0, "run", true, 0);
			} else if (name == "raptor") {
				state.SetAnimation(0, "walk", true);
				state.SetAnimation(1, "empty", false);
				state.AddAnimation(1, "gungrab", false, 2);
			} else {
				state.SetAnimation(0, "walk", true);
			}

			skeleton.X = 400;
			skeleton.Y = 590;
			skeleton.UpdateWorldTransform();

			headSlot = skeleton.FindSlot("head");
		}
Exemplo n.º 39
0
	public override void Reset () {
		base.Reset();
		if (!valid)
			return;

		state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());

		#if UNITY_EDITOR
		if (!string.IsNullOrEmpty(_animationName)) {
			if (Application.isPlaying) {
				state.SetAnimation(0, _animationName, loop);
			} else {
				// Assume SkeletonAnimation is valid for skeletonData and skeleton. Checked above.
				var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(_animationName);
				if (animationObject != null)
					animationObject.Apply(skeleton, 0f, 0f, false, null);
			}
			Update(0);
		}
		#else
		if (!string.IsNullOrEmpty(_animationName)) {
			state.SetAnimation(0, _animationName, loop);
			Update(0);
		}
		#endif
	}
		public void Initialize (bool overwrite) {
			if (this.IsValid && !overwrite) return;

			// Make sure none of the stuff is null
			if (this.skeletonDataAsset == null) return;
			var skeletonData = this.skeletonDataAsset.GetSkeletonData(false);
			if (skeletonData == null) return;

			if (skeletonDataAsset.atlasAssets.Length <= 0 || skeletonDataAsset.atlasAssets[0].materials.Length <= 0) return;

			this.state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
			if (state == null) {
				Clear();
				return;
			}

			this.skeleton = new Skeleton(skeletonData);
			this.spineMeshGenerator = new Spine.Unity.MeshGeneration.ArraysSimpleMeshGenerator(); // You can switch this out with any other implementer of Spine.Unity.MeshGeneration.ISimpleMeshGenerator
			this.spineMeshGenerator.PremultiplyVertexColors = true;

			// Set the initial Skin and Animation
			if (!string.IsNullOrEmpty(initialSkinName))
				skeleton.SetSkin(initialSkinName);

			if (!string.IsNullOrEmpty(startingAnimation))
				state.SetAnimation(0, startingAnimation, startingLoop);
		}