Example #1
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);
        }
Example #2
0
        /// <summary>
        /// Inicialización
        /// </summary>
        protected override void Initialize()
        {
            // Actualizar la proyección
            GlobalMatrices.UpdateProjection(this.GraphicsDevice);

            // Cámara
            CameraGameComponent camera = new CameraGameComponent(this);

            camera.Position            = new Vector3(50.0f, 80.0f, 50.0f);
            camera.KeyBoardSensibility = 50;
            this.Components.Add(camera);

            // Suelo
            float    size = _TerrainSize * 0.5f;
            Vector3  NO   = new Vector3(-size, 40, size);
            Vector3  NE   = new Vector3(size, 20, size);
            Vector3  SO   = new Vector3(-size, 20, -size);
            Vector3  SE   = new Vector3(size, 30, -size);
            Triangle tr1  = new Triangle(NO, SO, NE);
            Triangle tr2  = new Triangle(NE, SO, SE);

            this.Physics.RegisterTerrain(new CollisionTriangleSoup(new Triangle[] { tr1, tr2 }, float.PositiveInfinity));
            FloorGameComponent floor = new FloorGameComponent(this, new Vector3[] { NO, NE, SO, SE }, @"floor");

            floor.Position = new Vector3(0f, 0f, 0f);
            this.Components.Add(floor);

            // Inicializa las balas
            List <AmmoRound> roundList = new List <AmmoRound>();

            for (int i = 0; i < _AmmoRounds; i++)
            {
                AmmoRound round = new AmmoRound(ShotType.UnUsed, 0f, 0f);
                this.Physics.RegisterAmmoData(round);
                roundList.Add(round);
            }

            AmmoDrawer ammoDrawer = new AmmoDrawer(this);

            ammoDrawer.Rounds = roundList.ToArray();
            this.Components.Add(ammoDrawer);

            // Inicializa las cajas
            Random rnd = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < _Boxes; i++)
            {
                // Inicializa los componentes gráficos de las cajas
                float   hsX = 0.5f + ((float)rnd.NextDouble() * 1.5f);
                float   hsY = 0.5f + ((float)rnd.NextDouble() * 1.5f);
                float   hsZ = 0.5f + ((float)rnd.NextDouble() * 1.5f);
                Vector3 min = new Vector3(-hsX, -hsY, -hsZ);
                Vector3 max = new Vector3(hsX, hsY, hsZ);

                CubeGameComponent cube = new CubeGameComponent(this, min, max);
                cube.Register(this.Physics);
                this.m_Cubes.Add(cube);
                this.Components.Add(cube);
            }

            // El tanque del jugador 1
            m_Tank_1 = new Tank(this);
            this.Components.Add(m_Tank_1);

            // El tanque del jugador 2
            m_Tank_2 = new Tank(this);
            this.Components.Add(m_Tank_2);

            base.Initialize();

            m_Tank_1.Register(this.Physics);
            m_Tank_2.Register(this.Physics);

            this.Reset();
        }
