Пример #1
0
        public Animation(string AnimationFile)
        {
            skeletonRenderer = new SkeletonRenderer();

            String name = AnimationFile;

            Atlas atlas = new Atlas("Data/" + name + ".atlas", new GLImpTextureLoader());
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.ReadSkeletonData("Data/" + name + ".json"));
            skeleton.SetSlotsToSetupPose();

            // Define mixing between animations.
            stateData = new AnimationStateData(skeleton.Data);
            state = new AnimationState(stateData);
            //state.SetAnimation("idle", true);

            skeleton.X = 0;
            skeleton.Y = 0.1f;
            skeleton.UpdateWorldTransform();

            drawtime = new Stopwatch();
            drawtime.Start();

            Program.MiddleDrawQueue += Draw;
        }
        public override void draw(Spine.SkeletonRenderer sb)
        {
            //sb.DrawSpriteToSpineVertexArray(Game1.whitePixel, new Rectangle(0, 0, 1, 1), position, Color.Black, 0.0f, new Vector2(48));
            //sb.Draw(Game1.whitePixel, position, null, Color.Black, 0.0f, Vector2.Zero, new Vector2(48, 48), SpriteEffects.None, 0.5f);
            //sb.Draw(Game1.whitePixel, CenterPoint, null, Color.White, angle, Vector2.Zero, new Vector2(radius, 10.0f), SpriteEffects.None, 0.5f);

            if (state == mutantBallState.Agressive)
            {
                float interpolate = Vector2.Distance(ball_coordinate, CenterPoint);

                for (int i = 0; i <= (int)(interpolate); i += 3)
                {
                    chain_ball.drawAnimationFrame(0.0f, sb, new Vector2(current_skeleton.Skeleton.FindBone("head").WorldX, current_skeleton.Skeleton.FindBone("head").WorldY) + new Vector2(i * (float)(Math.Cos(angle)), i * (float)(Math.Sin(angle))), new Vector2(1.0f), 0.5f, angle, CenterPoint, Color.White);
                }
            }
            if (state == mutantBallState.Agressive)
            {
                if (radius < radius_max)
                {
                    radius += 2.0f;
                }
            }
            else
            {
                if (radius > 0)
                {
                    radius -= 2.0f;
                    angle  += 0.1f;
                }
            }
        }
Пример #3
0
 public RawSpineData(string pSkeletonDataPath, string pSkeletonName)
 {
     skeletonRenderer = new SkeletonRenderer(EngineSettings.Graphics.GraphicsDevice);
       skeletonRenderer.PremultipliedAlpha = SpineSettings.PremultipliedAlphaRendering;
       atlas = new Atlas(pSkeletonDataPath + pSkeletonName + ".atlas", new XnaTextureLoader(EngineSettings.Graphics.GraphicsDevice));
       json = new SkeletonJson(atlas);
 }
Пример #4
0
 public override void draw(Spine.SkeletonRenderer sb)
 {
     /*
      * sb.Draw(Game1.whitePixel, CenterPoint, null, Color.White, angle1, Vector2.Zero, new Vector2(600.0f, 10.0f),SpriteEffects.None, 0.5f);
      * sb.Draw(Game1.whitePixel, CenterPoint, null, Color.White, angle, Vector2.Zero, new Vector2(600.0f, 10.0f), SpriteEffects.None, 0.5f);
      * sb.Draw(Game1.whitePixel, CenterPoint, null, Color.White, angle2, Vector2.Zero, new Vector2(600.0f, 10.0f), SpriteEffects.None, 0.5f);
      */
 }
Пример #5
0
        public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice)
        {
            itemTex = content.Load<Texture2D>("robo/robo");

            skeletonRenderer = new SkeletonRenderer(graphicsDevice);

            sourceDict.Add("crowbar", new Rectangle(2, 151, 50, 19));
            sourceDict.Add("laserpistol", new Rectangle(54, 206, 46, 28));
            sourceDict.Add("axe", new Rectangle(2, 2, 77, 77));
        }
Пример #6
0
        public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice)
        {
            //blankTex = content.Load<Texture2D>("blank");
            //hudTex = content.Load<Texture2D>("particles");

            skeletonRenderer = new SkeletonRenderer(graphicsDevice);

            AtlasDict.Add("dude", new Atlas(graphicsDevice, "dude/dude.atlas", content));
            JsonDict.Add("dude", File.ReadAllText(Path.Combine(content.RootDirectory, "dude/dude.json")));
        }
Пример #7
0
 public override void draw(Spine.SkeletonRenderer sb)
 {
     if (Player_Right_Item != null)
     {
         Player_Right_Item.draw(sb);
     }
     if (Player_Left_Item != null)
     {
         Player_Left_Item.draw(sb);
     }
 }
