public override void Initialize()
        {
            base.Initialize();

            m_Scenery = (SceneryGameComponent)this.Game.Services.GetService(typeof(SceneryGameComponent));

            declaration = new VertexDeclaration(this.GraphicsDevice, VertexPositionColor.VertexElements);

            VertexPositionColor v1 = new VertexPositionColor();

            v1.Position = Vector3.Up;
            v1.Color    = Color.Red;

            VertexPositionColor v2 = new VertexPositionColor();

            v2.Position = Vector3.Zero;
            v2.Color    = Color.Red;

            VertexPositionColor v3 = new VertexPositionColor();

            v3.Position = Vector3.Right;
            v3.Color    = Color.Blue;

            VertexPositionColor v4 = new VertexPositionColor();

            v4.Position = Vector3.Zero;
            v4.Color    = Color.Blue;

            VertexPositionColor v5 = new VertexPositionColor();

            v5.Position = Vector3.Forward;
            v5.Color    = Color.Green;

            VertexPositionColor v6 = new VertexPositionColor();

            v6.Position = Vector3.Zero;
            v6.Color    = Color.Green;

            VertexPositionColor[] vertList = new VertexPositionColor[] { v1, v2, v3, v4, v5, v6 };

            //buffer = new VertexBuffer(
            //    this.GraphicsDevice,
            //    VertexPositionColor.SizeInBytes * vertList.Length,
            //    ResourceUsage.WriteOnly);
            buffer = new VertexBuffer(
                this.GraphicsDevice,
                VertexPositionColor.SizeInBytes * vertList.Length,
                BufferUsage.WriteOnly);
            buffer.SetData <VertexPositionColor>(vertList);

            effect = new BasicEffect(this.GraphicsDevice, null);
        }
Exemple #2
0
        /// <summary>
        /// Inicializar
        /// </summary>
        protected override void Initialize()
        {
#if DEBUG
            this.Graphics.PreferredBackBufferWidth  = 1024;
            this.Graphics.PreferredBackBufferHeight = 600;
            this.Graphics.PreferMultiSampling       = false;
            this.Graphics.IsFullScreen = false;
#else
            this.Graphics.PreferredBackBufferWidth  = this.GraphicsDevice.DisplayMode.Width;
            this.Graphics.PreferredBackBufferHeight = this.GraphicsDevice.DisplayMode.Height;
            this.Graphics.PreferredBackBufferFormat = this.GraphicsDevice.DisplayMode.Format;
            this.Graphics.PreferMultiSampling       = false;
            this.Graphics.IsFullScreen = true;
#endif

            this.Graphics.ApplyChanges();

            InputHelper.Initialize(this.GraphicsDevice);

#if DEBUG
            GameComponents.Debug.DebugDrawer.Initialize(this.GraphicsDevice);
#endif
            this.m_Scenery             = new SceneryGameComponent(this);
            this.m_Scenery.UpdateOrder = 0;
            this.m_Scenery.DrawOrder   = 0;
            this.Components.Add(this.m_Scenery);
            this.Services.AddService(typeof(SceneryGameComponent), this.m_Scenery);

            this.m_VehicleContainer             = new VehicleContainerService(this);
            this.m_VehicleContainer.UpdateOrder = 1;
            this.Services.AddService(typeof(VehicleContainerService), this.m_VehicleContainer);

            this.m_BuilngContainer             = new BuildingContainerService(this);
            this.m_BuilngContainer.UpdateOrder = 2;
            this.Services.AddService(typeof(BuildingContainerService), this.m_BuilngContainer);

            AmmoDrawer ammoDrawer = new AmmoDrawer(this, @"Content/Steel 1");
            ammoDrawer.Rounds      = this.Physics.Projectiles;
            ammoDrawer.UpdateOrder = 3;
            ammoDrawer.DrawOrder   = 3;
            this.Components.Add(ammoDrawer);

            Building[] buildings = AddBuildings(BuildingTypes.Type0, 10);

            Vehicle[] squad01 = AddSquadron(VehicleTypes.LandSpeeder, 3);
            //Vehicle[] squad02 = AddSquadron(VehicleTypes.LandSpeeder, 3);
            //Vehicle[] squad03 = AddSquadron(VehicleTypes.LandSpeeder, 3);
            //Vehicle[] squad04 = AddSquadron(VehicleTypes.LandSpeeder, 3);
            //Vehicle[] squad05 = AddSquadron(VehicleTypes.LandSpeeder, 3);
            //Vehicle[] squad06 = AddSquadron(VehicleTypes.LandSpeeder, 3);
            //Vehicle[] squad04 = AddSquadron(VehicleTypes.LandRaider, 2);
            Vehicle[] squad05 = AddSquadron(VehicleTypes.LemanRuss, 3);
            //Vehicle[] squad06 = AddSquadron(VehicleTypes.LemanRuss, 3);
            Vehicle[] squad07 = AddSquadron(VehicleTypes.Rhino, 3);
            //Vehicle[] squad08 = AddSquadron(VehicleTypes.Rhino, 3);
            //Vehicle[] squad09 = AddSquadron(VehicleTypes.Rhino, 3);

            this.m_LensFlare             = new LensFlareComponent(this);
            this.m_LensFlare.UpdateOrder = 96;
            this.m_LensFlare.DrawOrder   = 96;
            this.Components.Add(this.m_LensFlare);

            this.m_Camera             = new CameraGameComponent(this);
            this.m_Camera.UseMouse    = true;
            this.m_Camera.Mode        = CameraGameComponent.CameraModes.FirstPerson;
            this.m_Camera.UpdateOrder = 98;
            this.Components.Add(this.m_Camera);

            this.m_Info             = new SceneryInfoGameComponent(this);
            this.m_Info.UpdateOrder = 99;
            this.m_Info.DrawOrder   = 99;
            this.Components.Add(this.m_Info);

            this.m_TextDrawer             = new TextDrawerComponent(this);
            this.m_TextDrawer.UpdateOrder = 100;
            this.m_TextDrawer.DrawOrder   = 100;
            this.Components.Add(this.m_TextDrawer);

            this.m_ParticleManager = new ParticleManager(this);
            this.Components.Add(this.m_ParticleManager);

            base.Initialize();

            IntersectionTests.m_DEBUGUSE = true;

            this.Physics.RegisterScenery(this.m_Scenery.Scenery);

            this.InitializeBuildings(buildings);

            this.InitializeSquadron(squad01);
            //this.InitializeSquadron(squad02);
            //this.InitializeSquadron(squad03);
            //this.InitializeSquadron(squad04);
            this.InitializeSquadron(squad05);
            //this.InitializeSquadron(squad06);
            this.InitializeSquadron(squad07);
            //this.InitializeSquadron(squad08);
            //this.InitializeSquadron(squad09);

            this.SetFocus(squad01[0]);

            //squad01[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 60f);
            //squad02[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 60f);
            //squad03[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 60f);
            //squad04[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 60f);
            //squad05[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 60f);
            //squad06[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 60f);
            //squad07[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 40f);
            //squad08[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 40f);
            //squad09[0].AutoPilot.GoTo(new Vector3(RandomComponent.Next(10000), 0, RandomComponent.Next(10000)), 40f);
        }