Example #3
0
        /// <summary>
        /// Inicialización
        /// </summary>
        protected override void Initialize()
        {
            // Inicializar el control de entrada de usuario
            InputHelper.Initialize(this.GraphicsDevice);

            // Actualizar la proyección
            GlobalMatrices.UpdateProjection(this.GraphicsDevice);
#if DEBUG
            // Debug
            GameComponents.Debug.DebugDrawer.Initialize(this.GraphicsDevice);
#endif

            // Suelo
            this.m_Scenery             = new DemoScenery(this, _TerrainSize, GlobalTraslation, @"Content/dharma");
            this.m_Scenery.UpdateOrder = 0;
            this.Components.Add(this.m_Scenery);
            this.Physics.RegisterScenery(this.m_Scenery);

            // Reflejo solar
            this.m_LensFlare           = new LensFlareComponent(this);
            this.m_LensFlare.DrawOrder = 98;
            this.Components.Add(this.m_LensFlare);

            // Texto
            this.m_Text           = new TextDrawerComponent(this);
            this.m_Text.DrawOrder = 99;
            this.Components.Add(this.m_Text);

            // Cámara
            this.m_Camera             = new CameraGameComponent(this);
            this.m_Camera.UseMouse    = true;
            this.m_Camera.Forward     = Keys.Up;
            this.m_Camera.Backward    = Keys.Down;
            this.m_Camera.Left        = Keys.Left;
            this.m_Camera.Right       = Keys.Right;
            this.m_Camera.Up          = Keys.Add;
            this.m_Camera.Down        = Keys.Subtract;
            this.m_Camera.Mode        = CameraGameComponent.CameraModes.Free;
            this.m_Camera.UpdateOrder = 99;
            this.Components.Add(this.m_Camera);

            // Un edificio
            this.m_Building_1             = new BuildingType0(this, @"Content/Buildings/", @"WHBuilding01.xml");
            this.m_Building_1.UpdateOrder = 3;
            this.Components.Add(this.m_Building_1);
            this.Physics.RegisterObject(this.m_Building_1);

            // Otro edificio
            this.m_Building_2             = new BuildingType0(this, @"Content/Buildings/", @"WHBuilding02.xml");
            this.m_Building_2.UpdateOrder = 3;
            this.Components.Add(this.m_Building_2);
            this.Physics.RegisterObject(this.m_Building_2);

            // Otro edificio
            this.m_Building_3             = new BuildingType0(this, @"Content/Buildings/", @"WHBuilding03.xml");
            this.m_Building_3.UpdateOrder = 3;
            this.Components.Add(this.m_Building_3);
            this.Physics.RegisterObject(this.m_Building_3);

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

            Random rnd = new Random(DateTime.Now.Millisecond);

            // Inicializa las cajas
            for (int i = 0; i < _Boxes; i++)
            {
                // Inicializa los componentes gráficos de las cajas
                float   hsX = 0.5f + ((float)rnd.NextDouble() * 1.5f);
                float   hsY = 0.5f + ((float)rnd.NextDouble() * 1.5f);
                float   hsZ = 0.5f + ((float)rnd.NextDouble() * 1.5f);
                Vector3 min = new Vector3(-hsX, -hsY, -hsZ);
                Vector3 max = new Vector3(hsX, hsY, hsZ);

                CubeGameComponent cube = new CubeGameComponent(this, min, max, (max - min).Length() * 20f);
                this.Physics.RegisterObject(cube);
                this.m_Cubes.Add(cube);
                cube.UpdateOrder = 4;
                this.Components.Add(cube);
            }

            // Inicializa las esferas
            for (int i = 0; i < _Balls; i++)
            {
                // Inicializa los componentes gráficos de las esferas
                float radius = 0.5f + ((float)rnd.NextDouble() * 1.5f);

                BallGameComponent ball = new BallGameComponent(this, radius, radius);
                this.Physics.RegisterObject(ball);
                this.m_Balls.Add(ball);
                ball.UpdateOrder = 4;
                this.Components.Add(ball);
            }

            // Land Raider
            this.m_LandRaider             = new LandRaider(this, "Content/Vehicles");
            this.m_LandRaider.UpdateOrder = 5;
            this.Components.Add(this.m_LandRaider);
            this.Physics.RegisterObject(m_LandRaider);

            // Leman Russ
            this.m_LemanRuss             = new LemanRuss(this, "Content/Vehicles");
            this.m_LemanRuss.UpdateOrder = 5;
            this.Components.Add(this.m_LemanRuss);
            this.Physics.RegisterObject(m_LemanRuss);

            // Land speeder 1
            this.m_LandSpeeder_1             = new LandSpeeder(this, "Content/Vehicles");
            this.m_LandSpeeder_1.UpdateOrder = 5;
            this.Components.Add(this.m_LandSpeeder_1);
            this.Physics.RegisterObject(m_LandSpeeder_1);

            // Land speeder 2
            this.m_LandSpeeder_2             = new LandSpeeder(this, "Content/Vehicles");
            this.m_LandSpeeder_2.UpdateOrder = 5;
            this.Components.Add(this.m_LandSpeeder_2);
            this.Physics.RegisterObject(m_LandSpeeder_2);

            // El tanque del jugador 1
            this.m_Rhino_1             = new Rhino(this, "Content/Vehicles");
            this.m_Rhino_1.UpdateOrder = 5;
            this.Components.Add(this.m_Rhino_1);
            this.Physics.RegisterObject(m_Rhino_1);

            // El tanque del jugador 2
            this.m_Rhino_2             = new Rhino(this, "Content/Vehicles");
            this.m_Rhino_2.UpdateOrder = 5;
            this.Components.Add(this.m_Rhino_2);
            this.Physics.RegisterObject(m_Rhino_2);

            // Prueba
            //this.ball1 = new BallGameComponent(this, 1f, 1f);
            //this.Components.Add(ball1);
            //this.Physics.RegisterVehicle(ball1);

            //this.ball2 = new BallGameComponent(this, 1.5f, 2f);
            //this.Components.Add(ball2);
            //this.Physics.RegisterVehicle(ball2);

            //this.ball3 = new BallGameComponent(this, 2f, 4f);
            //this.Components.Add(ball3);
            //this.Physics.RegisterVehicle(ball3);

            //RodComponent rod1 = new RodComponent(this, this.ball1, Vector3.Up * this.ball1.Radius, null, new Vector3(0, 40, 0), 10f);
            //this.Components.Add(rod1);
            //this.Physics.RegisterContactGenerator(rod1.Rod);

            //RodComponent rod2 = new RodComponent(this, this.ball2, Vector3.Up * this.ball2.Radius, null, new Vector3(0, 40, 0), 10f);
            //this.Components.Add(rod2);
            //this.Physics.RegisterContactGenerator(rod2.Rod);

            //JointComponent joint1 = new JointComponent(this, this.ball1, Vector3.Down * this.ball1.Radius, this.ball3, Vector3.Left * this.ball3.Radius, 5f);
            //this.Components.Add(joint1);
            //this.Physics.RegisterContactGenerator(joint1.Joint);

            //JointComponent joint2 = new JointComponent(this, this.ball2, Vector3.Down * this.ball2.Sphere.Radius, this.ball3, Vector3.Right * this.ball3.Sphere.Radius, 5f);
            //this.Components.Add(joint2);
            //this.Physics.RegisterContactGenerator(joint2.Joint);

            //Joint2Component rod24 = new Joint2Component(this, this.ball1, Vector3.Up * this.ball1.Radius, null, new Vector3(0, 40, 0), 10f);
            //this.Components.Add(rod24);
            //this.Physics.RegisterContactGenerator(rod24.Rod);

            // Establecer el foco en el vehículo
            this.SetFocus(this.m_Rhino_1);

            base.Initialize();

            this.Reset();
        }