Ejemplo n.º 1
0
        public override void OnInitialise()
        {
            GameSimRules rules = new GameSimRules();

            rules.FragWinLimit  = 20;
            rules.RespawnTime   = 5;
            rules.GameTimeLimit = 300;

            var gameSim = new GameSimulation(rules);

            SystemCore.AddNewUpdateRenderSubsystem(gameSim);
            SystemCore.CursorVisible = true;
            SystemCore.ActiveScene.SetUpAmbientAndFullLightingRig();

            cameraObject = new GameObject();
            cameraObject.AddComponent(new ComponentCamera(MathHelper.PiOver4, SystemCore.GraphicsDevice.Viewport.AspectRatio, 1f, 200f, false));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraObject);
            SystemCore.SetActiveCamera(cameraObject.GetComponent <ComponentCamera>());
            cameraObject.Transform.AbsoluteTransform = Matrix.CreateWorld(new Vector3(0, 200, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1));



            host = WebHostHelper.CreateWebHost(gameSim);


            base.OnInitialise();
        }
Ejemplo n.º 2
0
        public override void OnInitialise()
        {
            fpsLabel.Visible = true;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            SystemCore.ActiveScene.SetDiffuseLightDir(0, new Vector3(0.01f, 1, 0.01f));
            SystemCore.ActiveScene.FogEnabled = false;

            //mouse camera
            mouseCamera           = new MouseFreeCamera(new Vector3(0, 0, 0), 1f, 50000f);
            mouseCamera.moveSpeed = 1f;
            mouseCamera.SetPositionAndLook(new Vector3(0, 200, -200), (float)Math.PI, (float)-Math.PI / 5);
            SystemCore.SetActiveCamera(mouseCamera);



            AddInputBindings();



            SetUpGameWorld();



            base.OnInitialise();
        }
Ejemplo n.º 3
0
        public void Initalise()
        {
            currentVertices = new List <Vector3>();

            SystemCore.ActiveScene.SetUpAmbientAndFullLightingRig();

            SystemCore.ActiveScene.AddPointLight(new Vector3(0, 15, 0), Color.White, 20, 20, 1, PointLightNumber.One);
            SystemCore.ActiveScene.AddPointLight(new Vector3(0, -15, 0), Color.White, 20, 20, 1, PointLightNumber.Two);
            SystemCore.ActiveScene.AddPointLight(new Vector3(0, 0, 15), Color.White, 20, 20, 1, PointLightNumber.Three);
            SystemCore.ActiveScene.AddPointLight(new Vector3(0, 0, -15), Color.White, 20, 20, 1, PointLightNumber.Four);

            SystemCore.AddNewUpdateRenderSubsystem(new SkyDome(Color.LightGray, Color.Gray, Color.DarkBlue));

            shapeBuilder = new ProceduralShapeBuilder();
            CurrentMode  = EditMode.Voxel;
            shapesToBake = new Dictionary <GameObject.GameObject, ProceduralShape>();


            cameraGameObject = new GameObject.GameObject("camera");
            cameraGameObject.AddComponent(new ComponentCamera());
            cameraGameObject.Transform.SetPosition(new Vector3(0, 0, 20));
            cameraGameObject.Transform.SetLookAndUp(new Vector3(0, 0, -1), new Vector3(0, 1, 0));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraGameObject);
            SystemCore.SetActiveCamera(cameraGameObject.GetComponent <ComponentCamera>());


            mouseCursor = GameObjectFactory.CreateRenderableGameObjectFromShape(new ProceduralCube(),
                                                                                EffectLoader.LoadSM5Effect("flatshaded"));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(mouseCursor);



            AddGUI();
        }
Ejemplo n.º 4
0
        public override void Update(GameTime gameTime)
        {
            if (!SystemCore.CursorVisible)
            {
                EvaluateMouseCamControls(gameTime);
            }

            if (input.EvaluateInputBinding("SwitchCamera"))
            {
                if (SystemCore.ActiveCamera is ComponentCamera)
                {
                    SystemCore.SetActiveCamera(mouseCamera);
                }
                else
                {
                    SystemCore.SetActiveCamera(cameraObject.GetComponent <ComponentCamera>());
                }
            }

            if (input.EvaluateInputBinding("MainMenu"))
            {
                SystemCore.ScreenManager.AddAndSetActive(new MainMenuScreen());
            }

            EvaluateCamera();



            base.Update(gameTime);
        }
