Example #1
0
        /// <summary>
        /// Init the UI and player status components of the game.
        /// </summary>
        /// <param name="scene">Game main scene.</param>
        private void InitUI(GameScene scene)
        {
            // get UI manager from scene
            GeonBit.UI.UserInterface UI = scene.UserInterface;

            // disable cursor
            UI.ShowCursor = false;

            // create the progressbar to display player hp
            GeonBit.UI.Entities.ProgressBar hpShow = new GeonBit.UI.Entities.ProgressBar(0, 5, new Vector2(300, -1), GeonBit.UI.Entities.Anchor.TopLeft);
            hpShow.Caption.Text           = "Shield";
            hpShow.Locked                 = true;
            hpShow.ProgressFill.FillColor = Color.Green;
            UI.AddEntity(hpShow);
            PlayerStatus.HpShow = hpShow;

            // create the progressbar to display player ammo
            GeonBit.UI.Entities.ProgressBar ammoShow = new GeonBit.UI.Entities.ProgressBar(0, 100, new Vector2(300, -1), GeonBit.UI.Entities.Anchor.TopLeft, new Vector2(0, 50));
            ammoShow.Caption.Text           = "Ammo";
            ammoShow.Locked                 = true;
            ammoShow.ProgressFill.FillColor = Color.Red;
            UI.AddEntity(ammoShow);
            PlayerStatus.AmmoShow = ammoShow;

            // pagraph to show current score
            GeonBit.UI.Entities.Paragraph scoreShow = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.TopCenter);
            UI.AddEntity(scoreShow);
            PlayerStatus.ScoreShow = scoreShow;

            // reset player status
            PlayerStatus.Reset();
        }
Example #2
0
        /// <summary>
        /// Initialize to implement per main type.
        /// </summary>
        override public void Initialize()
        {
            // create the scene
            GameScene scene = new GameScene();

            // create skybox
            Managers.GraphicsManager.CreateSkybox(null, scene.Root);
            Managers.Diagnostic.DebugRenderPhysics = false;

            // create camera object
            GameObject camera          = new GameObject();
            Camera     cameraComponent = new Camera();

            cameraComponent.FarPlane = 10000f;
            camera.AddComponent(cameraComponent);
            camera.SceneNode.Position = new Vector3(-100, 100, -100);
            cameraComponent.LookAt    = new Vector3(0, 100, 0);
            camera.AddComponent(new CameraEditorController());
            camera.Parent = scene.Root;

            // create the combined meshes component
            var combined = new CombinedMeshesRenderer <VertexPositionNormalTexture>();

            scene.Root.AddComponent(combined);

            // get model to add
            var model = Resources.GetModel("GeonBit.Core/BasicMeshes/Cube");

            // add lots of entities to the combined renderer
            int   amount    = 12;
            float shapeSize = 10f;

            for (int x = 0; x < amount; ++x)
            {
                for (int y = 0; y < amount; ++y)
                {
                    for (int z = 0; z < amount; ++z)
                    {
                        Matrix transform = Matrix.CreateTranslation(new Vector3(x, y, z) * shapeSize * 0.5f) * Matrix.CreateScale(shapeSize);
                        combined.AddModel(model, transform);
                    }
                }
            }

            // build the combined meshes
            combined.Build();

            // add diagnostic data paragraph to scene
            var diagnosticData = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.BottomLeft, offset: Vector2.One * 10f, scale: 0.7f);

            diagnosticData.BeforeDraw = (GeonBit.UI.Entities.Entity entity) =>
            {
                diagnosticData.Text = Managers.Diagnostic.GetReportString();
            };
            scene.UserInterface.AddEntity(diagnosticData);

            // set scene
            GeonBitMain.Instance.Application.LoadScene(scene);
        }
Example #3
0
        /// <summary>
        /// Initialize to implement per main type.
        /// </summary>
        override public void Initialize()
        {
            // create a new empty scene
            GameScene scene = new GameScene();

            // Init ui
            InitUI(scene);

            // create camera
            InitCamera(scene);

            // Init background and music
            InitAmbience(scene);

            // create meteors and explosions prototype
            InitAsteroids(scene);
            InitExplosions();

            // create the player
            InitPlayer(scene);

            // set to default top-down controls
            Managers.GameInput.SetDefaultTopDownControls();

            // add diagnostic data paragraph to scene
            var diagnosticData = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.BottomLeft, offset: Vector2.One * 10f, scale: 0.7f);

            diagnosticData.BeforeDraw = (GeonBit.UI.Entities.Entity entity) =>
            {
                diagnosticData.Text = Managers.Diagnostic.GetReportString();
            };
            scene.UserInterface.AddEntity(diagnosticData);

            // load our scene (eg make it active)
            scene.Load();
        }
