Пример #1
0
        public override void LoadContent(ContentManager content)
        {
            spriteSheet = new SpriteSheet();
            spriteSheet.Sheet = content.Load<Texture2D>("tilesheet");
            spriteSheet.Map = content.Load<Dictionary<string, Rectangle>>("tilesheetmap");
            sourceRect = spriteSheet.Map[groundFrameName];

            float tilePaddingScale = 1.04f;

            wallFrame = new Frame();
            int randomNumberR = random.Next(10);
            int randomNumberG = random.Next(10);
            int randomNumberB = random.Next(10);
            Color wallColor = new Color(225 - randomNumberR, 225 - randomNumberG, 225 - randomNumberB);
            wallFrame.Initialize(spriteSheet, Vector2.Zero, wallFrameName, wallColor, tilePaddingScale, SpriteEffects.None);
            wallFrame.LayerDepth = 0.3f;

            checkpointPoleFrame = new Frame();
            checkpointPoleFrame.Initialize(spriteSheet, Vector2.Zero, checkpointPoleFrameName, Color.White, 1f, SpriteEffects.None);
            checkpointPoleFrame.LayerDepth = 0.25f;

            checkpointFlagFrame = new Frame();
            checkpointFlagFrame.Initialize(spriteSheet, Vector2.Zero, checkpointFlagFrameName, Color.White, 1f, SpriteEffects.None);
            checkpointFlagFrame.LayerDepth = 0.25f;

            groundFrame = new Frame();
            groundFrame.Initialize(spriteSheet, Vector2.Zero, groundFrameName, Color.White, tilePaddingScale, SpriteEffects.None);
            groundFrame.LayerDepth = 0.24f;

            spikeFrame = new Frame();
            spikeFrame.Initialize(spriteSheet, Vector2.Zero, spikeFrameName, Color.Red, 1f, SpriteEffects.None);
            spikeFrame.LayerDepth = 0.1f;

            staticPlatformFrame = new Frame();
            staticPlatformFrame.Initialize(spriteSheet, Vector2.Zero, staticPlatformFrameName, Color.White, tilePaddingScale, SpriteEffects.None);
            staticPlatformFrame.LayerDepth = 0.25f;

            movingPlatformFrame = new Frame();
            movingPlatformFrame.Initialize(spriteSheet, Vector2.Zero, movingPlatformFrameName, Color.White, tilePaddingScale, SpriteEffects.None);
            movingPlatformFrame.LayerDepth = 0.25f;

            fallingPlatformFrame = new Frame();
            fallingPlatformFrame.Initialize(spriteSheet, Vector2.Zero, fallingPlatformFrameName, Color.White, tilePaddingScale, SpriteEffects.None);
            fallingPlatformFrame.LayerDepth = 0.25f;
        }