Ejemplo n.º 5
0
        public override void OnInitialise()
        {
            base.OnInitialise();

            SystemCore.Game.Window.Title = "Conway's Game of Life";

            mouseCamera = new MouseFreeCamera(new Vector3(0, 0, 0));
            SystemCore.SetActiveCamera(mouseCamera);
            mouseCamera.moveSpeed = 0.01f;
            mouseCamera.SetPositionAndLook(new Vector3(50, 30, -20), (float)Math.PI, (float)-Math.PI / 5);


            SystemCore.ActiveScene.SetUpAmbientAndFullLightingRig();
            SystemCore.ActiveScene.AmbientLight.LightIntensity = 0.075f;
            SystemCore.ActiveScene.GetBackLight().LightIntensity = 0f;
            SystemCore.ActiveScene.GetFillLight().LightIntensity = 0.1f;
            SystemCore.ActiveScene.FogEnabled = false;

            SystemCore.CursorVisible = true;
            //fpsLabel.Visible = true;


            skyDome = new GradientSkyDome(Color.LightGray, Color.DarkGray);

            simulationTickTimer         = new XNATimer(tickFrequency, x => RunSimulationTick(x));
            simulationTickTimer.Enabled = true;

            AddInputBindings();


            // var heightMapObject = CreateHeightMapGameObject();
            //SystemCore.GameObjectManager.AddAndInitialiseGameObject(heightMapObject);


            CreateGameOfLifeBoard();


            cameraGameObject = new GameObject("camera");
            cameraGameObject.AddComponent(new ComponentCamera());
            cameraGameObject.Transform.SetPosition(new Vector3(50, 15, 50));

            Vector3 lookAt = Vector3.Normalize(boardMidpoint - cameraGameObject.Position);

            cameraGameObject.Transform.SetLookAndUp(lookAt, Vector3.Up);
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraGameObject);
            SystemCore.SetActiveCamera(cameraGameObject.GetComponent <ComponentCamera>());

            //var sphere = GameObjectFactory.CreateRenderableGameObjectFromShape(new ProceduralSphere(10, 10), EffectLoader.LoadSM5Effect("flatshaded"));
            //sphere.Transform.SetPosition(boardMidpoint);
            //sphere.Transform.Scale = 5f;
            //SystemCore.GameObjectManager.AddAndInitialiseGameObject(sphere);

            AddGUI();
        }
Ejemplo n.º 6
0
 public SpaceShipCamera(SpaceShip ship)
 {
     this.ship   = ship;
     chaseCamera = new ChaseCamera();
     chaseCamera.DesiredPositionOffset = new Microsoft.Xna.Framework.Vector3(0.0f, 40f, 55f);
     chaseCamera.LookAtOffset          = new Microsoft.Xna.Framework.Vector3(0.0f, 0.0f, 0);
     chaseCamera.Stiffness             = 2000;
     chaseCamera.Damping = 600;
     chaseCamera.Mass    = 50f;
     chaseCamera.NearZ   = 0.5f;
     chaseCamera.FarZ    = 10000.0f;
     SystemCore.SetActiveCamera(chaseCamera);
 }
Ejemplo n.º 7
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;
            fpsLabel.Visible         = true;

            mouseCamera = new MouseFreeCamera(new Vector3(0, 0, 0));
            SystemCore.SetActiveCamera(mouseCamera);



            AddInputBindings();
            base.OnInitialise();
        }
