Beispiel #1
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            TOTAL_RABID_DOGS = 40;
            aspectRatio = (float)ScreenManager.Game.GraphicsDevice.Viewport.Width / (float)ScreenManager.Game.GraphicsDevice.Viewport.Height;

            // Initialize flicker for when health bar on danger.
            flicker = true;

            // Get current screen width and height.
            screenWidth = ScreenManager.Game.GraphicsDevice.Viewport.Width;
            screenHeight = ScreenManager.Game.GraphicsDevice.Viewport.Height;

            // Setup frame buffer.
            GameStateManagementGame.graphics.SynchronizeWithVerticalRetrace = false;
            GameStateManagementGame.graphics.PreferredBackBufferWidth = screenWidth;
            GameStateManagementGame.graphics.PreferredBackBufferHeight = screenHeight;
            GameStateManagementGame.graphics.PreferMultiSampling = true;
            GameStateManagementGame.graphics.ApplyChanges();

            cry = content.Load<SoundEffect>("Audio\\Waves\\araguzbattlecry");
            cryInstance = cry.CreateInstance();

            win = content.Load<SoundEffect>("Audio\\Waves\\winningyell");
            winInstance = win.CreateInstance();

            bark = content.Load<SoundEffect>("Audio\\Waves\\barkingdog");
            barkInstance = bark.CreateInstance();

            donotfear = content.Load<SoundEffect>("Audio\\Waves\\donotfear");
            donotfearInstance = donotfear.CreateInstance();

            motherearth = content.Load<SoundEffect>("Audio\\Waves\\motherearth");
            motherearthInstance = motherearth.CreateInstance();

            callmegerry = content.Load<SoundEffect>("Audio\\Waves\\callmegerry");
            callmegerryInstance = callmegerry.CreateInstance();

            jacksonwincry = content.Load<SoundEffect>("Audio\\Waves\\jacksonwincry");
            jacksonwincryInstance = jacksonwincry.CreateInstance();

            jacksonlosecry = content.Load<SoundEffect>("Audio\\Waves\\jacksonlosecry");
            jacksonlosecryInstance = jacksonlosecry.CreateInstance();

            taunt = content.Load<SoundEffect>("Audio\\Waves\\jacksontaunt");
            tauntInstance = taunt.CreateInstance();

            becareful = content.Load<SoundEffect>("Audio\\Waves\\becareful");
            becarefulInstance = becareful.CreateInstance();

            dogsinpark = content.Load<SoundEffect>("Audio\\Waves\\dogsinpark");
            dogsinparkInstance = dogsinpark.CreateInstance();

            onfire = content.Load<SoundEffect>("Audio\\Waves\\onfire");
            onfireInstance = onfire.CreateInstance();

            totherescue = content.Load<SoundEffect>("Audio\\Waves\\totherescue");
            totherescueInstance = totherescue.CreateInstance();

            telepath = content.Load<SoundEffect>("Audio\\Waves\\telepath");
            telepathInstance = telepath.CreateInstance();

            collectsample = content.Load<SoundEffect>("Audio\\Waves\\collectsample");
            collectsampleInstance = collectsample.CreateInstance();

            virussamples = content.Load<SoundEffect>("Audio\\Waves\\virussamples");
            virussamplesInstance = virussamples.CreateInstance();

            plasmaray = content.Load<SoundEffect>("Audio\\Waves\\plasmaray");
            plasmarayInstance = plasmaray.CreateInstance();
            plasmarayInstance.IsLooped = true;

            gameMusic = content.Load<SoundEffect>("Audio\\Waves\\gamemusic");
            gameMusicInstance = gameMusic.CreateInstance();
            gameMusicInstance.IsLooped = true;
            //gameMusicInstance.Play();

            numberOfCollectedSamples = 0;

            initialNumberOfDogs = TOTAL_RABID_DOGS;

            // Position the in-game text.
            fontPos = new Vector2(1.0f, 1.0f);

            // Setup the initial input states.
            curMouseState = Mouse.GetState();
            curKeyboardState = Keyboard.GetState();

            // Load the game font.
            gameFont = content.Load<SpriteFont>("Fonts\\gamefont");

            // Initialize the sprite batch for the in-game font.
            spriteBatch = new SpriteBatch(ScreenManager.GraphicsDevice);

            // Load the in-game font.
            spriteFont = content.Load<SpriteFont>("Fonts\\ingamefont");

            // Initialize the sprite batch for the health bar.
            mBatch = new SpriteBatch(ScreenManager.GraphicsDevice);

            // Load the health bar image.
            mHealthBar = content.Load<Texture2D>("healthbar");

            // Load the bullet image and setup bullet effects.
            quadEffect = content.Load<Effect>("Effects\\effects");
            quad = new Quad(ScreenManager.GraphicsDevice, Vector3.Zero, Vector3.Up, screenWidth / 2, screenHeight / 2);
            bullets = content.Load<Texture2D>("Textures\\bulletfire");

            // Load the effects and setup vertices for triangle indicator.
            vertices = new List<VertexPositionColor[]>();
            effect = content.Load<Effect>("Effects\\effects");
            indicatorPos = new Vector3(5, 45, 0);
            SetUpVertices(indicatorPos, indicatorScale);

            // Intialize lists for enemies.
            rabidDogHealths = new List<int>();
            rabidDogRadii = new List<float>();
            rabidDogModels = new List<MyModel>();
            rabidDogEntities = new List<Entity>();
            rabidDogHealthDecrs = new List<float>();
            rabidDogBounds = new List<BoundingSphere>();
            bottleModels = new List<MyModel>();
            bottleEntities = new List<Entity>();
            bottleBounds = new List<BoundingSphere>();
            bottleRadii = new List<float>();
            modelEnemyTransforms = new List<Matrix[]>();
            bulletList = new List<Bullet>();
            dogs = new List<AnimationPlayer>();
            dogClips = new List<AnimationClip>();
            rabidDogPreviousPositions = new List<Vector3>();
            for (int i = 0; i < TOTAL_RABID_DOGS; i++)
            {
                rabidDogHealths.Add(100);
                rabidDogHealthDecrs.Add(0.0f);
                modelEnemyTransforms.Add(null);
                rabidDogPreviousPositions.Add(new Vector3());
            }

            healed = new bool[initialNumberOfDogs];
            collected = new bool[initialNumberOfDogs];
            for (int index = 0; index < initialNumberOfDogs; index++)
            {
                healed[index] = false;
                collected[index] = false;
            }

            // Load models and set aspect ratio.
            //playerModel = new MyModel("Models\\ball", content);
            //playerModel.Texture("Textures\\wedge_p1_diff_v1", content);
            LoadAraguz();
            for (int i = 0; i < TOTAL_RABID_DOGS; i++)
            {
                LoadDog();
                //rabidDogModels.Add(new MyModel("Models\\troubled_canine", content));
                //rabidDogModels[i].Texture("Textures\\DogEyes", content);
                //rabidDogModels[i].Texture("Textures\\DogPupil", content);
                //rabidDogModels[i].Texture("Textures\\DogSkin", content);
                bottleModels.Add(new MyModel("Models\\sample_bottle", content));
                bottleModels[i].Texture("Textures\\Chemical1", content);
                bottleModels[i].Texture("Textures\\Chemical2", content);
                bottleModels[i].Texture("Textures\\RedLiquid", content);
                bottleModels[i].Texture("Textures\\TopOfFlask", content);
                bottleModels[i].Texture("Textures\\gray", content);
                //rabidDogModels.Add(new MyModel("Models\\ball", content));
                //rabidDogModels[i].Texture("Textures\\wedge_p1_diff_v1", content);
            }

            sound = content.Load<SoundEffect>("Audio\\Waves\\wind");
            soundInstance = sound.CreateInstance();
            soundInstance.IsLooped.Equals(true);
            soundInstance.Play();

            // Load terrain and sky.
            grassy_level = content.Load<Model>("terrain");
            //content.Load<Texture2D>("Textures\\parkgrass");
            sky = content.Load<Sky>("sky");

            levelModel = new MyModel("Models\\zanzibardesert", content);
            levelModel.Texture("Textures\\desertmud", content);

            // Determine the radius of the player model.
            BoundingSphere bounds = new BoundingSphere();
            foreach (ModelMesh mesh in playerModel.ModelHeld.Meshes)
                bounds = BoundingSphere.CreateMerged(bounds, mesh.BoundingSphere);
            playerRadius = bounds.Radius;

            playerBounds = bounds;

            BoundingSphere lbounds = new BoundingSphere();
            foreach (ModelMesh mesh in levelModel.ModelHeld.Meshes)
                lbounds = BoundingSphere.CreateMerged(lbounds, mesh.BoundingSphere);
            levelRadius = lbounds.Radius;

            levelBounds = lbounds;

            // Determine the radii of the enemy models.
            for (int i = 0; i < TOTAL_RABID_DOGS; i++)
            {
                BoundingSphere rbounds = new BoundingSphere();
                foreach (ModelMesh mesh in rabidDogModels[i].ModelHeld.Meshes)
                    rbounds = BoundingSphere.CreateMerged(rbounds, mesh.BoundingSphere);
                rabidDogRadii.Add(rbounds.Radius);

                rabidDogBounds.Add(rbounds);

                BoundingSphere bottlebounds = new BoundingSphere();
                foreach (ModelMesh mesh in bottleModels[i].ModelHeld.Meshes)
                    bottlebounds = BoundingSphere.CreateMerged(bottlebounds, mesh.BoundingSphere);
                bottleRadii.Add(bottlebounds.Radius);

                bottleBounds.Add(bottlebounds);
            }

            // Determine the radius of the height map.
            BoundingSphere tbounds = new BoundingSphere();
            foreach (ModelMesh mesh in grassy_level.Meshes)
                tbounds = BoundingSphere.CreateMerged(tbounds, mesh.BoundingSphere);
            terrainRadius = tbounds.Radius;

            terrainBounds = tbounds;

            // Setup the camera.
            camera = new ThirdPersonCamera();
            camera.Perspective(CAMERA_FOVX, (float)screenWidth / (float)screenHeight,
                CAMERA_ZNEAR, CAMERA_ZFAR);
            camera.LookAt(new Vector3(0.0f, playerRadius * 3.0f, playerRadius * 7.0f),
                Vector3.Zero, Vector3.Up);

            // Setup the player entity.
            playerEntity = new Entity();
            playerEntity.ConstrainToWorldYAxis = true;
            playerEntity.Position = new Vector3(0.0f, 1.0f + playerRadius, 0.0f);

            levelEntity = new Entity();
            levelEntity.ConstrainToWorldYAxis = true;
            levelEntity.Position = new Vector3(0.0f, 1.0f + levelRadius, 0.0f);

            // Setup the enemy and bottle entities.
            for (int i = 0; i < TOTAL_RABID_DOGS; i++)
            {
                rabidDogEntities.Add(new Entity());
                rabidDogEntities[i].ConstrainToWorldYAxis = true;
                rabidDogEntities[i].Position = new Vector3((random.Next(1000) * 1.0f + 200.0f) + playerEntity.Position.X, 20.0f + rabidDogRadii[i], random.Next(1000));

                bottleEntities.Add(new Entity());
                bottleEntities[i].ConstrainToWorldYAxis = true;
                bottleEntities[i].Position = rabidDogEntities[i].Position;
            }

            // Setup the terrain entity.
            terrainEntity = new Entity();
            terrainEntity.ConstrainToWorldYAxis = true;
            terrainEntity.Position = new Vector3(0.0f, 1.0f + terrainRadius, 0.0f);

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            Thread.Sleep(3000);

            // Once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
Beispiel #2
0
        protected void LoadAraguz()
        {
            playerModel = new MyModel("Models\\geraldo_araguz", content);

            // Look up our custom skinning information.
            SkinningData skinningData = playerModel.ModelHeld.Tag as SkinningData;

            if (skinningData == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips["Take 001"];

            animationPlayer.StartClip(clip);
        }