Пример #8
0
 public override void draw(Spine.SkeletonRenderer sb)
 {
     for (int i = 0; i < max_bullet_count; i++)
     {
         if (bullets[i].active)
         {
             //sb.DrawSpriteToSpineVertexArray(Game1.whitePixel, new Rectangle(0, 0, 1, 1), bullets[i].position, Color.White, 0.0f, new Vector2(10.0f, 10.0f));
             bulletPic.drawAnimationFrame(0.0f, sb, bullets[i].position - (bulletPic.FrameDimensions / 2), new Vector2(1f), 0.5f, bullets[i].Bullet_Angle, bullets[i].CenterPoint, Color.White);
         }
     }
 }
 public Renderer(GraphicsDevice graphicsDevice, Effect defaultShader)
 {
     this.defaultShader = defaultShader;
     Font = null;
     Camera = null;
     ResetTint();
     spriteBatch = new SpriteBatch(graphicsDevice);
     skeletonRenderer = new SkeletonRenderer(graphicsDevice);
     skeletonRenderer.BlendState = BlendState.NonPremultiplied;
     state = RendererState.NoneBegan;
     CurrentShader = null;
 }
Пример #10
0
 public void drawAcidSplotches(Spine.SkeletonRenderer sb)
 {
     for (int i = 0; i < size_of_spit_array; i++)
     {
         if (projectile[i].active)
         {
             if (projectile[i].Projectile_State != SpitProjectile.ProjectileState.Travel)
             {
                 acid_pool.drawAnimationFrame(projectile[i].alive_timer, sb, projectile[i].CenterPoint - acid_pool.FrameDimensions / 2, new Vector2(projectile[i].scale), 0.5f, 0.0f, projectile[i].CenterPoint, Color.White);
             }
         }
     }
 }
		void Apply (SkeletonRenderer skeletonRenderer) {
			atlas = atlasAsset.GetAtlas();
			float scale = skeletonRenderer.skeletonDataAsset.scale;

			var enumerator = attachments.GetEnumerator();
			while (enumerator.MoveNext()) {
				var entry = (SlotRegionPair)enumerator.Current;

				var slot = skeletonRenderer.skeleton.FindSlot(entry.slot);
				var region = atlas.FindRegion(entry.region);
				slot.Attachment = region.ToRegionAttachment(entry.region, scale);
			}
		}
        public override void draw(Spine.SkeletonRenderer sb)
        {
            //sb.DrawSpriteToSpineVertexArray(Game1.whitePixel, new Rectangle(0, 0, 1, 1), position, Color.Green, 0.0f, new Vector2(48));

            if (state == ChainState.Throw || state == ChainState.Pull)
            {
                float interpolate = Vector2.Distance(chain_position, new Vector2(directionAnims[(int)direction_facing].Skeleton.FindBone("rHand").WorldX, directionAnims[(int)direction_facing].Skeleton.FindBone("rHand").WorldY));

                for (int i = 0; i <= (int)(interpolate); i += 16)
                {
                    hook.drawAnimationFrame(0.0f, sb, new Vector2(directionAnims[(int)direction_facing].Skeleton.FindBone("rHand").WorldX, directionAnims[(int)direction_facing].Skeleton.FindBone("rHand").WorldY) + new Vector2(i * (float)(Math.Cos(angle)), i * (float)(Math.Sin(angle))), new Vector2(1.0f), 0.5f, angle, Vector2.Zero, Color.White);
                }
            }
        }
Пример #13
0
		/// <summary>
		/// Drawed den Package-Inhalt
		/// </summary>
		/// <param name="pSpriteBatch">SpriteBatch zum drawen von Texturen</param>
		/// <param name="pSkeletonRenderer">SkeletonRenderer zum drawen von Texturen</param>
		public void Draw(SpriteBatch pSpriteBatch, SkeletonRenderer pSkeletonRenderer)
		{
			if (!Spine)
			{
				pSpriteBatch.Draw(mTexture, mPosition, new Color(mAlpha, mAlpha, mAlpha, mAlpha));
			}
			else
			{
				pSkeletonRenderer.Begin();
				pSkeletonRenderer.Draw(mSkeleton);
				pSkeletonRenderer.End();
			}
			if (EngineSettings.IsDebug)
				pSpriteBatch.Draw(TextureManager.Instance.GetElementByString("pixel"), mCollisionBox, mDebugColor);
		}
Пример #14
0
            public void drawAnimationFrame(float time, Spine.SkeletonRenderer sb, Vector2 position, Vector2 scale, float depth, float rotation, Vector2 centerPoint, Color color)
            {
                int frame = (int)(time / frameDuration);

                if (loop)
                {
                    frame = frame % frameCount;
                }
                else if (frame >= frameCount)
                {
                    frame = frameCount - 1;
                }

                sb.DrawSpriteToSpineVertexArray(sheet, new Rectangle(x + (frame * frameWidth), y, frameWidth, frameHeight), position + new Vector2((int)offsetX, (int)offsetY), color, rotation, scale);
            }