Example #4
0
        /// <summary>
        /// Initialize to implement per main type.
        /// </summary>
        override public void Initialize()
        {
            // set scene size
            int sceneSize = 10000;

            // create the scene
            GameScene scene = new GameScene();

            GameObject.OctreeSceneBoundaries = new BoundingBox(Vector3.One * -sceneSize, Vector3.One * sceneSize);
            GameObject.OctreeMaxDivisions    = 7;
            GameObject octree = new GameObject("octree", SceneNodeType.OctreeCulling);

            octree.Parent = scene.Root;

            // create skybox
            Managers.GraphicsManager.CreateSkybox(null, scene.Root);

            // default no culling node types
            GameObject.DefaultSceneNodeType = SceneNodeType.Simple;

            // create camera
            GameObject camera          = new GameObject();
            Camera     cameraComponent = new Camera();

            camera.AddComponent(cameraComponent);
            cameraComponent.LookAt    = new Vector3(100, 2, 100);
            camera.SceneNode.Position = new Vector3(0, 100, 0);
            camera.AddComponent(new CameraEditorController());
            cameraComponent.FarPlane = 5000;
            camera.Parent            = scene.Root;

            // create floor material
            GeonBit.Core.Graphics.Materials.BasicMaterial tilesMaterial = new GeonBit.Core.Graphics.Materials.BasicMaterial();
            tilesMaterial.Texture        = Resources.GetTexture("test/floor");
            tilesMaterial.TextureEnabled = true;
            tilesMaterial.SpecularColor  = Color.Black;

            // for random positions
            System.Random rand = new System.Random();

            // create some starting tiles
            for (int i = 0; i < 80; ++i)
            {
                for (int j = 0; j < 80; ++j)
                {
                    GameObject    obj       = new GameObject();
                    ShapeRenderer tileModel = obj.AddComponent(new ShapeRenderer(ShapeMeshes.Cube)) as ShapeRenderer;
                    tileModel.SetMaterial(tilesMaterial);
                    obj.SceneNode.Scale    = Vector3.One * 10;
                    obj.SceneNode.Position = new Vector3(
                        rand.Next(-sceneSize, sceneSize),
                        rand.Next(-sceneSize, sceneSize),
                        rand.Next(-sceneSize, sceneSize));
                    obj.Parent = octree;
                }
            }

            // add diagnostic data paragraph to scene
            var diagnosticData = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.BottomLeft, offset: Vector2.One * 10f, scale: 0.7f);

            diagnosticData.BeforeDraw = (GeonBit.UI.Entities.Entity entity) =>
            {
                diagnosticData.Text = Managers.Diagnostic.GetReportString();
            };
            scene.UserInterface.AddEntity(diagnosticData);

            // set scene
            scene.Load();
        }