Ejemplo n.º 8
0
        public RenderTestScreen()
            : base()
        {
            SystemCore.CursorVisible = false;
            fpsLabel.Visible         = true;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();

            var effect = EffectLoader.LoadSM5Effect("FlatShaded");


            mouseCamera = new MouseFreeCamera(new Vector3(0, 0, 0));
            SystemCore.SetActiveCamera(mouseCamera);

            var shape = new ProceduralSphere(20, 20);

            shape.SetColor(SystemCore.ActiveColorScheme.Color5);



            //create 100 cubes, add collision and collision visualiser components, give them random position and velocity
            for (int i = 0; i < 100; i++)
            {
                var gameObject = new GameObject();
                gameObject.AddComponent(new RenderGeometryComponent(BufferBuilder.VertexBufferBuild(shape), BufferBuilder.IndexBufferBuild(shape), shape.PrimitiveCount));

                gameObject.AddComponent(new EffectRenderComponent(effect));
                //gameObject.AddComponent(new BasicEffectRenderComponent(effect));
                gameObject.Transform.SetPosition(RandomHelper.GetRandomVector3(Vector3.One * -100, Vector3.One * 100));
                gameObject.AddComponent(new RotatorComponent(Vector3.Up));
                SystemCore.GetSubsystem <GameObjectManager>().AddAndInitialiseGameObject(gameObject);

                gameObject.Transform.Scale    = 5f;
                gameObject.Transform.Velocity = RandomHelper.GetRandomVector3(-Vector3.One, Vector3.One) * 0.01f;
            }


            AddInputBindings();

            Model           geoDesicModel = SystemCore.ContentManager.Load <Model>("Models/geodesic");
            ProceduralShape geodesicShape = ModelMeshParser.GetShapeFromModelNoUVs(geoDesicModel);

            geodesicShape.Scale(20f);
            geodesicShape.InsideOut();
            GameObject geoDesic = GameObjectFactory.CreateRenderableGameObjectFromShape(geodesicShape, EffectLoader.LoadSM5Effect("cockpitscreen"));

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(geoDesic);
        }
Ejemplo n.º 9
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            SystemCore.ActiveScene.SetDiffuseLightDir(0, new Vector3(1, 1, 1));
            colorScheme = SystemCore.ActiveColorScheme;
            SystemCore.ActiveScene.FogEnabled = false;

            SystemCore.PhysicsSimulation.ForceUpdater.Gravity = new BEPUutilities.Vector3(0, -9.81f, 0);


            mouseCamera = new MouseFreeCamera(new Vector3(10, 10, 10));
            SystemCore.SetActiveCamera(mouseCamera);


            var effect = EffectLoader.LoadSM5Effect("FlatShaded");

            //ground plane
            var groundShape = new ProceduralCuboid(100, 100, 0.5f);

            groundShape.SetColor(colorScheme.Color5);
            var gameObjectPlane = new GameObject();

            gameObjectPlane.AddComponent(new RenderGeometryComponent(BufferBuilder.VertexBufferBuild(groundShape), BufferBuilder.IndexBufferBuild(groundShape), groundShape.PrimitiveCount));
            gameObjectPlane.AddComponent(new EffectRenderComponent(effect));
            var groundPhysicsComponent = new PhysicsComponent(false, true, PhysicsMeshType.box);

            gameObjectPlane.AddComponent(groundPhysicsComponent);


            SystemCore.GameObjectManager.AddAndInitialiseGameObject(gameObjectPlane);
            groundPhysicsComponent.PhysicsEntity.IsAffectedByGravity = false;


            var shape = new ProceduralCube();

            shape.SetColor(colorScheme.Color4);

            for (int i = 0; i < 100; i++)
            {
                AddCube(shape, effect, RandomHelper.GetRandomVector3(new Vector3(-10, 2, -10), new Vector3(10, 20, 10)));
            }

            AddInputBindings();
            base.OnInitialise();
        }
Ejemplo n.º 10
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;

            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            SystemCore.ActiveScene.SetDiffuseLightDir(0, new Vector3(0.01f, 1, 0.01f));
            SystemCore.ActiveScene.FogEnabled = true;

            mouseCamera = new MouseFreeCamera(new Vector3(0, 0, 0));
            SystemCore.SetActiveCamera(mouseCamera);
            mouseCamera.moveSpeed = 0.1f;
            mouseCamera.SetPositionAndLook(new Vector3(50, 30, -20), (float)Math.PI, (float)-Math.PI / 5);

            cameraObject = new GameObject();
            cameraObject.AddComponent(new ComponentCamera(MathHelper.PiOver4, SystemCore.GraphicsDevice.Viewport.AspectRatio, 0.25f, 100.0f, false));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraObject);
            SystemCore.SetActiveCamera(cameraObject.GetComponent <ComponentCamera>());
            cameraOffset = new Vector3(0, 10, -10);


            AddInputBindings();



            SetUpGameWorld();

            chopper = new Chopper();
            chopper.Transform.SetPosition(new Vector3(10, 0.5f, 10));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(chopper);
            chopper.Transform.Rotate(Vector3.Up, MathHelper.Pi);

            carrier = new Carrier();
            carrier.Transform.SetPosition(new Vector3(5, 1, 5));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(carrier);


            carrier.GetComponent <PhysicsComponent>().PhysicsEntity.IsAffectedByGravity = false;
            carrier.GetComponent <PhysicsComponent>().PhysicsEntity.Mass = 100;

            SystemCore.PhysicsSimulation.ForceUpdater.Gravity = new BEPUutilities.Vector3(0, -1f, 0);


            OrientCamera(chopper);

            base.OnInitialise();
        }