Пример #15
0
		void Start () {
			skeletonRenderer = GetComponent<SkeletonRenderer>();
			Skeleton skeleton = skeletonRenderer.skeleton;

			customSkin = new Skin("CustomSkin");

			foreach (var pair in skinItems) {
				var attachment = SpineAttachment.GetAttachment(pair.sourceAttachmentPath, skinSource);
				customSkin.AddAttachment(skeleton.FindSlotIndex(pair.targetSlot), pair.targetAttachment, attachment);
			}

			// The custom skin does not need to be added to the skeleton data for it to work.
			// But it's useful for your script to keep a reference to it.
			skeleton.SetSkin(customSkin);
		}
Пример #16
0
        public SpinePlayer(string atlasPath, string jsonPath)
        {
            Name = jsonPath;

            _skeletonRenderer = new SkeletonRenderer(Render.Device);

            var atlas = new Atlas(atlasPath, new XnaTextureLoader(Render.Device));
            var json = new SkeletonJson(atlas);

            Skeleton = new Skeleton(json.ReadSkeletonData(jsonPath));
            Skeleton.SetSlotsToSetupPose(); // Without this the skin attachments won't be attached. See SetSkin.

            var stateData = new AnimationStateData(Skeleton.Data);
            State = new AnimationState(stateData);
            IsVisible = true;
        }
		void OnEnable () {
			skeletonUtility = (SkeletonUtility)target;
			skeletonRenderer = skeletonUtility.GetComponent<SkeletonRenderer>();
			skeleton = skeletonRenderer.skeleton;
			transform = skeletonRenderer.transform;

			if (skeleton == null) {
				skeletonRenderer.Initialize(false);
				skeletonRenderer.LateUpdate();

				skeleton = skeletonRenderer.skeleton;
			}

			UpdateAttachments();
			isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab;
		}
Пример #18
0
        public override void draw(Spine.SkeletonRenderer sb)
        {
            //sb.DrawSpriteToSpineVertexArray(Game1.whitePixel, new Rectangle(0, 0, 1, 1), position, Color.White, 0.0f, dimensions);

            for (int i = 0; i < size_of_spit_array; i++)
            {
                if (projectile[i].active)
                {
                    if (projectile[i].Projectile_State == SpitProjectile.ProjectileState.Travel)
                    {
                        //sb.DrawSpriteToSpineVertexArray(Game1.whitePixel, new Rectangle(0, 0, 1, 1), projectile[i].position, Color.Pink, 0.0f, projectile[i].dimensions);
                        acid_pool.drawAnimationFrame(0.0f, sb, projectile[i].position - new Vector2(64), new Vector2(0.23f), 0.5f, projectile[i].alive_timer, Vector2.Zero, Color.White);
                    }
                }
            }

            //drawAcidSplotches(sb);
        }
Пример #19
0
        public Avatar(string AnimationFile)
        {
            SkeletonRenderer = new SkeletonRenderer(Vector3.UnitY, Vector3.UnitZ);

            String name = AnimationFile;

            Atlas atlas = new Atlas(name + ".atlas", new OpenTKTextureLoader());
            SkeletonJson json = new SkeletonJson(atlas);
            Skeleton = new Skeleton(json.ReadSkeletonData(name + ".json"));
            Skeleton.SetSlotsToSetupPose();

            // Define mixing between animations.
            StateData = new AnimationStateData(Skeleton.Data);
            State = new AnimationState(StateData);

            Skeleton.X = 0;
            Skeleton.Y = 0;
            Skeleton.UpdateWorldTransform();
        }
        public override void spinerender(Spine.SkeletonRenderer renderer)
        {
            if (direction_facing == GlobalGameConstants.Direction.Right || direction_facing == GlobalGameConstants.Direction.Up || direction_facing == GlobalGameConstants.Direction.Down)
            {
                current_skeleton.Skeleton.FlipX = false;
            }
            if (direction_facing == GlobalGameConstants.Direction.Left)
            {
                current_skeleton.Skeleton.FlipX = true;
            }

            current_skeleton.Skeleton.RootBone.X = CenterPoint.X * (current_skeleton.Skeleton.FlipX ? -1 : 1);
            current_skeleton.Skeleton.RootBone.Y = CenterPoint.Y + (dimensions.Y / 2f);

            current_skeleton.Skeleton.RootBone.ScaleX = 1.0f;
            current_skeleton.Skeleton.RootBone.ScaleY = 1.0f;

            current_skeleton.Skeleton.UpdateWorldTransform();
            renderer.Draw(current_skeleton.Skeleton);
        }