Example #5
0
        /// <summary>
        /// Initialize to implement per main type.
        /// </summary>
        override public void Initialize()
        {
            // set default scene node type
            GameObject.DefaultSceneNodeType = SceneNodeType.Simple;

            // create the scene
            GameScene scene = new GameScene();

            // add instructions
            GeonBit.UI.Entities.Paragraph instructions = new GeonBit.UI.Entities.Paragraph("Press number keys (1-9) to change particle types.");
            scene.UserInterface.AddEntity(instructions);

            // add diagnostic data paragraph to scene
            var diagnosticData = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.BottomLeft, offset: Vector2.One * 10f, scale: 0.7f);

            diagnosticData.BeforeDraw = (GeonBit.UI.Entities.Entity entity) =>
            {
                diagnosticData.Text = Managers.Diagnostic.GetReportString();
            };
            scene.UserInterface.AddEntity(diagnosticData);

            // create camera
            camera = new GameObject();
            Camera cameraComponent = new Camera();

            cameraComponent.LookAt = Vector3.Zero;
            camera.AddComponent(cameraComponent);
            camera.SceneNode.PositionZ = 50;
            camera.SceneNode.PositionY = 50;
            camera.AddComponent(new CameraEditorController());
            camera.Parent = scene.Root;

            // add skybox
            Managers.GraphicsManager.CreateSkybox(null, scene.Root);

            // particle system: red fountain
            {
                // define the particle
                GameObject    particle = new GameObject("particle", SceneNodeType.ParticlesNode);
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle.AddComponent(new TimeToLive(3f));
                particle.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 1f, 0f, 2.5f, 0.5f));
                particle.AddComponent(new MotionAnimator(BaseAnimatorProperties.Defaults, Vector3.Up * 25f, acceleration: Vector3.Down * 15f, velocityDirectionJitter: Vector3.One * 5));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 0.5f, 1.5f, 4f, 0.5f, 0.5f, 0.5f));
                particle.AddComponent(new ColorAnimator(BaseAnimatorProperties.Defaults, Color.Red, Color.Orange, 3f));

                // create particles system
                GameObject     systemObject = new GameObject("system1", SceneNodeType.Simple);
                ParticleSystem system       = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.85f));
                systemObject.Parent = scene.Root;
                _systems.Add(systemObject);
            }

            // particle system: gas cloud
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle.AddComponent(new TimeToLive(3f));
                particle.AddComponent(new SpawnRandomizer(positionJitter: Vector3.One * 2f));
                particle.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 0.75f, 0f, 2.5f, 0.5f));
                particle.AddComponent(new MotionAnimator(new BaseAnimatorProperties(speedFactor: 1.5f), Vector3.One, velocityDirectionJitter: Vector3.One));
                particle.AddComponent(new RotationAnimator(BaseAnimatorProperties.Defaults, 1f));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 0.5f, 1.5f, 4f, 0.5f, 0.5f, 0.5f));
                particle.AddComponent(new ColorAnimator(BaseAnimatorProperties.Defaults, Color.Green, Color.Black, 3f, startColorJitter: Color.Blue));

                // create particles system
                GameObject     systemObject = new GameObject("system2");
                ParticleSystem system       = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.35f));
                systemObject.Parent = scene.Root;
                _systems.Add(systemObject);
            }

            // particle system: balls madness
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Solid;
                particle.AddComponent(new TimeToLive(3f));
                particle.AddComponent(new MotionAnimator(new BaseAnimatorProperties(speedFactor: 25f), Vector3.One, velocityDirectionJitter: Vector3.One));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 0.5f, 1.5f, 4f, 0.5f, 0.5f, 0.5f));
                particle.AddComponent(new RotationAnimator(BaseAnimatorProperties.Defaults, 20f, 4f));
                particle.AddComponent(new ColorAnimator(BaseAnimatorProperties.Defaults, Color.Black, Color.Black, 1f, startColorJitter: Color.White, endColorJitter: Color.White));

                // create particles system
                GameObject     systemObject = new GameObject("system3");
                ParticleSystem system       = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.85f));
                systemObject.Parent = scene.Root;
                _systems.Add(systemObject);
            }

            // particle system: rain
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.RenderingQueue         = GeonBit.Core.Graphics.RenderingQueue.Solid;
                particle.SceneNode.PositionY = 50;
                particle.AddComponent(new TimeToLive(3f));
                particle.AddComponent(new SpawnRandomizer(positionJitter: new Vector3(100, 0, 40)));
                particle.AddComponent(new MotionAnimator(new BaseAnimatorProperties(speedFactor: 25f), Vector3.Down));

                // create particles system
                GameObject     systemObject = new GameObject("system4");
                ParticleSystem system       = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.85f));
                systemObject.Parent = scene.Root;
                _systems.Add(systemObject);
            }

            // particle system: explosions
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle.AddComponent(new TimeToLive(1f));
                particle.AddComponent(new SpawnRandomizer(positionJitter: Vector3.One * 2f, minColor: new Color(200, 75, 0), maxColor: new Color(255, 225, 50)));
                particle.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 1.0f, 0f, 1.0f, 0.25f));
                particle.AddComponent(new RotationAnimator(BaseAnimatorProperties.Defaults, 1f));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 0.5f, 2.5f, 1f, 0.15f, 0.25f, 0.25f));
                particle.AddComponent(new MotionAnimator(new BaseAnimatorProperties(speedFactor: 2f), Vector3.Zero, velocityDirectionJitter: Vector3.One));
                GameObject particle2 = particle.Clone();
                particle.GetComponent <ShapeRenderer>().BlendingState = GeonBit.Core.Graphics.BlendStates.Additive;

                // create particles system
                GameObject     systemObject = new GameObject("system5");
                ParticleSystem system       = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.85f));
                system.AddParticleType(new ParticleType(particle2, frequency: 0.85f));
                systemObject.Parent = scene.Root;
                _systems.Add(systemObject);
            }

            // particle system: backfire
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle.AddComponent(new TimeToLive(1f));
                particle.AddComponent(new SpawnRandomizer(minColor: new Color(200, 75, 0), maxColor: new Color(255, 225, 50)));
                particle.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 1.0f, 0f, 0.8f));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 1.5f, 0.1f, 1f, 0.15f, 0.15f, 0.15f));
                particle.AddComponent(new MotionAnimator(new BaseAnimatorProperties(speedFactor: 25f), Vector3.Down));

                // create an object that's rotating the particles system position around center
                GameObject rotator = new GameObject();
                rotator.AddComponent(new RotationAnimator(BaseAnimatorProperties.Defaults, 2f));
                rotator.Parent = scene.Root;

                // create particles system
                GameObject systemObject = new GameObject("system6");
                systemObject.SceneNode.PositionY = 10f;
                ParticleSystem system = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 1.0f));
                system.Interval           = 0.015f;
                system.AddParticlesToRoot = true;
                systemObject.Parent       = rotator;
                _systems.Add(systemObject);
            }

            // particle system: magic
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.BlendingState  = GeonBit.Core.Graphics.BlendStates.Additive;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle.AddComponent(new TimeToLive(3f));
                particle.AddComponent(new SpawnRandomizer(positionJitter: Vector3.One * 2.5f, minColor: Color.Red * 0.25f, maxColor: Color.White * 0.25f));
                particle.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 0.75f, 0f, 2.5f, 0.5f));
                particle.AddComponent(new MotionAnimator(new BaseAnimatorProperties(speedFactor: 1.5f), Vector3.One, velocityDirectionJitter: Vector3.One));
                particle.AddComponent(new RotationAnimator(BaseAnimatorProperties.Defaults, 1f));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 0.5f, 2.5f, 4f, 0.5f, 0.5f, 0.5f));

                // create particles system
                GameObject     systemObject = new GameObject("system7");
                ParticleSystem system       = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.3f));
                systemObject.Parent = scene.Root;
                _systems.Add(systemObject);
            }

            // particle system: magic missile
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.BlendingState  = GeonBit.Core.Graphics.BlendStates.Additive;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle.AddComponent(new TimeToLive(3f));
                particle.AddComponent(new SpawnRandomizer(positionJitter: Vector3.One * 2.5f, minColor: Color.Red * 0.25f, maxColor: Color.White * 0.25f));
                particle.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 0.75f, 0f, 2.5f, 0.5f));
                particle.AddComponent(new MotionAnimator(new BaseAnimatorProperties(speedFactor: 1.5f), Vector3.One, velocityDirectionJitter: Vector3.One));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 0.5f, 2.5f, 4f, 0.5f, 0.5f, 0.5f));

                // define another type of particle
                GameObject    particle2 = new GameObject("particle2");
                ShapeRenderer shape2    = particle2.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape2.BlendingState  = GeonBit.Core.Graphics.BlendStates.Additive;
                shape2.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle2.AddComponent(new TimeToLive(2f));
                particle2.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 1.5f, 0.1f, 1.5f, 0.15f, 0.15f, 0.15f));
                particle2.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 0.5f, 0f, 1.5f, 0.5f));

                // create an object that's rotating the particles system position around center
                GameObject rotator = new GameObject();
                rotator.AddComponent(new RotationAnimator(BaseAnimatorProperties.Defaults, 2f));
                rotator.Parent = scene.Root;

                // create particles system
                GameObject systemObject = new GameObject("system8");
                systemObject.SceneNode.PositionY = 10f;
                ParticleSystem system = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.3f));
                system.AddParticleType(new ParticleType(particle2, frequency: 0.5f));
                system.AddParticlesToRoot = true;
                systemObject.Parent       = rotator;
                _systems.Add(systemObject);
            }

            // particle system: smoke
            {
                // define the particle
                GameObject    particle = new GameObject("particle");
                ShapeRenderer shape    = particle.AddComponent(new ShapeRenderer(ShapeMeshes.Sphere), "model") as ShapeRenderer;
                shape.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Effects;
                particle.AddComponent(new TimeToLive(3f));
                particle.AddComponent(new FadeAnimator(BaseAnimatorProperties.Defaults, 1f, 0f, 2.5f, 0.5f));
                particle.AddComponent(new MotionAnimator(BaseAnimatorProperties.Defaults, Vector3.Up * 10f, velocityDirectionJitter: Vector3.One * 0.75f));
                particle.AddComponent(new ScaleAnimator(BaseAnimatorProperties.Defaults, 0.25f, 3.5f, 4f, 0.5f, 0.5f, 0.5f));
                particle.AddComponent(new ColorAnimator(BaseAnimatorProperties.Defaults, Color.Purple, Color.Black, 3f));

                // create particles system
                GameObject     systemObject = new GameObject("system9");
                ParticleSystem system       = systemObject.AddComponent(new ParticleSystem()) as ParticleSystem;
                system.AddParticleType(new ParticleType(particle, frequency: 0.35f));
                systemObject.Parent = scene.Root;
                _systems.Add(systemObject);
            }

            // select default system
            SelectParticleSystem(0);

            // set scene
            GeonBitMain.Instance.Application.LoadScene(scene);
        }