Ejemplo n.º 11
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;

            SystemCore.ActiveScene.AddKeyLight(Vector3.Up, Color.White, 1f, false);
            camera       = new DummyOrthographicCamera(SystemCore.Viewport.Width / 10, SystemCore.Viewport.Height / 10, 0.3f, 50f);
            camera.World = Matrix.CreateWorld(new Vector3(0, 20, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1));
            camera.View  = Matrix.Invert(camera.World);
            SystemCore.SetActiveCamera(camera);


            for (int i = 1; i < 64 * 32; i++)
            {
                var cube = new ProceduralCube();
                cube.SetColor(RandomHelper.RandomColor);
                var ball = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));

                int column = i % 64;
                int row    = i / 64;

                ball.Transform.SetPosition(new Vector3(-(column - 1), 0, row));


                SystemCore.GameObjectManager.AddAndInitialiseGameObject(ball);
            }

            //var cube = new ProceduralCube();
            //cube.SetColor(Color.White);
            //ball = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
            //ball.Transform.SetPosition(Vector3.Zero);

            //SystemCore.GameObjectManager.AddAndInitialiseGameObject(ball);


            //Initialise
            InitialiseEmulator();


            //load ROM
            LoadRom("PONG");

            base.OnInitialise();
        }
Ejemplo n.º 12
0
        public override void OnInitialise()
        {
            CollisionRules.DefaultCollisionRule = CollisionRule.NoSolver;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            SystemCore.ActiveScene.SetDiffuseLightDir(0, new Vector3(1, 1, 1));

            float arenaSize   = 40f;
            var   arenaObject = CreateTestArena(arenaSize);

            cameraGameObject = new GameObject("camera");
            cameraGameObject.AddComponent(new ComponentCamera());
            cameraGameObject.Transform.SetPosition(new Vector3(0, 200, 0));
            cameraGameObject.Transform.SetLookAndUp(new Vector3(0, -1, 0), new Vector3(0, 0, 1));

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraGameObject);
            SystemCore.SetActiveCamera(cameraGameObject.GetComponent <ComponentCamera>());



            player = new GridWarrior(new Vector3(0, 5, 0));

            enemies = new List <SimpleEnemy>();
            for (int i = 0; i < 5; i++)
            {
                SpawnEnemy();
            }


            healthLabel = new Label(GUIFonts.Fonts["neuropolitical"], "Health:");

            healthLabel.SetPosition(new Vector2(GUIManager.GetFractionOfWidth(0.1f),
                                                GUIManager.GetFractionOfHeight(0.02f)));

            SystemCore.GUIManager.AddControl(healthLabel);

            killLabel = new Label(GUIFonts.Fonts["neuropolitical"], "Kills:");
            killLabel.SetPosition(new Vector2(GUIManager.GetFractionOfWidth(0.9f),
                                              GUIManager.GetFractionOfHeight(0.02f)));

            SystemCore.GUIManager.AddControl(killLabel);
            base.OnInitialise();
        }
Ejemplo n.º 13
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;

            SystemCore.ActiveScene.AddKeyLight(Vector3.Up, Color.White, 1f, false);
            camera       = new DummyOrthographicCamera(SystemCore.Viewport.Width / 10, SystemCore.Viewport.Height / 10, 0.3f, 50f);
            camera.World = Matrix.CreateWorld(new Vector3(0, 20, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1));
            camera.View  = Matrix.Invert(camera.World);
            SystemCore.SetActiveCamera(camera);


            var cube = new ProceduralCube();

            cube.SetColor(Color.White);
            ball = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
            ball.Transform.SetPosition(Vector3.Zero);

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(ball);

            base.OnInitialise();
        }