Пример #21
0
		void Apply (SkeletonRenderer skeletonRenderer) {
			atlas = atlasAsset.GetAtlas();

			AtlasAttachmentLoader loader = new AtlasAttachmentLoader(atlas);

			float scaleMultiplier = skeletonRenderer.skeletonDataAsset.scale;

			var enumerator = attachments.GetEnumerator();
			while (enumerator.MoveNext()) {
				var entry = (SlotRegionPair)enumerator.Current;
				var regionAttachment = loader.NewRegionAttachment(null, entry.region, entry.region);
				regionAttachment.Width = regionAttachment.RegionOriginalWidth * scaleMultiplier;
				regionAttachment.Height = regionAttachment.RegionOriginalHeight * scaleMultiplier;

				regionAttachment.SetColor(new Color(1, 1, 1, 1));
				regionAttachment.UpdateOffset();

				var slot = skeletonRenderer.skeleton.FindSlot(entry.slot);
				slot.Attachment = regionAttachment;
			}
		}
Пример #22
0
        public override void draw(Spine.SkeletonRenderer sb)
        {
            float bullet_angle = 0.0f;

            if (direction_facing == GlobalGameConstants.Direction.Right || direction_facing == GlobalGameConstants.Direction.Left)
            {
                bullet_angle = 0.0f;
            }
            else
            {
                bullet_angle = (float)(Math.PI / 2);
            }

            for (int i = 0; i < bullet_number; i++)
            {
                if (bullets[i].active)
                {
                    //sb.DrawSpriteToSpineVertexArray(Game1.whitePixel, new Rectangle(0, 0, 1, 1), bullets[i].Position, Color.White, 0.0f, new Vector2(2.0f));

                    bulletPic.drawAnimationFrame(0.0f, sb, bullets[i].Position - (bulletPic.FrameDimensions / 2), new Vector2(1.0f), 0.5f, bullet_angle, bullets[i].CenterPoint, Color.White);
                }
            }
        }
Пример #23
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            Texture2D texture = Util.LoadTexture(GraphicsDevice, "data/goblins.png");
            Atlas atlas = new Atlas("data/goblins.atlas", texture, texture.Width, texture.Height);
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.ReadSkeletonData("data/goblins.json"));
            skeleton.SetSkin("goblingirl");
            skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin.
            animation = skeleton.Data.FindAnimation("walk");

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
Пример #24
0
        public override void Render(SkeletonRenderer skeletonRenderer, EntityWorld world, Entity entity, Renderable position)
        {
            ActivityComponent activityCom = null;
            DirectionComponent directionCom = null;

            foreach (IComponent com in world.EntityManager.GetComponents(entity)) {
                if (com is ActivityComponent)
                    activityCom = com as ActivityComponent;
                else if (com is DirectionComponent)
                    directionCom = com as DirectionComponent;
            }

            if (activityCom != null && activityCom.Activity != _activity) {
                _activity = activityCom.Activity;

                string animationKey = null;
                if (!_record.ActivityMap.TryGetValue(activityCom.Activity, out animationKey))
                    animationKey = _record.DefaultAnimation;

                string animation = "";
                bool flipX = false;
                bool flipY = false;

                if (animationKey != null) {
                    if (directionCom != null && _record.DirectedAnimationMap.ContainsKey(animationKey)) {
                        if (_record.DirectedAnimationMap[animationKey].ContainsKey(directionCom.Direction)) {
                            ISpineDirectionElement element = _record.DirectedAnimationMap[animationKey][directionCom.Direction];
                            animation = element.Animation;
                            flipX = element.FlipX;
                            flipY = element.FlipY;
                        }
                        else if (_record.DefaultAnimationMap.ContainsKey(animationKey))
                            animation = _record.DefaultAnimationMap[animationKey];
                    }
                    else if (_record.DefaultAnimationMap.ContainsKey(animationKey))
                        animation = _record.DefaultAnimationMap[animationKey];
                }

                if (_animation == null || animation != _animation.Name) {
                    _animation = _skeleton.Data.FindAnimation(animation);
                    _time = 0;
                }

                if (_animation == null && _skeleton.Data.Animations.Count > 0) {
                    _animation = _skeleton.Data.Animations[0];
                    _time = 0;
                }

                _skeleton.FlipX = flipX;
                _skeleton.FlipY = flipY;
            }

            if (_animation != null) {
                _time += (float)world.GameTime.ElapsedGameTime.TotalSeconds;
                _animation.Apply(_skeleton, _time, true);
            }

            _skeleton.RootBone.X = (float)position.RenderX;
            _skeleton.RootBone.Y = (float)position.RenderY;
            _skeleton.UpdateWorldTransform();

            skeletonRenderer.Draw(_skeleton);
        }