Example #6
0
        /// <summary>
        /// Initialize to implement per main type.
        /// </summary>
        override public void Initialize()
        {
            // create the scene
            GameScene scene = new GameScene();

            // Added GPU-animated model
            {
                // create skinned mesh object
                GameObject           modelObject = new GameObject("mech");
                SkinnedModelRenderer model       = new SkinnedModelRenderer("game/mech/Mech");

                // set model materials color and disable lighting
                foreach (var material in model.GetMaterials())
                {
                    material.DiffuseColor  = Color.Gray;
                    material.SpecularColor = Color.White;
                    material.SpecularPower = 50f;
                    material.AmbientLight  = new Color(150, 180, 225);
                }

                // add to gameobject and set its position and rotation
                modelObject.AddComponent(model, "model");
                modelObject.SceneNode.Scale     = Vector3.One * 0.1f;
                modelObject.SceneNode.PositionX = -45;
                modelObject.SceneNode.RotationY = (float)System.Math.PI;
                modelObject.Parent = scene.Root;
            }

            // Added CPU-animated model
            {
                // create skinned mesh object
                GameObject           modelObject = new GameObject("wolf");
                SkinnedModelRenderer model       = new SkinnedModelRenderer("game/wolf/Wolf");
                model.SetClip("Wolf_Skeleton|Wolf_Walk_cycle_", transitionTime: 0f);

                // set model materials color and disable lighting
                foreach (var material in model.GetMaterials())
                {
                    material.DiffuseColor = Color.White;
                    material.AmbientLight = Color.Gray;
                    material.Alpha        = 1f;
                }

                // fix something in wolf's model (problem with one of the mesh effects)
                var furMesh = model.GetMesh("Wolf_obj_fur");
                furMesh.RenderingQueue = GeonBit.Core.Graphics.RenderingQueue.Opacity;
                var furMaterial = furMesh.GetMaterial(0);
                furMaterial.Alpha         = 1f;
                furMaterial.DiffuseColor  = Color.White;
                furMaterial.SpecularPower = 10f;
                furMaterial.SpecularColor = Color.Black;
                furMaterial.Texture       = Resources.GetTexture("game/wolf/textures/Wolf_Fur_Alpha");

                // add to gameobject and set its position and rotation
                modelObject.AddComponent(model, "model");
                modelObject.SceneNode.Scale     = Vector3.One * 1.5f;
                modelObject.SceneNode.PositionX = 45;
                modelObject.SceneNode.RotationY = (float)System.Math.PI;
                modelObject.Parent = scene.Root;
            }

            // create skybox
            Managers.GraphicsManager.CreateSkybox(null, scene.Root);

            // create camera
            GameObject camera = new GameObject();

            camera.AddComponent(new CameraEditorController());
            Camera cameraComponent = new Camera();

            camera.AddComponent(cameraComponent);
            camera.SceneNode.Position  = new Vector3(0, 0.8f, -0.75f) * 250f;
            camera.SceneNode.RotationX = -2.5f;
            camera.Parent = scene.Root;

            // add diagnostic data paragraph to scene
            var diagnosticData = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.BottomLeft, offset: Vector2.One * 10f, scale: 0.7f);

            diagnosticData.BeforeDraw = (GeonBit.UI.Entities.Entity entity) =>
            {
                diagnosticData.Text = Managers.Diagnostic.GetReportString();
            };
            scene.UserInterface.AddEntity(diagnosticData);

            // set scene
            scene.Load();
        }
