コード例 #1
0
        public void SetAnimations()
        {
            spritesheet = new Spritesheet.Spritesheet(GameManager.Assets["mine"]).WithGrid((16, 10));

            animation = spritesheet.CreateAnimation((0, 0), (1, 0), (2, 0));
            animation.Start(Repeat.Mode.LoopWithReverse);
        }
コード例 #2
0
        // Create all animations from spritesheet

        #region Animation

        public void SetAnimations()
        {
            texture = GameManager.Assets["square"];

            gunTexture = GameManager.Assets["gun2"];

            rocketLauncherTexture = GameManager.Assets["launcher"];

            shield.SetTexture();

            healthBar.SetTexture();

            Texture2D spriteSheetTexture = GameManager.Assets["mamba"];

            spriteSheet = new Spritesheet.Spritesheet(spriteSheetTexture).WithGrid((16, 16));

            idleAnim         = spriteSheet.CreateAnimation((0, 1), (1, 1), (2, 1));
            runningAnimation = spriteSheet.CreateAnimation((0, 0), (1, 0), (2, 0));
            jumpingAnimation = spriteSheet.CreateAnimation((0, 2), (1, 2), (2, 2));

            idleAnimLeft         = idleAnim.FlipX();
            runningAnimationLeft = runningAnimation.FlipX();
            jumpingAnimationLeft = jumpingAnimation.FlipX();

            currentAnimation = idleAnim;

            idleAnim.Start(Repeat.Mode.Loop);
            runningAnimation.Start(Repeat.Mode.Loop);
            idleAnimLeft.Start(Repeat.Mode.Loop);
            runningAnimationLeft.Start(Repeat.Mode.Loop);
            currentAnimation.Start(Repeat.Mode.Loop);
        }
コード例 #3
0
        public override void SetAnimations()
        {
            spriteSheet = new Spritesheet.Spritesheet(GameManager.Assets["guard"]).WithGrid((16, 16));

            idleAnim      = spriteSheet.CreateAnimation((0, 0), (1, 0));
            idleAnim_Left = idleAnim.FlipX();
            runAnim       = spriteSheet.CreateAnimation((0, 0), (1, 0), (2, 0), (3, 0));
            runAnim_Left  = runAnim.FlipX();

            currentAnimation = idleAnim;

            idleAnim.Start(Repeat.Mode.Loop);
            idleAnim_Left.Start(Repeat.Mode.Loop);
            runAnim.Start(Repeat.Mode.Loop);
            runAnim_Left.Start(Repeat.Mode.Loop);
            currentAnimation.Start(Repeat.Mode.Loop);

            healthBar.SetTexture();
        }
コード例 #4
0
        public override void LoadContent()
        {
            font = game.Content.Load <SpriteFont>("Font");
            // 521px wide x 464px high
            idleTexture = game.Content.Load <Texture2D>("fairy_idle");
            // 536px wide x 501px high
            flyingTexture = game.Content.Load <Texture2D>("fairy_fly");
            //695px wide x 640px high
            dyingTexture      = game.Content.Load <Texture2D>("fairy_die");
            radius            = (500 * scale.X) / 2;
            idleSpriteSheet   = new Spritesheet.Spritesheet(idleTexture).WithGrid((521, 464), (0, 0), (0, 0));
            flyingSpriteSheet = new Spritesheet.Spritesheet(flyingTexture).WithGrid((536, 501), (0, 0), (0, 0));
            dyingSpriteSheet  = new Spritesheet.Spritesheet(dyingTexture).WithGrid((695, 640), (0, 0), (0, 0));
            CreateAnimations();

            List <Texture2D> textures = new List <Texture2D>();

            textures.Add(game.Content.Load <Texture2D>("diamond"));
            particleEngine = new ParticleEngine(game, textures, GetBottomPos(), BuildPalette(), 1);
        }
