示例#1
0
        // Draw Model
        public void DrawModel(Matrix world, Matrix view, Matrix projection, Camera cam)
        {
            foreach (ModelMesh mesh in charModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    //effect.TextureEnabled = false;

                    //Lighting
                    //effect.EnableDefaultLighting();
                    effect.LightingEnabled = true; // turn on the lighting subsystem.
                    //Ambient Light - All round light source
                    effect.AmbientLightColor = new Vector3(30, 30, 30);

                    //Fog
                    //effect.FogEnabled = true;
                    //effect.FogColor = Color.CornflowerBlue.ToVector3(); // For best results, ake this color whatever your background is.
                    //effect.FogStart = 9.75f;
                    //effect.FogEnd = 10.75f;

                    //Apply the world, view and projection matrices.
                    //Update world view depending on the characters values
                    //Translate to origin first then scale, then rotate then translate back
                    world = Matrix.CreateTranslation(Vector3.Zero) * Matrix.CreateScale(scale) * Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationZ(rotation.Z) * Matrix.CreateTranslation(position);

                    effect.World = world;
                    //effect.View = view;
                    //effect.Projection = projection;
                    effect.View = cam.viewMatrix;
                    effect.Projection = cam.projectionMatrix;
                }

                mesh.Draw();
            }
        }
示例#2
0
        // Draw the attack
        public void DrawModel(Matrix world, Matrix view, Matrix projection, Camera cam)
        {
            foreach (ModelMesh mesh in attackModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    //effect.TextureEnabled = false;
                    effect.TextureEnabled = true;
                    effect.Texture = GameConstants.heroAttackTexure;

                    //Lighting
                    //effect.EnableDefaultLighting();
                    //effect.LightingEnabled = true; // turn on the lighting subsystem.
                    //Ambient Light - All round light source
                    //effect.AmbientLightColor = new Vector3(30, 30, 30);

                    //Apply the world, view and projection matrices.
                    //Update world view depending on the characters values
                    //Translate to origin first then scale, then rotate then translate back
                    world = Matrix.CreateTranslation(Vector3.Zero) * Matrix.CreateScale(scale) * Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationZ(rotation.Z) * Matrix.CreateTranslation(position);

                    effect.World = world;
                    effect.View = cam.viewMatrix;
                    effect.Projection = cam.projectionMatrix;
                }

                mesh.Draw();
            }
        }
示例#3
0
 //Check if the camera has been switched from top down to third person and vice-versa
 private void CheckCameraChange()
 {
     //Change camera perspective
     if ((currentKeyState.IsKeyDown(Keys.Q) && oldKeyState.IsKeyUp(Keys.Q)) || (currentPadState.IsButtonDown(Buttons.Y) && oldPadState.IsButtonUp(Buttons.Y)))
     {
         //Do the switch
         switchCam = mainCam;
         mainCam = personCam;
         personCam = switchCam;
     }
 }
示例#4
0
        // Draw the attack
        public void DrawModel(Matrix world, Matrix view, Matrix projection, Camera cam)
        {
            foreach (ModelMesh mesh in attackModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    //Error with texture co-ordinates so texture enabled is false
                    effect.TextureEnabled = false;
                    effect.Texture = GameConstants.bossAttackTexure;

                    //Apply the world, view and projection matrices.
                    //Update world view depending on the characters values
                    //Translate to origin first then scale, then rotate then translate back
                    world = Matrix.CreateTranslation(Vector3.Zero) * Matrix.CreateScale(scale) * Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationZ(rotation.Z) * Matrix.CreateTranslation(position);

                    effect.World = world;
                    effect.View = cam.viewMatrix;
                    effect.Projection = cam.projectionMatrix;
                }

                mesh.Draw();
            }
        }
示例#5
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;
        }