Example #7
0
 public void ResetMoves(GeonBit.UI.Entities.Paragraph moves)
 {
     movesLeft        = numOfMoves;
     moves.Text       = "Moves Left: " + (movesLeft).ToString();
     SearchedThisTurn = false;
 }
Example #8
0
        /// <summary>
        /// Initialize to implement per main type.
        /// </summary>
        override public void Initialize()
        {
            // create the scene
            GameScene scene = new GameScene();

            // create skybox
            Managers.GraphicsManager.CreateSkybox(null, scene.Root);
            Managers.Diagnostic.DebugRenderPhysics = false;

            // create camera object
            GameObject camera          = new GameObject();
            Camera     cameraComponent = new Camera();

            camera.AddComponent(cameraComponent);
            cameraComponent.LookAt    = new Vector3(100, 2, 100);
            camera.SceneNode.Position = new Vector3(0, 5, 0);
            camera.AddComponent(new CameraEditorController());
            camera.Parent = scene.Root;

            // create a tilemap for the floor
            TileMap tilemap = scene.Root.AddComponent(new TileMap(Vector2.One * 10f, 10)) as TileMap;

            // create floor material
            LitMaterial tilesMaterial = new LitMaterial();

            tilesMaterial.Texture        = Resources.GetTexture("game/floor");
            tilesMaterial.TextureEnabled = true;
            tilesMaterial.SpecularColor  = Color.Black;

            // set ambient light
            scene.Lights.AmbientLight = new Color(20, 20, 20, 255);

            // add robot model
            GameObject robot         = new GameObject();
            var        robotRenderer = robot.AddComponent(new ModelRenderer("Game/robot")) as ModelRenderer;
            var        robotMat      = new LitMaterial();

            robotMat.Texture        = Resources.GetTexture("Game/robottexture_0");
            robotMat.TextureEnabled = true;
            robotMat.DiffuseColor   = Color.White;
            robotRenderer.SetMaterial(robotMat);
            robot.SceneNode.Scale    = Vector3.One * tileSize * 0.75f;
            robot.SceneNode.Position = new Vector3(tilemapSize * tileSize * 0.5f, 10f, tilemapSize * tileSize * 0.5f);
            robot.Parent             = scene.Root;

            // attach light to camera
            {
                var lightComponent = camera.AddComponent(new Light()) as Light;
                lightComponent.Intensity = 2f;
                lightComponent.Range     = tileSize * 15f;
                lightComponent.Color     = Color.Green;
            }

            // add directional light
            {
                var lightComponent = scene.Root.AddComponent(new Light()) as Light;
                lightComponent.Intensity = 0.25f;
                lightComponent.Range     = 0f;
                lightComponent.Direction = Vector3.Normalize(new Vector3(0.2f, 1f, 0.1f));
                lightComponent.Color     = Color.White;
            }

            // attach lights
            lightsCenter      = new GameObject();
            lightsCenter.Name = "LightsCenter";
            lightsCenter.SceneNode.Position = robot.SceneNode.Position;
            for (int i = -1; i <= 1; i += 2)
            {
                GameObject lightGo = new GameObject();
                lightGo.Name = "Light" + i.ToString();
                lightGo.SceneNode.PositionX = i * tileSize * 3f;
                var lightComponent = lightGo.AddComponent(new Light()) as Light;
                lightComponent.Intensity = 3;
                lightComponent.Range     = tileSize * 15.5f;
                lightComponent.Color     = i == -1 ? Color.Red : Color.Blue;
                lightGo.Parent           = lightsCenter;
            }
            lightsCenter.Parent = scene.Root;

            // create some floor tiles
            for (int i = 0; i < tilemapSize; ++i)
            {
                for (int j = 0; j < tilemapSize; ++j)
                {
                    GameObject    tile      = tilemap.GetTile(new Point(i, j));
                    ShapeRenderer tileModel = tile.AddComponent(new ShapeRenderer(ShapeMeshes.Plane)) as ShapeRenderer;
                    tileModel.SetMaterial(tilesMaterial);
                    tile.SceneNode.Scale     = Vector3.One * tileSize * 0.5f;
                    tile.SceneNode.RotationX = (float)System.Math.PI * -0.5f;
                }
            }

            // add floor physical body
            GameObject floorPhysics   = new GameObject();
            float      wholePlaneSize = tilemapSize * tileSize;
            StaticBody floorBody      = floorPhysics.AddComponent(new StaticBody(new CollisionBox(wholePlaneSize, 5f, wholePlaneSize))) as StaticBody;

            floorBody.Restitution           = 0.75f;
            floorPhysics.SceneNode.Position = new Vector3((wholePlaneSize - tileSize) * 0.5f, -2.5f, (wholePlaneSize - tileSize) * 0.5f);
            floorPhysics.Parent             = scene.Root;

            // add diagnostic data paragraph to scene
            var diagnosticData = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.BottomLeft, offset: Vector2.One * 10f, scale: 0.7f);

            diagnosticData.BeforeDraw = (GeonBit.UI.Entities.Entity entity) =>
            {
                diagnosticData.Text = Managers.Diagnostic.GetReportString();
            };
            scene.UserInterface.AddEntity(diagnosticData);

            // set scene
            GeonBitMain.Instance.Application.LoadScene(scene);
        }
