コード例 #1
0
        protected override void LoadContent()
        {
            this.camera.GetMatrices(out this.world, out this.view, out this.projection);
            this.grassTexture = this.Game.Content.Load <Texture2D>("Textures/grass");
            this.msgBoxIcon   = this.Game.Content.Load <Texture2D>("Textures/MessageBox/warning");

            Int16[] indices = new Int16[MAP_WIDTH * MAP_HEIGHT * 6];
            this.GenerateVertices(MAP_WIDTH, MAP_HEIGHT, STEP, ref indices);
            this.vertexBuffer = new VertexBuffer(this.Game.GraphicsDevice, typeof(VertexPositionNormalTexture), this.vertices.Count(), BufferUsage.WriteOnly);
            this.vertexBuffer.SetData(this.vertices);
            this.indexBuffer = new IndexBuffer(this.Game.GraphicsDevice, typeof(Int16), indices.Count(), BufferUsage.WriteOnly);
            this.indexBuffer.SetData(indices);

            this.terrainWorld = Matrix.CreateTranslation(new Vector3(-MAP_WIDTH * STEP / 2.0f, 0, MAP_HEIGHT * STEP / 2.0f)) * Matrix.CreateRotationY(MathHelper.ToRadians(60.0f));

            this.basicEffect = new BasicEffect(this.Game.GraphicsDevice);
            this.pickingService.SetTerrainWorldMatrix(ref this.terrainWorld);
            this.buildingsParent.SetTerrainWorld(ref this.terrainWorld);
            this.resourcesParent.SetTerrainWorld(ref this.terrainWorld);
            this.humansParent.SetTerrainWorld(ref this.terrainWorld);
            this.humansParent.SetBuildingsResourcesParent(ref this.buildingsParent, ref this.resourcesParent);

            this.lineEffect = new BasicEffect(this.Game.GraphicsDevice);
            this.lineEffect.VertexColorEnabled = true;

            this.buildingsParent.InitializeWalls();
            this.resourcesParent.AddResources();
            this.humansParent.InitializeCommanders();

            base.LoadContent();
        }