Пример #25
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            Atlas atlas = new Atlas(GraphicsDevice, "data/spineboy.atlas");
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.readSkeletonData("spineboy", File.ReadAllText("data/spineboy.json")));
            animation = skeleton.Data.FindAnimation("walk");

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
Пример #26
0
 public SpineRenderLayer(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     _manager = new SpineRenderManager(world, skeletonRenderer);
     _options = new SpineRenderManagerOptions();
 }
Пример #27
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            Atlas atlas = new Atlas(GraphicsDevice, "data/goblins.atlas");
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.readSkeletonData("goblins", File.ReadAllText("data/goblins.json")));
            skeleton.SetSkin("goblingirl");
            skeleton.SetSlotsToBindPose();
            animation = skeleton.Data.FindAnimation("walk");

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
Пример #28
0
 public abstract void draw(Spine.SkeletonRenderer sb);
Пример #29
0
		public override void Initialize()
		{
			skeletonRenderer = new SkeletonRenderer(EngineSettings.Graphics.GraphicsDevice);
			skeletonRenderer.PremultipliedAlpha = true;
		}
Пример #30
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();
        }
Пример #31
0
        public override void draw(Spine.SkeletonRenderer sb)
        {
            //sb.Draw(Game1.whitePixel, position, null, Color.White, 0.0f, Vector2.Zero, dimensions, SpriteEffects.None, 0.5f);


            //sb.DrawSpriteToSpineVertexArray(Game1.whitePixel, new Rectangle(0,0,1,1),position, Color.Green, 0.0f, dimensions);

            //tankAnim.drawAnimationFrame(0.0f, sb, CenterPoint, new Vector2(1, 1), 0.5f, tank_hull_angle, new Vector2(48f,69.5f));

            Vector2 offset = new Vector2(19, 0);

            if (mech_state == MechState.Death)
            {
                if (explode_timer > 30)
                {
                    tankDeadAnim.drawAnimationFrame(0.0f, sb, position - offset / 2, new Vector2(1.0f), 0.5f, tank_hull_angle, new Vector2(48f, 69.5f), Color.White);
                    tankTurretDeadAnim.drawAnimationFrame(0.0f, sb, position + new Vector2(50, 50), new Vector2(1.0f), 0.5f, tank_hull_angle, CenterPoint, Color.White);
                }
                else
                {
                    tankAnim.drawAnimationFrame(tank_hull_animation_time, sb, position - offset / 2, new Vector2(1), 0.5f, tank_hull_angle, new Vector2(48f, 69.5f), Color.White);
                }
                plasmaExplode.drawAnimationFrame(explode_timer, sb, position - offset / 2, new Vector2(2.0f), 0.5f, 0.0f, CenterPoint, Color.White);
            }
            else
            {
                switch (direction_facing)
                {
                case GlobalGameConstants.Direction.Right:
                    if ((float)(tank_hull_angle) < (float)((Math.PI / 2) - 0.02f))
                    {
                        tank_hull_angle += tank_hull_turn_magnitude;
                    }
                    else if ((float)(tank_hull_angle) > ((float)((Math.PI / 2) + 0.02f)))
                    {
                        tank_hull_angle -= tank_hull_turn_magnitude;
                    }
                    offset = new Vector2(-19, 0);
                    break;

                case GlobalGameConstants.Direction.Left:
                    if ((float)(tank_hull_angle) < (float)(3 * Math.PI / 2) - 0.02f)
                    {
                        tank_hull_angle += tank_hull_turn_magnitude;
                    }
                    else if ((float)(tank_hull_angle) > ((float)(3 * Math.PI / 2) + 0.02f))
                    {
                        tank_hull_angle -= tank_hull_turn_magnitude;
                    }
                    offset = new Vector2(-19, 0);
                    break;

                case GlobalGameConstants.Direction.Up:
                    if ((float)(tank_hull_angle) < (float)(0.0) - 0.02f)
                    {
                        tank_hull_angle += tank_hull_turn_magnitude;
                    }
                    else if ((float)(tank_hull_angle) > ((float)(0.0) + 0.02))
                    {
                        tank_hull_angle -= tank_hull_turn_magnitude;
                    }
                    offset = new Vector2(0, 19);
                    break;

                default:
                    if ((float)(tank_hull_angle) < (float)(Math.PI) - 0.02)
                    {
                        tank_hull_angle += tank_hull_turn_magnitude;
                    }
                    else if ((float)(tank_hull_angle) > ((float)(Math.PI) + 0.02))
                    {
                        tank_hull_angle -= tank_hull_turn_magnitude;
                    }
                    offset = new Vector2(0, 19);
                    break;
                }

                tankAnim.drawAnimationFrame(tank_hull_animation_time, sb, position - offset / 2, new Vector2(1), 0.5f, tank_hull_angle, new Vector2(48f, 69.5f), Color.White);


                if (grenade.active)
                {
                    if (grenade.State == Grenades.GrenadeState.Travel)
                    {
                        rocketProjectile.drawAnimationFrame(grenade.Active_Timer, sb, grenade.Position, new Vector2(1.0f), 0.5f, rocket_angle, grenade.CenterPoint, Color.White);
                    }
                    else if (grenade.State == Grenades.GrenadeState.Explosion)
                    {
                        plasmaExplode.drawAnimationFrame(grenade.explosion_timer, sb, grenade.Position, new Vector2(2.0f), 0.5f, 0.0f, grenade.CenterPoint, Color.White);
                    }
                    //sb.Draw(Game1.whitePixel, grenade.Position, null, Color.Blue, 0.0f, Vector2.Zero, grenade.Dimensions, SpriteEffects.None, 0.5f);
                }
            }
        }