Ejemplo n.º 14
0
        public override void OnInitialise()
        {
            startPos = new Vector3(0, planetSize * 1.25f, 0);

            CollisionRules.DefaultCollisionRule = CollisionRule.NoSolver;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();


            SystemCore.AddNewUpdateRenderSubsystem(new SkyDome(Color.Black, Color.Black, Color.Black));


            cameraGameObject = new GameObject("camera");
            cameraGameObject.AddComponent(new ComponentCamera());
            cameraGameObject.Transform.SetPosition(startPos);
            cameraGameObject.Transform.SetLookAndUp(new Vector3(1, 0, 0), new Vector3(0, 1, 0));
            cameraGameObject.AddComponent(new MouseController());
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraGameObject);
            SystemCore.SetActiveCamera(cameraGameObject.GetComponent <ComponentCamera>());

            planets = new List <MiniPlanet>();

            var shape = SimpleModelEditor.LoadShape("voxrocket");

            if (shape != null)
            {
                testShip = GameObjectFactory.CreateRenderableGameObjectFromShape(shape,
                                                                                 EffectLoader.LoadSM5Effect("flatshaded"));

                testShip.Transform.Rotate(Vector3.Up, -MathHelper.PiOver2);
                testShip.Transform.AbsoluteTransform.Translation = new Vector3(100, 0, 0);
                //testShip.AddComponent(new RotatorComponent(Vector3.Right, 0.001f));

                SystemCore.GameObjectManager.AddAndInitialiseGameObject(testShip);
            }

            GenerateSystem();

            base.OnInitialise();
        }
Ejemplo n.º 15
0
        public override void OnInitialise()
        {
            //lighting
            fpsLabel.Visible = true;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();
            SystemCore.ActiveScene.SetDiffuseLightDir(0, new Vector3(0.01f, 1, 0.01f));
            SystemCore.ActiveScene.FogEnabled = false;



            //input
            input = SystemCore.GetSubsystem <InputManager>();
            input.AddKeyDownBinding("CameraForward", Keys.Up);
            input.AddKeyDownBinding("CameraBackward", Keys.Down);
            input.AddKeyDownBinding("CameraLeft", Keys.Left);
            input.AddKeyDownBinding("CameraRight", Keys.Right);
            input.AddKeyPressBinding("MainMenu", Keys.Escape);
            var binding = input.AddKeyPressBinding("WireframeToggle", Keys.Space);

            binding.InputEventActivated += (x, y) => { SystemCore.Wireframe = !SystemCore.Wireframe; };


            //camera
            cameraObject = new GameObject();
            camComponent = new ComponentCamera();
            cameraObject.AddComponent(camComponent);
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraObject);
            cameraObject.Transform.SetPosition(new Vector3(0, 100, 0));
            cameraObject.Transform.Rotate(Vector3.Right, MathHelper.ToRadians(-45));
            cameraObject.Transform.Rotate(Vector3.Up, -MathHelper.PiOver4);
            SystemCore.SetActiveCamera(camComponent);


            simulation = new GameSimulation();
            simulation.InitaliseSimulation();

            base.OnInitialise();
        }
Ejemplo n.º 16
0
        public MainGameScreen()
            : base()
        {
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();

            SystemCore.AddNewUpdateRenderSubsystem(new SkyDome(Color.Black, Color.Black, Color.Black));


            ship = new Ship("ship");
            SystemCore.SetActiveCamera(ship.shipCameraObject.GetComponent <ComponentCamera>());



            Model           geoDesicModel = SystemCore.ContentManager.Load <Model>("Models/geodesic2");
            ProceduralShape geodesicShape = ModelMeshParser.GetShapeFromModelWithUVs(geoDesicModel);

            geodesicShape.Scale(1f);
            geodesicShape.InsideOut();

            ship.AddComponent(new RenderGeometryComponent(geodesicShape));
            //var cockpitEffectComponent = new EffectRenderComponent(EffectLoader.LoadEffect("cockpitscreen"));
            //cockpitEffectComponent.DrawOrder = 100;
            //ship.AddComponent(cockpitEffectComponent);

            oldPos = ship.GetComponent <HighPrecisionPosition>().Position;
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(ship);


            testPlanetSurfacePosition           = new PlanetSurfacePosition();
            testPlanetSurfacePosition.Latitude  = 40;
            testPlanetSurfacePosition.Longitude = -90;

            solarSystem            = new SolarSystem();
            solarSystem.PlayerShip = ship;
            ship.SolarSystem       = solarSystem;
            SystemCore.AddNewGameComponent(solarSystem);
            ship.Transform.Rotate(Vector3.Up, MathHelper.PiOver2);
        }
