コード例 #1
0
        public void LoadContent(SpriteBatch spriteBatch, ContentManager Content, Viewport viewport, 
            Camera camera, Texture2D enemyTexture, GraphicsDeviceManager graphics, 
            SoundEffect _backgroundMusic, GameController _gameController, 
            SoundEffect _fireballSound, SpriteFont _spritefont, Texture2D _bossTexture)
        {
            _enemyTexture = enemyTexture;
            this.camera = camera;
            _graphics = graphics;

            spritefont = _spritefont;

            bossTexture = _bossTexture;

            backgroundMusic = _backgroundMusic;
            fireballSound = _fireballSound;

            _content = Content;
            gameController = _gameController;
            character = Content.Load<Texture2D>("imp");
            Flame.SetTexture(Content.Load<Texture2D>("Flames"));
            
            soundEffectInstance = backgroundMusic.CreateInstance();

            onFirstLevel = false;
            onSecondLevel = false;
            onThirdLevel = false;
            onFourthLevel = false;

        }
コード例 #2
0
        // The constructor of the Player class//
        public Player(Vector2 position, Map map, List<AnimatedSprites> animatedSprites, Camera camera, GameController _gameController, SoundEffect _fireballSound) : base(position, camera)//this position is handled through the base class
        {
            spreadRandom = new Random();
            life = 5;
            giveDamage = 1;
            this.position = position;
            this.camera = camera;
            this.map = map;
            this.animatedSprites = animatedSprites;

            fireballSound = _fireballSound;

            hitbox = new Vector4(15, 40, 49, 66); // bästa raden gällande karaktären!   (15, 40, 49, 66)
            offset = new Vector2(hitbox.X + hitbox.Z, hitbox.Y + hitbox.W) / 2f;
            gameController = _gameController;
            FramesPerSecond = 6;

            //Adds all the players animations
            AddAnimation(3, 1, 0, "Down", 64, 64);
            AddAnimation(3, 65, 0, "Left", 64, 64);
            AddAnimation(3, 129, 0, "Right", 64, 64);
            AddAnimation(3, 193, 0, "Up", 64, 64);
            PlayAnimation("Down");
        }
コード例 #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            
            //create all the necessary classes!
            menuController = new MenuController();
            gameController = new GameController(this);
            
            camera = new Camera(GraphicsDevice.Viewport);

            //snow = new ParticleGenerator(Content.Load<Texture2D>("Snowflake"), graphics.GraphicsDevice.Viewport.Width, 50, camera);
            rain = new ParticleGenerator(Content.Load<Texture2D>("Rain"), graphics.GraphicsDevice.Viewport.Width, 50, camera);

            backgroundMusic = Content.Load<SoundEffect>("sleeping_beast_4"); // ge cred ... //http://www.opsound.org/artist/dhalius/

            fireballSound = Content.Load<SoundEffect>("fireballShot");// när spelaren skjuter så kommer ljud!
            spritefont = Content.Load<SpriteFont>("NewSpriteFont");
            menuFont = Content.Load<SpriteFont>("SpriteFontMenu/NewSpriteFont");
            //Load all the textures here and sound as well!
            Texture2D enemyTexture = Content.Load<Texture2D>("Bat");
            Texture2D bossTexture = Content.Load<Texture2D>("Fox");
            Texture2D startMenuBackground = Content.Load<Texture2D>("KillerStory");
            Texture2D playButton = Content.Load<Texture2D>("playButton");
            Texture2D instructionButton = Content.Load<Texture2D>("InstructionsButton");
            //character = Content.Load<Texture2D>("Fox");

            soundEffectInstance = backgroundMusic.CreateInstance();

            //pause saker
            gameOverScreen = Content.Load<Texture2D>("GameOverScreen");
            gameOverRectangle = new Rectangle(0, 0, gameOverScreen.Width, gameOverScreen.Height);

            pauseTexture = Content.Load<Texture2D>("PauseMenu");
            pausedRectangle = new Rectangle(0, 0, pauseTexture.Width, pauseTexture.Height);

            FishishedScreen = Content.Load<Texture2D>("FinishedScreen");
            FishishedRectangle = new Rectangle(0, 0, FishishedScreen.Width, FishishedScreen.Height);

            pauseInstructions = Content.Load<Texture2D>("Instructions");
            pausedRectangleInstruction = new Rectangle(0, 0, pauseTexture.Width, pauseTexture.Height);

            buttonPlay = new PauseButton();
            buttonPlay.Load(Content.Load<Texture2D>("ResumeButton2"), new Vector2(400, 400));
            buttonQuit = new PauseButton();
            buttonQuit.Load(Content.Load<Texture2D>("QuitButton2"), new Vector2(400, 450));
            buttonMainMenu = new PauseButton();
            buttonMainMenu.Load(Content.Load<Texture2D>("MenuButton2"), new Vector2(400, 500));
            buttonInstruction = new PauseButton();
            buttonInstruction.Load(Content.Load<Texture2D>("InstructionsButton"), new Vector2(400, 550));
            buttonBack = new PauseButton();
            buttonBack.Load(Content.Load<Texture2D>("ButtonBack"), new Vector2(740, 780));
            
            //load all the classes and give them all the necessary parameters!
            menuController.LoadContent(spriteBatch, Content, GraphicsDevice.Viewport, startMenuBackground, playButton, instructionButton);
            gameController.LoadContent(spriteBatch, Content, GraphicsDevice.Viewport, camera, enemyTexture, graphics, backgroundMusic, gameController, fireballSound, spritefont, bossTexture);

            menuController.setPosition(new Vector2(400, 400));// sätter positionen för knappen!
        }