Пример #32
0
 public Screen(Example game)
 {
     this.game        = game;
     skeletonRenderer = new SkeletonRenderer(game.GraphicsDevice);
     skeletonRenderer.PremultipliedAlpha = false;
 }
Пример #33
0
        protected override void LoadContent()
        {
            // Two color tint effect, comment line 76 to disable
            var spineEffect = Content.Load <Effect>("Content\\SpineEffect");

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

            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = true;
            skeletonRenderer.Effect             = spineEffect;

            // String name = "spineboy";
            // String name = "goblins-mesh";
            // String name = "raptor";
            // String name = "tank";
            // String name = "coin";
            String name       = "TwoColorTest";
            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;
            }
            if (name == "tank")
            {
                scale = 0.3f;
            }
            if (name == "TwoColorTest")
            {
                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.AddAnimation(1, "gungrab", false, 2);
            }
            else if (name == "coin")
            {
                state.SetAnimation(0, "rotate", true);
            }
            else if (name == "tank")
            {
                state.SetAnimation(0, "drive", true);
            }
            else if (name == "TwoColorTest")
            {
                state.SetAnimation(0, "animation", true);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X = 400 + (name == "tank" ? 300: 0);
            skeleton.Y = 580 + (name == "TwoColorTest" ? -300 : 0);
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Пример #34
0
 public override void draw(Spine.SkeletonRenderer sb)
 {
 }
Пример #35
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            Atlas atlas = new Atlas("data/goblins.atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.ReadSkeletonData("data/goblins.json"));
            skeleton.SetSkin("goblingirl");
            skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin.
            skeleton.SetAttachment("left hand item", "spear");
            animation = skeleton.Data.FindAnimation("walk");

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
Пример #36
0
        public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice)
        {
            itemTex = content.Load<Texture2D>("dude/dude");

            skeletonRenderer = new SkeletonRenderer(graphicsDevice);

            sourceDict.Add("weapon0", new Rectangle(217, 34, 29, 30));
            sourceDict.Add("weapon1", new Rectangle(220, 2, 33, 30));
            sourceDict.Add("weapon2", new Rectangle(2, 164, 19, 49));
            sourceDict.Add("weapon3", new Rectangle(153, 2, 65, 18));
            sourceDict.Add("weapon4", new Rectangle(2, 2, 80, 19));
            sourceDict.Add("chute", new Rectangle(126, 72, 23, 48));
        }
		void OnEnable () {
			if (skeletonRenderer == null) {
				skeletonRenderer = GetComponent<SkeletonRenderer>();
			}

			if (skeletonAnimation == null) {
				skeletonAnimation = GetComponent<SkeletonAnimation>();
				if (skeletonAnimation == null)
					skeletonAnimation = GetComponent<SkeletonAnimator>();
			}

			skeletonRenderer.OnRebuild -= HandleRendererReset;
			skeletonRenderer.OnRebuild += HandleRendererReset;

			if (skeletonAnimation != null) {
				skeletonAnimation.UpdateLocal -= UpdateLocal;
				skeletonAnimation.UpdateLocal += UpdateLocal;
			}

			CollectBones();
		}
		void HandleRendererReset (SkeletonRenderer r) {
			if (OnReset != null)
				OnReset();

			CollectBones();
		}
Пример #39
0
 public SpineRenderManager(EntityWorld world, SkeletonRenderer skeletonRenderer)
 {
     World = world;
     SkeletonRenderer = skeletonRenderer;
 }
Пример #40
0
        public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice)
        {
            blankTex = content.Load<Texture2D>("blank");

            skeletonRenderer = new SkeletonRenderer(graphicsDevice);
            Atlas atlas = new Atlas(graphicsDevice, Path.Combine(content.RootDirectory, "spinegirl.atlas"));
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.readSkeletonData("spinegirl", File.ReadAllText(Path.Combine(content.RootDirectory, "spinegirl.json"))));
            skeleton.SetSkin("default");
            skeleton.SetSlotsToBindPose();
            Animations.Add("walk", skeleton.Data.FindAnimation("walk"));
            Animations.Add("jump", skeleton.Data.FindAnimation("jump"));
            Animations.Add("crawl", skeleton.Data.FindAnimation("crawl"));
            Animations.Add("fall", skeleton.Data.FindAnimation("fall"));
            Animations.Add("grab", skeleton.Data.FindAnimation("grab"));
            Animations.Add("climb", skeleton.Data.FindAnimation("climb"));
            Animations.Add("turnvalve", skeleton.Data.FindAnimation("turnvalve"));

            skeleton.RootBone.X = Position.X;
            skeleton.RootBone.Y = Position.Y;
            skeleton.RootBone.ScaleX = Scale;
            skeleton.RootBone.ScaleY = Scale;

            skeleton.UpdateWorldTransform();
        }