Ejemplo n.º 17
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = false;
            fpsLabel.Visible         = true;

            SystemCore.ActiveScene.SetUpAmbientAndFullLightingRig();



            float lightDistance = 80f;
            float fadeStart     = 50;
            float fadeEnd       = 100;

            SystemCore.ActiveScene.AddPointLight(new Vector3(lightDistance, 0, 0), new Color(0.1f, 0.5f, 0.1f, 1), fadeStart, fadeEnd, 1f, PointLightNumber.One);
            SystemCore.ActiveScene.AddPointLight(new Vector3(-lightDistance, 0, 0), Color.Blue, fadeStart, fadeEnd, 1f, PointLightNumber.Two);
            SystemCore.ActiveScene.AddPointLight(new Vector3(0, 0, -lightDistance), Color.White, fadeStart, fadeEnd, 1f, PointLightNumber.Three);
            SystemCore.ActiveScene.AddPointLight(new Vector3(0, 0, lightDistance), Color.Red, fadeStart, fadeEnd, 1f, PointLightNumber.Four);

            var effect = EffectLoader.LoadSM5Effect("FlatShaded");

            SystemCore.ActiveScene.FogEnabled = false;


            mouseCamera = new MouseFreeCamera(new Vector3(0, 0, 0));
            SystemCore.SetActiveCamera(mouseCamera);

            var shape = new ProceduralSphere(20, 20);

            shape.SetColor(Color.LightGray);


            for (int i = 0; i < 10; i++)
            {
                var gameObject = new GameObject();
                gameObject.AddComponent(new RenderGeometryComponent(BufferBuilder.VertexBufferBuild(shape), BufferBuilder.IndexBufferBuild(shape), shape.PrimitiveCount));
                gameObject.AddComponent(new EffectRenderComponent(effect));
                gameObject.Transform.SetPosition(RandomHelper.GetRandomVector3(Vector3.One * -100, Vector3.One * 100));
                gameObject.AddComponent(new RotatorComponent(Vector3.Up));
                gameObject.AddComponent(new ShadowCasterComponent());



                SystemCore.GetSubsystem <GameObjectManager>().AddAndInitialiseGameObject(gameObject);
                gameObject.Transform.Scale    = 5f;
                gameObject.Transform.Velocity = RandomHelper.GetRandomVector3(-Vector3.One, Vector3.One) * 0.01f;
            }


            AddInputBindings();

            AddTestMario("Mario", Vector3.Zero);
            AddTestMario("RedGloss", new Vector3(20, 0, 0));
            AddTestMario("RedMatt", new Vector3(-20, 0, 0));
            AddTestMario("OrangeGloss", new Vector3(0, 0, -20));
            AddTestMario("WoodenCrate", new Vector3(0, 0, 20));

            crate = AddTestModel("Models/Crate", "WoodenCrate");
            crate.Transform.SetPosition(new Vector3(100, 0, 50));
            crate.Transform.Scale = 0.01f;


            var groundShape = new ProceduralCuboid(10, 10, 0.5f);

            groundShape.SetColor(Color.LightGray);
            var gameObjectPlane = new GameObject();

            gameObjectPlane.AddComponent(new RenderGeometryComponent(BufferBuilder.VertexBufferBuild(groundShape), BufferBuilder.IndexBufferBuild(groundShape), groundShape.PrimitiveCount));
            gameObjectPlane.AddComponent(new EffectRenderComponent(effect));
            gameObjectPlane.Transform.SetPosition(new Vector3(0, -20, 0));
            gameObjectPlane.Transform.Scale = 10f;
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(gameObjectPlane);


            Heightmap heightMap = new Heightmap(100, 1);
            var       seaObject = heightMap.CreateRenderableHeightMap(Color.Blue, EffectLoader.LoadSM5Effect("water"));

            seaObject.Transform.SetPosition(new Vector3(0, 0, 0));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(seaObject);

            base.OnInitialise();
        }
