Exemple #1
0
        public void setUpThirdPersonCamera(Character heroChar)
        {
            heroCharacter = heroChar;

            thirdPersonPosition = heroCharacter.Position - new Vector3(-5, 20, -10);
            thirdPersonTarget = heroCharacter.Position - new Vector3(-5, 0, 0);

            viewMatrix = Matrix.Identity;
            //Paramaters of projectionMatrix:  Field Of View/Apsect Ratio/Near Plane/Far Plane
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(100.0f), 16 / 9, .5f, 500f);
        }
Exemple #2
0
 public Camera(bool thirdPerson, Character heroChar)
 {
     if (thirdPerson)
     {
         thirdPersonCam = true;
         setUpThirdPersonCamera(heroChar);
     }
     else
     {
         //Default Camera (Main)
         thirdPersonCam = false;
         setUpCamera();
     }
 }
Exemple #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);

            //
            //  LOAD CHARACTERS AND ENEMIES
            //
                //Load our main character
                heroModel = Content.Load<Model>("Models\\CharModel");
                modPosition = GameConstants.heroStartPosition;
                modRotation = GameConstants.heroStartRotation;
                modScale = GameConstants.heroStartScale;
                heroCharacter = new Character(heroModel, modPosition, modRotation, modScale);
                //Assign the attack to the model. Not actually created until HeroAttack.cs
                heroAttack = Content.Load<Model>("Models\\BulletAttack");
                GameConstants.heroAttackTexure = Content.Load<Texture2D>("Textures\\HeroAttack");

                //Declary enemies for each room
                //Define the number of enemies in each room and what enemies are contained within
                room1Enemies = new Enemy[GameConstants.numRoom1Enemies];
                numEnemyLeftRoom1 = GameConstants.numRoom1Enemies;
                room2Enemies = new Enemy[GameConstants.numRoom2Enemies];
                numEnemyLeftRoom2 = GameConstants.numRoom2Enemies;
                room3Enemies = new Enemy[GameConstants.numRoom3Enemies];
                numEnemyLeftRoom3 = GameConstants.numRoom3Enemies;
                //Assign the boss attack to the model. Not actually created until BossAttack.cs
                bossAttack = Content.Load<Model>("Models\\BossAttack");
                GameConstants.heroAttackTexure = Content.Load<Texture2D>("Textures\\HeroAttack");

            //
            //  LOAD CAMERAS
            //
                //Load our top down static camera
                mainCam = new Camera(false, heroCharacter);
                personCam = new Camera(true, heroCharacter); //Third Person Camera
                switchCam = mainCam; //Used as a holder to switch cameras

                //Load the default room (Room1)
                LoadRoom1();

            //
            //  LOAD OTHER ASSETS
            //
                //Floor and Wall Models
                floorModel = Content.Load<Model>("Models\\Cuboid");
                wallModelLeft = Content.Load<Model>("Models\\Cuboid");
                wallModelRight = Content.Load<Model>("Models\\Cuboid");
                wallModelVeryBack = Content.Load<Model>("Models\\Cuboid");
                wallModelBackLeft = Content.Load<Model>("Models\\Cuboid");
                wallModelBackRight = Content.Load<Model>("Models\\Cuboid");
                exitDoorModel = Content.Load<Model>("Models\\ExitDoor");
                //Images for these models
                floorTex = Content.Load<Texture2D>("Textures\\GroundTexture");
                wallTex = Content.Load<Texture2D>("Textures\\CaveWall");
                exitDoorTex = Content.Load<Texture2D>("Textures\\DoorTexture");

                //Load initial (closed) positions for the exit doors
                exitDoorPos = new Vector3(0, 121f, -10);
                exitDoor2Pos = new Vector3(0, 301f, -10);

                //Load the font for displaying text
                gameFont = Content.Load<SpriteFont>("Other\\GameFont");
                //Load health bar images
                healthBarOutline = Content.Load<Texture2D>("Textures\\HealthBarOutline");
                healthBar = Content.Load<Texture2D>("Textures\\HealthBar");

            //
            //  LOAD GAME MUSIC
            //
                //Background Music
                //Song taken from Game Boy game: Zelda: Link's Awakening
                //Turtle Rock Music : http://www.zeldauniverse.net/music/zelda-soundtracks/links-awakening-ost/
                bgMusic = Content.Load<Song>("Sounds\\ZLA_TurtleRock");
                MediaPlayer.Volume = 0.1f; //Lower the volume
                MediaPlayer.IsRepeating = true; //Have the song on repeat
                MediaPlayer.Play(bgMusic);

                //Load the sound effects
                //Sound Effects taken from Metroid games
                //http://metroidr.brpxqzme.net/index.php?act=resdb&param=01&c=5
                heroAttackSound = Content.Load<SoundEffect>("Sounds\\HeroAttackWav");
                bossAttackSound = Content.Load<SoundEffect>("Sounds\\BossAttackWav");
                SoundEffect.MasterVolume = 0.1f; //Lower the volume

            //
            //  GAME START FEATURES
            //
                //Start the game at the start screen
                gameState = 1;
                //Load various screens
                titleScreen = Content.Load<Texture2D>("Textures\\Screens\\Gp3_TitleScreen");
                winScreen = Content.Load<Texture2D>("Textures\\Screens\\Gp3_WinScreen");
                deathScreen = Content.Load<Texture2D>("Textures\\Screens\\Gp3_DeathScreen");

                //Default Game Score
                gameScore = 0;
        }