Пример #41
0
        public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice)
        {
            blankTex = content.Load<Texture2D>("Textures/Blank");

            skeletonRenderer = new SkeletonRenderer(graphicsDevice);

            Atlas atlas = new Atlas(graphicsDevice, System.IO.Path.Combine(content.RootDirectory, "spineboy.atlas"));
            SkeletonJson json = new SkeletonJson(atlas);
            json.Scale = 0.5f;
            skeleton = new Skeleton(json.readSkeletonData("spineboy", File.ReadAllText(System.IO.Path.Combine(content.RootDirectory, "spineboy.json"))));
            skeleton.SetSkin("default");
            skeleton.SetSlotsToBindPose();
            walkAnimation = skeleton.Data.FindAnimation("walk");
            jumpAnimation = skeleton.Data.FindAnimation("jump");
            crawlAnimation = skeleton.Data.FindAnimation("crawl");
            fallAnimation = skeleton.Data.FindAnimation("fall");
            grabAnimation = skeleton.Data.FindAnimation("grab");
            climbAnimation = skeleton.Data.FindAnimation("climb");

            skeleton.RootBone.X = Position.X;
            skeleton.RootBone.Y = Position.Y;
            skeleton.UpdateWorldTransform();
        }
Пример #42
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            this.atlas = new Atlas("Content/crab.atlas", new XnaTextureLoader(GraphicsDevice));

            SkeletonJson json = new SkeletonJson(atlas);
            this.skeleton = new Skeleton(json.ReadSkeletonData("Content/crab-skeleton.json"));
            this.animationWalk = skeleton.Data.FindAnimation ("WalkLeft");
            this.animationJump = skeleton.Data.FindAnimation ("Jump");

            this.skeleton.SetSlotsToSetupPose(); // Without this the skin attachments won't be attached. See SetSkin.

            this.animation = 0;
            this.SetSkeletonStartPosition ();

            // used for debugging - draw the bones
            this.lineTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            this.lineTexture.SetData(new[]{Color.White});
            this.textureMaps.Add(lineTexture);

            base.LoadContent ();
        }