コード例 #5
0
ファイル: Scout.cs プロジェクト: m133solomon/SlashySam
        public Scout(Vector2 position)
        {
            Type             = EnemyType.Scout;
            guardingPosition = position;
            Position         = position;
            Scale            = new Vector2(2.6f, 3f);
            sourceRectangle  = new Rectangle(0, 0, 13, 16);
            var sheet = new Spritesheet.Spritesheet(Game.Assets.Enemies.Scout).WithGrid((13, 16));

            walkRight        = sheet.CreateAnimation((0, 1), (1, 1));
            idleRight        = sheet.CreateAnimation((0, 0), (1, 0), (2, 0));
            walkLeft         = walkRight.FlipX();
            idleLeft         = idleRight.FlipX();
            currentAnimation = walkRight;
            walkLeft.Start(Repeat.Mode.Loop);
            walkRight.Start(Repeat.Mode.Loop);
            idleLeft.Start(Repeat.Mode.Loop);
            idleRight.Start(Repeat.Mode.Loop);
            currentAnimation.Start(Repeat.Mode.Loop);

            Sword = new ScoutSword(this);

            Initialize();
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: m133solomon/SlashySam
        public Player()
        {
            Sword = new PlayerSword(this);

            Texture = Game.Assets.Player.Sam01;
            Scale   = new Vector2(1.7f);
            Game.Camera.Position = Position;
            sourceRectangle      = new Rectangle(0, 0, 16, 29);

            Spritesheet.Spritesheet sheet = new Spritesheet.Spritesheet(Texture).WithGrid((16, 29));

            animations.Add(Anim.IdleRight, sheet.CreateAnimation((0, 0), (1, 0), (2, 0)));
            animations.Add(Anim.WalkRight, sheet.CreateAnimation((0, 1), (1, 1)));

            animations[Anim.IdleLeft] = animations[Anim.IdleRight].FlipX();
            animations[Anim.WalkLeft] = animations[Anim.WalkRight].FlipX();

            animations[Anim.IdleRight].Start(Repeat.Mode.Loop);
            animations[Anim.IdleLeft].Start(Repeat.Mode.Loop);

            animations[Anim.WalkRight].Start(Repeat.Mode.Loop);
            animations[Anim.WalkLeft].Start(Repeat.Mode.Loop);

            currentAnim = animations[Anim.IdleRight];

            Spritesheet.Spritesheet headSheet = new Spritesheet.Spritesheet(Game.Assets.Player.SamHead).WithGrid((18, 14));

            headAnimRight = headSheet.CreateAnimation((0, 0), (1, 0));
            headAnimLeft  = headAnimRight.FlipX();

            headAnimRight.Start(Repeat.Mode.Loop);
            headAnimLeft.Start(Repeat.Mode.Loop);

            currentHeadAnim = headAnimLeft;

            var dashSize = Helper.SquareTexture.CreateScale(Rectangle.Width, Rectangle.Height);

            dashEffectSettings = new ParticleSystemSettings()
            {
                Density       = 1f,
                Lifetime      = new Size(0.2f, 0.5f),
                Size          = new Size(dashSize.X, dashSize.Y),
                Speed         = new Size(0, 0),
                Texture       = Helper.SquareTexture,
                OneTime       = false,
                DecreaseSize  = true,
                DecreaseAlpha = false,
                Color         = Color.Black
            };
            smokeBombEffectSettings = new ParticleSystemSettings()
            {
                Density       = 0.3f,
                Lifetime      = new Size(0.7f, 1.6f),
                Size          = new Size(3f, 6f),
                Speed         = new Size(100, 200),
                Texture       = Game.Assets.PixelatedCircle,
                OneTime       = false,
                DecreaseSize  = true,
                DecreaseAlpha = true,
                Colors        = new List <Color>()
                {
                    new Color(38, 38, 38),
                    new Color(69, 69, 69)
                },
                SpawnInCircle = false,
                CircleRadius  = (int)smokeBombSize.X,
            };

            dashEffect      = new ParticleSystem(Position, new Vector2(1, 1), dashEffectSettings);
            smokeBombEffect = new ParticleSystem(Position, smokeBombSize, smokeBombEffectSettings);

            HasCollider = true;
        }