コード例 #1
0
        public FireballRendererInformation(Fireball fireball)
        {
            var texture = SimulationGame.ContentManager.Load <Texture2D>(@"Spells\Fireball\Lv1UFireballp");
            var sheet   = new Spritesheet.Spritesheet(texture).WithGrid((15, 29)).WithFrameDuration(120).WithCellOrigin(new Point(7, 0));

            Flying = sheet.CreateAnimation((0, 0), (1, 0), (2, 0));
            Flying.Start(Repeat.Mode.Loop);
        }
コード例 #2
0
        public void StartImpactAnimation()
        {
            var explode = SimulationGame.ContentManager.Load <Texture2D>(@"Spells\Fireball\Explode");
            var sheet   = new Spritesheet.Spritesheet(explode).WithGrid((61, 60)).WithFrameDuration(100).WithCellOrigin(new Point(30, 30));

            Impact = sheet.CreateAnimation((0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0));
            Impact.Start(Repeat.Mode.Once);
        }
コード例 #3
0
        public SlashRendererInformation(Slash slash)
        {
            var texture = SimulationGame.ContentManager.Load <Texture2D>(@"Spells\Slash\Slash");
            var sheet   = new Spritesheet.Spritesheet(texture).WithFrameEffect(slash.Flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None).WithGrid((64, 64)).WithCellOrigin(new Point(32, 32)).WithFrameDuration(slash.Duration.TotalMilliseconds / 5);

            slashAnimation = sheet.CreateAnimation((0, 0), (1, 0), (2, 0), (3, 0), (4, 0));
            slashAnimation.Start(Repeat.Mode.Once);

            Angle = slash.Flipped ? slash.Angle - 0.5f * (float)Math.PI : slash.Angle;
        }
コード例 #4
0
        public static LivingEntityRendererInformation CreateRendererInformation(LivingEntity livingEntity)
        {
            var livingEntityType = lookup[livingEntity.LivingEntityType];

            var texture = SimulationGame.ContentManager.Load <Texture2D>(livingEntityType.SpritePath);
            var sheet   = new Spritesheet.Spritesheet(texture);

            if (livingEntityType.WithGrid)
            {
                sheet = sheet.WithGrid(livingEntityType.SpriteBounds);
            }

            sheet = sheet.WithCellOrigin(livingEntityType.SpriteOrigin).WithFrameDuration(livingEntityType.FrameDuration);

            Frame[] downFrames  = new Frame[livingEntityType.DownAnimation.Length];
            Frame[] upFrames    = new Frame[livingEntityType.UpAnimation.Length];
            Frame[] leftFrames  = new Frame[livingEntityType.LeftAnimation.Length];
            Frame[] rightFrames = new Frame[livingEntityType.RightAnimation.Length];

            for (var i = 0; i < livingEntityType.DownAnimation.Length; i++)
            {
                downFrames[i] = sheet.CreateFrame(livingEntityType.DownAnimation[i].X, livingEntityType.DownAnimation[i].Y, sheet.FrameDefaultDuration, sheet.FrameDefaultEffects);
            }
            for (var i = 0; i < livingEntityType.UpAnimation.Length; i++)
            {
                upFrames[i] = sheet.CreateFrame(livingEntityType.UpAnimation[i].X, livingEntityType.UpAnimation[i].Y, sheet.FrameDefaultDuration, sheet.FrameDefaultEffects);
            }
            for (var i = 0; i < livingEntityType.LeftAnimation.Length; i++)
            {
                leftFrames[i] = sheet.CreateFrame(livingEntityType.LeftAnimation[i].X, livingEntityType.LeftAnimation[i].Y, sheet.FrameDefaultDuration, sheet.FrameDefaultEffects);
            }
            for (var i = 0; i < livingEntityType.RightAnimation.Length; i++)
            {
                rightFrames[i] = sheet.CreateFrame(livingEntityType.RightAnimation[i].X, livingEntityType.RightAnimation[i].Y, sheet.FrameDefaultDuration, sheet.FrameDefaultEffects);
            }

            var rendererInformation = new LivingEntityRendererInformation(
                new Animation(downFrames),
                new Animation(upFrames),
                new Animation(leftFrames),
                new Animation(rightFrames)
                );

            return(rendererInformation);
        }
コード例 #5
0
        public static void Draw(SpriteBatch spriteBatch, GameTime gameTime, Blink blink)
        {
            if (blink.InteriorID == SimulationGame.Player.InteriorID && SimulationGame.VisibleArea.Contains(blink.Position))
            {
                if (blink.BlinkAnimation == null)
                {
                    var texture = SimulationGame.ContentManager.Load <Texture2D>(@"Spells\Blink\Blink");
                    var sheet   = new Spritesheet.Spritesheet(texture).WithGrid((80, 80)).WithFrameDuration(40).WithCellOrigin(new Point(40, 48));

                    blink.BlinkAnimation = sheet.CreateAnimation((0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (0, 2), (1, 2));
                    blink.BlinkAnimation.Start(Repeat.Mode.Once);
                }

                if (blink.BlinkAnimation.IsStarted)
                {
                    spriteBatch.Draw(blink.BlinkAnimation, blink.Origin.Position.ToVector(), new Color(180, 0, 0, 255), /*scale: new Vector2(2.5f, 2.5f), */ layerDepth: GeometryUtils.GetLayerDepthFromPosition(blink.Origin.Position.X, blink.Origin.Position.Y + World.WorldGrid.BlockSize.Y));
                }
            }
        }