Пример #43
0
        protected override void LoadContent()
        {
            bool   useNormalmapShader = false;
            Effect spineEffect;

            if (!useNormalmapShader)
            {
                // Two color tint effect. Note that you can also use the default BasicEffect instead.
                spineEffect = Content.Load <Effect>("spine-xna-example-content\\SpineEffect");
            }
            else
            {
                spineEffect = Content.Load <Effect>("spine-xna-example-content\\SpineEffectNormalmap");
                spineEffect.Parameters["Light0_Direction"].SetValue(new Vector3(-0.5265408f, 0.5735765f, -0.6275069f));
                spineEffect.Parameters["Light0_Diffuse"].SetValue(new Vector3(1, 0.9607844f, 0.8078432f));
                spineEffect.Parameters["Light0_Specular"].SetValue(new Vector3(1, 0.9607844f, 0.8078432f));
                spineEffect.Parameters["Light0_SpecularExponent"].SetValue(2.0f);
            }
            spineEffect.Parameters["World"].SetValue(Matrix.Identity);
            spineEffect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up));

            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = false;
            skeletonRenderer.Effect             = spineEffect;

            skeletonDebugRenderer = new SkeletonDebugRenderer(GraphicsDevice);
            skeletonDebugRenderer.DisableAll();
            skeletonDebugRenderer.DrawClipping = true;

            // String name = "spineboy-pro";
            String name = "raptor-pro";

            // String name = "tank-pro";
            //String name = "coin-pro";
            if (useNormalmapShader)
            {
                name = "raptor-pro";                 // we only have normalmaps for raptor
            }
            String atlasName = name.Replace("-pro", "").Replace("-ess", "");

            bool binaryData = false;

            Atlas atlas;

            if (!useNormalmapShader)
            {
                atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice));
            }
            else
            {
                atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice,
                                                                                            loadMultipleTextureLayers: true, textureSuffixes: new string[] { "", "_normals" }));
            }
            float scale = 1;

            if (name == "spineboy-pro")
            {
                scale = 0.6f;
            }
            if (name == "raptor-pro")
            {
                scale = 0.5f;
            }
            if (name == "tank-pro")
            {
                scale = 0.3f;
            }
            if (name == "coin-pro")
            {
                scale = 1;
            }

            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-pro")
            {
                skeleton.SetSkin("goblin");
            }

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

            state = new AnimationState(stateData);

            if (name == "spineboy-pro")
            {
                skeleton.SetAttachment("head-bb", "head");

                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, "run", true);
                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-pro")
            {
                state.SetAnimation(0, "walk", true);
                state.AddAnimation(1, "gun-grab", false, 2);
            }
            else if (name == "coin-pro")
            {
                state.SetAnimation(0, "animation", true);
            }
            else if (name == "tank-pro")
            {
                skeleton.X += 300;
                state.SetAnimation(0, "drive", true);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X += 400;
            skeleton.Y += GraphicsDevice.Viewport.Height;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Пример #44
0
 public abstract void Render(SkeletonRenderer skeletonRenderer, EntityWorld world, Entity entity, Renderable position);
Пример #45
0
        public void Load()
        {
            mSkeletonRenderer = new SkeletonRenderer(EngineSettings.Graphics.GraphicsDevice);
            mBounds = new SkeletonBounds();

            mSkeleton = SpineDataManager.Instance.NewSkeleton(mName, mScale); //Fixed Scale from here. Main instanciation.
            mSkeleton.SetSlotsToSetupPose(); // Without this the skin attachments won't be attached. See SetSkin.
            mAnimationState = SpineDataManager.Instance.NewAnimationState(mSkeleton.Data);
            mSkeleton.X = mInitPosition.X;
            mSkeleton.Y = mInitPosition.Y;
        }
Пример #46
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");
        }
 public override void draw(Spine.SkeletonRenderer sb)
 {
     //sb.Draw(Game1.whitePixel, sword_position, null, Color.Pink, 0.0f, Vector2.Zero, sword_hitbox, SpriteEffects.None, 0.5f);
     //chaseAnim.drawAnimationFrame(0.0f, sb, position, new Vector2(3, 3), 0.5f);
 }
Пример #48
0
        protected override void LoadContent()
        {
            // Two color tint effect, comment line 80 to disable
            var spineEffect = Content.Load <Effect>("spine-xna-example-content\\SpineEffect");

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

            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = false;
            skeletonRenderer.Effect             = spineEffect;

            skeletonDebugRenderer = new SkeletonDebugRenderer(GraphicsDevice);
            skeletonDebugRenderer.DisableAll();
            skeletonDebugRenderer.DrawClipping = true;

            // String name = "spineboy-ess";
            // String name = "goblins-pro";
            // String name = "raptor-pro";
            // String name = "tank-pro";
            String name      = "coin-pro";
            String atlasName = name.Replace("-pro", "").Replace("-ess", "");

            if (name == "goblins-pro")
            {
                atlasName = "goblins-mesh";
            }
            bool binaryData = false;

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

            float scale = 1;

            if (name == "spineboy-ess")
            {
                scale = 0.6f;
            }
            if (name == "raptor-pro")
            {
                scale = 0.5f;
            }
            if (name == "tank-pro")
            {
                scale = 0.3f;
            }
            if (name == "coin-pro")
            {
                scale = 1;
            }

            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-pro")
            {
                skeleton.SetSkin("goblin");
            }

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

            state = new AnimationState(stateData);

            if (name == "spineboy-ess")
            {
                skeleton.SetAttachment("head-bb", "head");

                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, "run", true);
                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-pro")
            {
                state.SetAnimation(0, "walk", true);
                state.AddAnimation(1, "gun-grab", false, 2);
            }
            else if (name == "coin-pro")
            {
                state.SetAnimation(0, "animation", true);
            }
            else if (name == "tank-pro")
            {
                skeleton.X += 300;
                state.SetAnimation(0, "drive", true);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X += 400;
            skeleton.Y += GraphicsDevice.Viewport.Height;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
 public override void draw(Spine.SkeletonRenderer sb)
 {
     //sb.Draw(Game1.whitePixel, position, null, Color.Green, 0.0f, Vector2.Zero, new Vector2(48, 48), SpriteEffects.None, 1.0f);
 }