コード例 #1
0
ファイル: DonkeyKong.cs プロジェクト: tiago-gmfrr/tpi_2020
 /// <summary>
 /// Updates the visual mario lives in the upper left corner
 /// </summary>
 private void LivesLeftDisplay()
 {
     for (int i = 0; i < _livesLeft; i++)
     {
         GenericSprite lifeSprite = new GenericSprite(_game);
         lifeSprite.LoadContent("Graphics/marioLife");
         lifeSprite._position = new Vector2(stackedBarrels._position.X + lifeSprite._texture.Width * i, 0);
         allLives.Add(lifeSprite);
     }
 }
コード例 #2
0
ファイル: DonkeyKong.cs プロジェクト: tiago-gmfrr/tpi_2020
        /// <summary>
        /// LoadContent will be called once per game to load all the content
        /// </summary>
        public void LoadContent()
        {
            brick.LoadContent("Graphics/Ground");
            stackedBarrels.LoadContent("Graphics/StackedBarrels");

            arcadeClassic           = _content.Load <SpriteFont>("arcadeClassic");
            arcadeClassicBig        = _content.Load <SpriteFont>("arcadeClassicBig");
            animationsMovementMario = new Dictionary <string, Animation>()
            {
                { "WalkRight", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
                { "WalkLeft", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkLeft"), 3) },
                { "WalkDown", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
                { "Climb", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioClimb"), 2) },
                { "JumpRight", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioJumpingRight"), 2) },
                { "JumpLeft", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioJumpingLeft"), 2) },
            };

            marioSoundEffects = new Dictionary <string, SoundEffect>()
            {
                { "Walking", _content.Load <SoundEffect>("Sounds/SoundEffects/walking") },
                { "Jump", _content.Load <SoundEffect>("Sounds/SoundEffects/jump") },
                { "Climbing", _content.Load <SoundEffect>("Sounds/SoundEffects/marioClimb") },
            };



            animationsKong = new Dictionary <string, Animation>()
            {
                { "Idle", new Animation(_content.Load <Texture2D>("Graphics/Animations/KongIdleAnimationSmall"), 3) },
                { "GrabBarrel", new Animation(_content.Load <Texture2D>("Graphics/Animations/KongBarrelAnimation"), 3) },
            };

            kongSoundEffects = new Dictionary <string, SoundEffect>()
            {
                { "Idle", _content.Load <SoundEffect>("Sounds/SoundEffects/kongStomp") },
            };

            oilBarrelAnimations = new Dictionary <string, Animation>()
            {
                { "Animation", new Animation(_content.Load <Texture2D>("Graphics/Animations/oilBarrelAnimation"), 2) }
            };

            princessAnimations = new Dictionary <string, Animation>()
            {
                { "Animation", new Animation(_content.Load <Texture2D>("Graphics/Animations/PrincessAnimation"), 2) }
            };

            gameOverSound    = _content.Load <SoundEffect>("Sounds/SoundEffects/gameOver");
            gameOverInstance = gameOverSound.CreateInstance();
            gameWonSound     = _content.Load <SoundEffect>("Sounds/SoundEffects/gameWon");
            gameWonInstance  = gameWonSound.CreateInstance();
        }
コード例 #3
0
        /// <summary>
        /// LoadContent will be called once per game to load all the content
        /// </summary>
        public void LoadContent()
        {
            arcadeClassic = _content.Load <SpriteFont>("arcadeClassic");

            DKTitle.LoadContent("Graphics/DKTitle");

            joystickRightLeft.LoadContent("Graphics/JoystickRightLeft");
            marioWalking.LoadContent("Graphics/MarioMovingExample");

            joystickUpDown.LoadContent("Graphics/JoystickUpDown");
            marioClimbing.LoadContent("Graphics/MarioClimbingExample");

            arcadeButtons.LoadContent("Graphics/ArcadeButtons");
            marioJumping.LoadContent("Graphics/MarioJumpingExample");

            goBackButton.LoadContent("Controls/GoBackButton");


            animationsMovementMario = new Dictionary <string, Animation>()
            {
                { "WalkRight", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
                { "WalkLeft", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkLeft"), 3) },
                { "WalkDown", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
                { "WalkUp", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
            };

            Dictionary <string, SoundEffect> marioSOundEffects = new Dictionary <string, SoundEffect>()
            {
                { "Walking", _content.Load <SoundEffect>("Sounds/SoundEffects/walking") },
                { "Jump", _content.Load <SoundEffect>("Sounds/SoundEffects/jump") },
                { "Climbing", _content.Load <SoundEffect>("Sounds/SoundEffects/marioClimb") },
            };

            _mario = new Mario(_game, animationsMovementMario, marioSOundEffects, _graphicsDevice)
            {
                Position = new Vector2(_graphicsDevice.Viewport.Width * 0.75f, _graphicsDevice.Viewport.Height * 0.85f),
                Input    = new Input()
                {
                    Up    = Keys.W,
                    Down  = Keys.S,
                    Left  = Keys.A,
                    Right = Keys.D,
                }
            };
        }
コード例 #4
0
        /// <summary>
        /// LoadContent will be called once per game to load all the content
        /// </summary>
        private void LoadContent()
        {
            animationsMovementMario = new Dictionary <string, Animation>()
            {
                { "WalkRight", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
                { "WalkLeft", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkLeft"), 3) },
                { "WalkDown", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
                { "WalkUp", new Animation(_content.Load <Texture2D>("Graphics/Animations/MarioWalkRight"), 3) },
            };

            Dictionary <string, SoundEffect> marioSOundEffects = new Dictionary <string, SoundEffect>()
            {
                { "Walking", _content.Load <SoundEffect>("Sounds/SoundEffects/walking") },
                { "Jump", _content.Load <SoundEffect>("Sounds/SoundEffects/jump") },
                { "Climbing", _content.Load <SoundEffect>("Sounds/SoundEffects/marioClimb") },
            };

            _mario = new Mario(_game, animationsMovementMario, marioSOundEffects, _graphicsDevice)
            {
                Position = new Vector2(100, _graphicsDevice.Viewport.Height * 0.8f),
                Input    = new Input()
                {
                    Up    = Keys.W,
                    Down  = Keys.S,
                    Left  = Keys.A,
                    Right = Keys.D,
                }
            };

            var animationsMenuBarrels1 = new Dictionary <string, Animation>()
            {
                { "Animated", new Animation(_content.Load <Texture2D>("Graphics/Animations/MenuBarrels"), 2) },
            };

            var animationsMenuBarrels2 = new Dictionary <string, Animation>()
            {
                { "Animated", new Animation(_content.Load <Texture2D>("Graphics/Animations/MenuBarrels"), 2) },
            };

            _menuBarrels = new List <AnimatedSprite>()
            {
                new AnimatedSprite(_game, animationsMenuBarrels1)
                {
                    Position = new Vector2(_graphicsDevice.Viewport.Width * 0.05f, _graphicsDevice.Viewport.Height * 0.35f),
                },
                new AnimatedSprite(_game, animationsMenuBarrels2)
                {
                    Position = new Vector2(_graphicsDevice.Viewport.Width * 0.82f, _graphicsDevice.Viewport.Height * 0.35f),
                },
            };

            var animationsMenuKong = new Dictionary <string, Animation>()
            {
                { "Animated", new Animation(_content.Load <Texture2D>("Graphics/Animations/KongIdleAnimation"), 3) },
            };


            _menuKong = new AnimatedSprite(_game, animationsMenuKong);

            _menuKong.Position = new Vector2(_graphicsDevice.Viewport.Width / 2 - _menuKong._width / 2, _graphicsDevice.Viewport.Height * 0.45f);


            gameBackgroundMusic = _game.Content.Load <Song>("Sounds/Music/gameMusic");
            menuBackgroundMusic = _game.Content.Load <Song>("Sounds/Music/menuMusic");


            MediaPlayer.Play(menuBackgroundMusic);
            MediaPlayer.Volume      = 0.1f;
            MediaPlayer.IsRepeating = true;

            DKTitle.LoadContent("Graphics/DKTitle");
            playButton.LoadContent("Controls/PlayButton");
            infoButton.LoadContent("Controls/InfoButton");
            exitButton.LoadContent("Controls/ExitButton");
        }