Example #1
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            world.Load(content);

            // Setup terrain.
            terrain = new Terrain(GraphicsDevice, content);
            terrain.Create(128, 20, 0.0f, 2048.0f, Terrain.HeightMapGenerationMethod.FromBitMap, AIParams.CONFIG_TERREIN_HEIGHT_PARAMETER);

            //terrain.AddRegion(-1000.0f, 2048.0f, @"Textures\region_grass_thin");

            terrain.AddRegion(-120.0f, -10.0f, @"Textures\region_soil_dry2");
            terrain.AddRegion(-10.0f, 500.0f, @"Textures\region_grass_thin");
            terrain.AddRegion(400.0f, 800.0f, @"Textures\region_rock1");
            //terrain.AddRegion(700.0f, 2048.0f, @"Textures\region_rock2");

            //terrain.AddRegion(-120.0f, 70.0f, @"Textures\region_soil_dry2");
            //terrain.AddRegion(20.0f, 700.0f, @"Textures\region_grass_thin");
            //terrain.AddRegion(700.0f, 1000.0f, @"Textures\region_rock1");
            //terrain.AddRegion(1001.0f, 2048.0f, @"Textures\region_rock2");

            terrain.SunlightDirection = Vector3.Down;
            terrain.SunlightColor     = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            terrain.TerrainAmbient    = new Vector4(0.3f, 0.3f, 0.3f, 1.0f);
            terrain.TerrainDiffuse    = new Vector4(0.7f, 0.7f, 0.7f, 1.0f);

            // Setup camera.
            camera.CurrentBehavior = Camera.Behavior.FreeView;
            camera.Velocity        = new Vector3(Settings.CAMERA_VELOCITY);
            camera.Acceleration    = new Vector3(Settings.CAMERA_ACCELERATION);
            camera.Perspective(80, (float)_windowWidth / (float)_windowHeight, 0.1f, terrain.TerrainBoundingSphere.Radius * 4.0f);
            Vector3 cameraPos = new Vector3();

            cameraPos.X = terrain.TerrainCenter.X;
            cameraPos.Z = terrain.TerrainCenter.Z;
            cameraPos.Y = terrain.TerrainHeightMap.HeightAt(cameraPos.X, cameraPos.Z) * 1.5f + 2000;
            camera.LookAt(cameraPos, new Vector3(terrain.TerrainCenter.X + 1, terrain.TerrainHeightMap.HeightAt(cameraPos.X, cameraPos.Z), terrain.TerrainCenter.Z + 1), Vector3.Up);

            worldMatrix = Matrix.CreateWorld(cameraPos, Vector3.Forward, Vector3.Up);

            // good for the tests
            int ntroops   = AIParams.CONFIG_NUMBER_AIOBJECTS_IN_TEAM;
            int nsnipers  = (int)Math.Ceiling((double)ntroops / 9.0);
            int nsupports = (int)Math.Ceiling((double)ntroops / 7.0);

            ntroops = ntroops - nsnipers - nsupports - 1;
            _aicontainer.CreateTeam(AITeamType.Alpha, Color.Red, ntroops, nsnipers, nsupports, terrain.TerrainCenter, true);
            _aicontainer.CreateTeam(AITeamType.Bravo, Color.Blue, ntroops, nsnipers, nsupports, new Vector3(200), true);
            _aicontainer.CreateTeam(AITeamType.Charlie, Color.White, ntroops, nsnipers, nsupports, new Vector3(terrain.TerrainSize - 200), true);

            //aicontainer.CreateTeam(AITeamType.Alpha, Color.Red, 0, 0, 0, terrain.TerrainCenter, false);
            //aicontainer.CreateTeam(AITeamType.Bravo, Color.Blue, 0, 0, 0, new Vector3(200), false);
            //aicontainer.CreateTeam(AITeamType.Charlie, Color.White, 0, 0, 0, new Vector3(terrain.TerrainSize - 200), false);

            _aicontainer.AddMulitpleAIStatics(
                AIParams.CONFIG_NUMBER_COVERS,
                AIParams.CONFIG_NUMBER_MEDS,
                AIParams.CONFIG_NUMBER_BONUSES
                );

            // have to be done after building the teams and adding objects to the world
            _aicontainer.InitializeAI();
            // Load ai objects
            _aicontainer.LoadContent(content);
            _aicontainer.SpreadObjects();

            //aicontainer.SelectTeam(AITeamType.Alpha);
            //aicontainer.SelectedTeam.ToFormation(AIFormation.Row);
            //aicontainer.SelectedTeam.KeepFormation = false;

            //aicontainer.SelectTeam(AITeamType.Bravo);
            //aicontainer.SelectedTeam.ToFormation(AIFormation.Arrow);
            //aicontainer.SelectedTeam.KeepFormation = false;

            //aicontainer.SelectTeam(AITeamType.Charlie);
            //aicontainer.SelectedTeam.ToFormation(AIFormation.Spread);
            //aicontainer.SelectedTeam.KeepFormation = false;

            AIGame.Console.Show();
        }