Пример #2
0
        public override void LoadContent(ContentManager content)
        {
            // Choose color
            if (player.PlayerIndex == PlayerIndex.One) // Green
                this.color = new Color(0, 255, 0);
            else if (player.PlayerIndex == PlayerIndex.Two) // Blue
                this.color = new Color(0, 255, 255);
            else if (player.PlayerIndex == PlayerIndex.Three) // Yellow
                this.color = new Color(255, 255, 0);
            else if (player.PlayerIndex == PlayerIndex.Four) // Pink
                this.color = new Color(255, 200, 255);

            spriteSheet = new SpriteSheet();
            spriteSheet.Sheet = content.Load<Texture2D>("animationsheet");
            spriteSheet.Map = content.Load<Dictionary<string, Rectangle>>("animationsheetmap");

            spriteEffects = SpriteEffects.None;
            float spritePaddingScale = 1f;

            // Load animations:
            // idle animation
            int idleFrameTime = 120;
            idleAnimation = new Animation();
            idleAnimation.Initialize(spriteSheet, Vector2.Zero, idleAnimationName, idleFrameTime, this.color, spritePaddingScale, spriteEffects, true);
            idleAnimation.LayerDepth = playerLayerDepth;
            // make this the current animation
            currentAnimation = idleAnimation;

            // idle frozen animation
            int idleFrozenFrameTime = 0;
            idleFrozenAnimation = new Animation();
            idleFrozenAnimation.Initialize(spriteSheet, Vector2.Zero, idleAnimationName, idleFrozenFrameTime, this.color, spritePaddingScale, spriteEffects, false);
            idleFrozenAnimation.LayerDepth = playerLayerDepth;

            // idle shoot animation
            int idleShootFrameTime = 30;
            idleShootAnimation = new Animation();
            idleShootAnimation.Initialize(spriteSheet, Vector2.Zero, idleShootAnimationName, idleShootFrameTime, this.color, spritePaddingScale, spriteEffects, false);
            idleShootAnimation.LayerDepth = playerLayerDepth;

            // running animation
            int runFrameTime = 25;
            runAnimation = new Animation();
            runAnimation.Initialize(spriteSheet, Vector2.Zero, runAnimationName, runFrameTime, this.color, spritePaddingScale, spriteEffects, true);
            runAnimation.LayerDepth = playerLayerDepth;

            // dash animation
            int dashFrameTime = 0;
            dashAnimation = new Animation();
            dashAnimation.Initialize(spriteSheet, Vector2.Zero, dashAnimationName, dashFrameTime, this.color, spritePaddingScale, spriteEffects, false);
            dashAnimation.LayerDepth = playerLayerDepth;

            // jumping animation
            int jumpFrameTime = 120;
            jumpAnimation = new Animation();
            jumpAnimation.Initialize(spriteSheet, Vector2.Zero, jumpAnimationName, jumpFrameTime, this.color, spritePaddingScale, spriteEffects, false);
            jumpAnimation.LayerDepth = playerLayerDepth;

            // falling animation
            int fallFrameTime = 120;
            fallAnimation = new Animation();
            fallAnimation.Initialize(spriteSheet, Vector2.Zero, fallAnimationName, fallFrameTime, this.color, spritePaddingScale, spriteEffects, false);
            fallAnimation.LayerDepth = playerLayerDepth;

            // gun weapon animations
            int gunFrameTime = 30;
            int gunShotFrameTime = 30;
            gunRepresentation = new WeaponRepresentation<PlayerWeapon>(player, player.Gun, new Vector2(gunOffsetX, gunOffsetY));
            gunRepresentation.InitializeAnimation(spriteSheet, Vector2.Zero, gunAnimationName, gunFrameTime, this.color, 1, spriteEffects, false);
            gunRepresentation.WeaponAnimation.LayerDepth = 0.05f;
            gunRepresentation.InitializeBullets(spriteSheet, Vector2.Zero, gunShotAnimationName, gunShotFrameTime, this.color, 1, spriteEffects, true);
            gunRepresentation.BulletsLayerDepth(0.05f);

            // sword weapon animations
            int swordFrameTime = 30;
            int swordShotFrameTime = 30;
            swordRepresentation = new WeaponRepresentation<PlayerWeapon>(player, player.Sword, new Vector2(swordOffsetX, swordOffsetY));
            swordRepresentation.InitializeAnimation(spriteSheet, Vector2.Zero, swordAnimationName, swordFrameTime, this.color, 1, spriteEffects, false);
            swordRepresentation.WeaponAnimation.LayerDepth = 0.05f;
            swordRepresentation.InitializeBullets(spriteSheet, Vector2.Zero, swordShotAnimationName, swordShotFrameTime, this.color, 1, spriteEffects, true);
            swordRepresentation.BulletsLayerDepth(0.05f);

            // eyes frame
            eyesFrame = new Frame();
            eyesFrame.Initialize(spriteSheet, Vector2.Zero, eyesFrameName, Color.White, spritePaddingScale, spriteEffects);
            eyesFrame.LayerDepth = playerLayerDepth - 0.001f;

            // dash trail particle emitter
            dashTrailEmitter.Initialize(5, 0.05f, 0.2f);
        }