Example #9
0
        /// <summary>
        /// Initialize to implement per main type.
        /// </summary>
        override public void Initialize()
        {
            // create the scene
            GameScene scene = new GameScene();

            // create skybox
            Managers.GraphicsManager.CreateSkybox(null, scene.Root);
            Managers.Diagnostic.DebugRenderPhysics = false;

            // create camera object
            GameObject camera          = new GameObject();
            Camera     cameraComponent = new Camera();

            camera.AddComponent(cameraComponent);
            cameraComponent.LookAt    = new Vector3(100, 2, 100);
            camera.SceneNode.Position = new Vector3(0, 5, 0);
            camera.AddComponent(new CameraEditorController());
            camera.Parent = scene.Root;

            // create a tilemap for the floor
            TileMap tilemap = scene.Root.AddComponent(new TileMap(Vector2.One * 10f, 10)) as TileMap;

            // create floor material
            BasicMaterial tilesMaterial = new BasicMaterial();

            tilesMaterial.Texture        = Resources.GetTexture("game/floor");
            tilesMaterial.TextureEnabled = true;
            tilesMaterial.SpecularColor  = Color.Black;

            // create some floor tiles
            for (int i = 0; i < tilemapSize; ++i)
            {
                for (int j = 0; j < tilemapSize; ++j)
                {
                    GameObject    tile      = tilemap.GetTile(new Point(i, j));
                    ShapeRenderer tileModel = tile.AddComponent(new ShapeRenderer(ShapeMeshes.Plane)) as ShapeRenderer;
                    tileModel.SetMaterial(tilesMaterial);
                    tile.SceneNode.Scale     = Vector3.One * tileSize * 0.5f;
                    tile.SceneNode.RotationX = (float)System.Math.PI * -0.5f;
                }
            }

            // add floor physical body
            GameObject floorPhysics   = new GameObject();
            float      wholePlaneSize = tilemapSize * tileSize;
            StaticBody floorBody      = floorPhysics.AddComponent(new StaticBody(new CollisionBox(wholePlaneSize, 5f, wholePlaneSize))) as StaticBody;

            floorBody.Restitution           = 0.75f;
            floorPhysics.SceneNode.Position = new Vector3((wholePlaneSize - tileSize) * 0.5f, -2.5f, (wholePlaneSize - tileSize) * 0.5f);
            floorPhysics.Parent             = scene.Root;

            // create some random physical objects
            for (int i = 0; i < 100; ++i)
            {
                GameObject obj = CreateRandomShape();
                obj.Parent = scene.Root;
            }

            // add diagnostic data paragraph to scene
            var diagnosticData = new GeonBit.UI.Entities.Paragraph("", GeonBit.UI.Entities.Anchor.BottomLeft, offset: Vector2.One * 10f, scale: 0.7f);

            diagnosticData.BeforeDraw = (GeonBit.UI.Entities.Entity entity) =>
            {
                diagnosticData.Text = Managers.Diagnostic.GetReportString();
            };
            scene.UserInterface.AddEntity(diagnosticData);

            // set scene
            GeonBitMain.Instance.Application.LoadScene(scene);
        }