Ejemplo n.º 18
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = true;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();

            cameraObject = new GameObject();
            worldObjects = new Dictionary <int, GameObject>();
            //give it some random ID to keep it out the range of the doom objects
            cameraObject.ID = 990000;

            cameraObject.AddComponent(new ComponentCamera(MathHelper.PiOver4, SystemCore.GraphicsDevice.Viewport.AspectRatio, 0.25f, 1000.0f, false));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraObject);
            SystemCore.SetActiveCamera(cameraObject.GetComponent <ComponentCamera>());
            cameraObject.Transform.AbsoluteTransform = Matrix.CreateWorld(new Vector3(0, -500, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1));


            mapHandler = new DoomMapHandler(filePath, "E1M" + level.ToString(), "E1M" + (level + 1).ToString());
            mapHandler.ParseWad();
            mapHandler.InitialiseFloodFill();


            apiHandler = new DoomAPIHandler(url, port);

            apiHandler.CreateRegularRequest(1000, new RestRequest("player"), x =>
            {
                UpdatePlayer(x);
            });

            apiHandler.CreateRegularRequest(4000, new RestRequest("world/objects"), x =>
            {
                foreach (GameObject worldObject in worldObjects.Values)
                {
                    SystemCore.GameObjectManager.RemoveObject(worldObject);
                }

                worldObjects.Clear();

                IDictionary <string, object> jsonValues = Json.JsonParser.FromJson(x.Content);
                List <object> objectList = jsonValues["array0"] as List <object>;


                List <string> types = new List <string>();


                foreach (object o in objectList)
                {
                    double id, angle, health, distance, xpos, ypos;
                    string type;

                    ParseObjectData(o, out id, out type, out angle, out health, out distance, out xpos, out ypos);

                    if (id == 0)
                    {
                        continue;
                    }

                    if (id == playerId)
                    {
                        continue;
                    }

                    GameObject worldObject;
                    DoomComponent component;

                    CreateLocalWorldObject(id, type, out worldObject, out component);

                    UpdateObject(worldObject, angle, xpos, ypos, type, health, distance);

                    types.Add(type);
                }
            });


            pickUpTypes = new List <string>();



            base.OnInitialise();
        }
Ejemplo n.º 19
0
        public override void OnInitialise()
        {
            SystemCore.CursorVisible = true;
            SystemCore.ActiveScene.SetUpBasicAmbientAndKey();

            cameraObject = new GameObject();

            //give it some random ID to keep it out the range of the doom objects
            cameraObject.ID = 990000;


            cameraObject.AddComponent(new ComponentCamera(MathHelper.PiOver4, SystemCore.GraphicsDevice.Viewport.AspectRatio, 0.25f, 1000.0f, false));
            SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraObject);
            SystemCore.SetActiveCamera(cameraObject.GetComponent <ComponentCamera>());
            cameraObject.Transform.AbsoluteTransform = Matrix.CreateWorld(new Vector3(0, -500, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1));


            var file = new FileInfo(filePath);

            using (var fs = file.OpenRead())
            {
                var doomWad = DoomWad.FromFile(filePath);

                string desiredLevel = "E1M1";

                int levelMarker = doomWad.Index.FindIndex(x => x.Name.Contains(desiredLevel));
                for (int i = levelMarker + 1; i < doomWad.NumIndexEntries; i++)
                {
                    var currentIndex = doomWad.Index[i];

                    if (currentIndex.Name.Contains("E1M2"))
                    {
                        break;
                    }

                    if (currentIndex.Name == ("SECTORS\0"))
                    {
                        sectors = currentIndex.Contents as DoomWad.Sectors;
                    }

                    if (currentIndex.Name.Contains("BLOCKMAP"))
                    {
                        blockMap = currentIndex.Contents as DoomWad.Blockmap;
                    }

                    if (currentIndex.Name.Contains("SIDEDEF"))
                    {
                        sideDefs = currentIndex.Contents as DoomWad.Sidedefs;
                    }

                    if (currentIndex.Name.Contains("VERTEX"))
                    {
                        vertices = currentIndex.Contents as DoomWad.Vertexes;
                    }

                    if (currentIndex.Name.Contains("THING"))
                    {
                        things = currentIndex.Contents as DoomWad.Things;
                    }

                    if (currentIndex.Name.Contains("LINEDEF"))
                    {
                        lineDefs = currentIndex.Contents as DoomWad.Linedefs;
                    }
                }
            }


            worldObjects = new Dictionary <int, GameObject>();
            apiHandler   = new DoomAPIHandler(restHost, restPort);
            aStar        = new AStar();

            GenerateNavStructures();

            base.OnInitialise();
        }
Ejemplo n.º 20
0
 public void Activate()
 {
     SystemCore.SetActiveCamera(chaseCamera);
 }
Ejemplo n.º 21
0
 public void Activate()
 {
     SystemCore.SetActiveCamera(CameraObject.GetComponent <ComponentCamera>());
 }