Exemplo n.º 1
0
        public void AddCharacter(DefaultCamera camera, InputManager inputManager, GameObject gameObject, float mass)
        {
            CharacterController rbc = new CharacterController(camera, inputManager, mass);

            gameObject.AddController(rbc);
            world.AddBody(rbc.Body);
            rbc.Body.EnableDebugDraw = true;
            rbc.Body.DebugDraw(debugDraw);
        }
Exemplo n.º 2
0
        /**
         * An async method to set the default camera and initialize the default camera
         */
        public async Task InitDefaultCameraAsync()
        {
            if (DefaultCamera == null)
            {
                var cameraDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

                // here we use the first or default camera. If requirement changes we can change the camera by changing selection here
                DeviceInformation defaultWebCamDev = cameraDevices.FirstOrDefault();
                DefaultCamera = await CameraDevice.CreateNewCameraDeviceAsync(defaultWebCamDev);
            }

            if (DefaultCamera.CameraCapture == null)
            {
                await DefaultCamera.InitCameraAsync();
            }
        }
Exemplo n.º 3
0
        private void WebsiteClick(UIEvent ev)
        {
            WebsiteEnter(null);

            AudioComponent audio = _website.GetComponent <AudioComponent>();

            audio.Play();
            audio.SetVolume(0.35f);

            if (!_finished)
            {
                AddDebt(1);

                Vector2 pos = DefaultCamera.ScreenPointToWorld(InputManager.Instance.MousePosition);
                BurstDollars(1, pos);

                _websiteSprite.Texture = ResourceManager.Load <Texture2D>($"Textures/Website{Random.NextRange(0, MAX_WEBSITES)}.png");
            }
        }
Exemplo n.º 4
0
        public void Setup()
        {
            try
            {
                this.state_e = GameState.SETUP;

                Core.DrawSpritesFirst();
                DefaultCamera.SetAspect((float)this.height_i / (float)this.width_i);
                Mouse.Hide();

                this.backdrop.Setup();
                this.player.Setup();
                this.aliens.Setup();
                this.sound.Setup();

                this.state_e = GameState.TITLE;

                Core.Sync();
            }
            catch (Exception ex)
            {
                this.exception_ex = ex;
            }
        }
Exemplo n.º 5
0
 public CharacterController(DefaultCamera camera, InputManager inputManager, float mass) : base(mass, PhysicsWorld.PhysicsShape.ConvexMesh)
 {
     this.camera        = camera;
     this.inputManager  = inputManager;
     camera.KeysEnabled = false;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Function to set up the renderers initial state.
        /// </summary>
        private void SetDefaultStates()
        {
            // Add shader includes if they're gone.
            if (!Graphics.Shaders.IncludeFiles.Contains("Gorgon2DShaders"))
            {
                Graphics.Shaders.IncludeFiles.Add("Gorgon2DShaders", Encoding.UTF8.GetString(Resources.BasicSprite));
            }

            // Record the initial state before set up.
            if (_initialState == null)
            {
                _initialState = new Gorgon2DStateRecall(this);
            }

            // Reset the cache values.
            _cache.Reset();

            // Set our default shaders.
            VertexShader.Current            = VertexShader.DefaultVertexShader;
            PixelShader.Current             = PixelShader.DefaultPixelShaderDiffuse;
            Graphics.Input.IndexBuffer      = DefaultIndexBuffer;
            Graphics.Input.VertexBuffers[0] = DefaultVertexBufferBinding;
            Graphics.Input.Layout           = DefaultLayout;
            Graphics.Input.PrimitiveType    = PrimitiveType.TriangleList;

            IsMultisamplingEnabled = Graphics.Rasterizer.States.IsMultisamplingEnabled;

            if (PixelShader != null)
            {
                GorgonTextureSamplerStates sampler = GorgonTextureSamplerStates.LinearFilter;
                sampler.TextureFilter = TextureFilter.Point;
                Graphics.Shaders.PixelShader.TextureSamplers[0] = sampler;
                Graphics.Shaders.PixelShader.Resources[0]       = null;
            }

            Graphics.Rasterizer.States                         = GorgonRasterizerStates.CullBackFace;
            Graphics.Output.BlendingState.States               = GorgonBlendStates.DefaultStates;
            Graphics.Output.DepthStencilState.States           = GorgonDepthStencilStates.NoDepthStencil;
            Graphics.Output.DepthStencilState.StencilReference = 0;
            Graphics.Output.SetRenderTarget(_defaultTarget.Target, _defaultTarget.DepthStencil);

            _currentTarget = _defaultTarget;

            UpdateTarget(ref _currentTarget);

            DefaultCamera.Update();

            // Get the current state.
            DefaultState = new Gorgon2DStateRecall(this);

            // By default, turn on multi sampling over a count of 1.
            if (Target.Resource.ResourceType != ResourceType.Texture2D)
            {
                return;
            }

            var target2D = (GorgonRenderTarget2D)Target.Resource;

            if ((!IsMultisamplingEnabled) &&
                ((target2D.Settings.Multisampling.Count > 1) || (target2D.Settings.Multisampling.Quality > 0)) &&
                ((Graphics.VideoDevice.SupportedFeatureLevel == DeviceFeatureLevel.SM4_1) ||
                 (Graphics.VideoDevice.SupportedFeatureLevel == DeviceFeatureLevel.SM5)))
            {
                _multiSampleEnable = true;
            }
        }
Exemplo n.º 7
0
        public Map3DDrawable(DeathmatchMap Map, GraphicsDevice g)
        {
            this.Map  = Map;
            sprCursor = Map.sprCursor;
            Camera    = new DefaultCamera(g);

            effect = Map.Content.Load <Effect>("Shaders/Default Shader 3D");

            PolygonEffect = new BasicEffect(g);


            PolygonEffect.TextureEnabled = true;
            PolygonEffect.EnableDefaultLighting();

            float aspectRatio = g.Viewport.Width / (float)g.Viewport.Height;

            Matrix Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                                    aspectRatio,
                                                                    1, 10000);

            PolygonEffect.Projection = Projection;

            PolygonEffect.World = Matrix.Identity;
            PolygonEffect.View  = Matrix.Identity;

            // Key light.
            effect.Parameters["DirLight0Direction"].SetValue(new Vector3(-0.5265408f, -0.5735765f, -0.6275069f));
            effect.Parameters["DirLight0DiffuseColor"].SetValue(new Vector3(1, 0.9607844f, 0.8078432f));
            effect.Parameters["DirLight0SpecularColor"].SetValue(new Vector3(1, 0.9607844f, 0.8078432f));

            // Fill light.
            effect.Parameters["DirLight1Direction"].SetValue(new Vector3(0.7198464f, 0.3420201f, 0.6040227f));
            effect.Parameters["DirLight1DiffuseColor"].SetValue(new Vector3(0.9647059f, 0.7607844f, 0.4078432f));
            effect.Parameters["DirLight1SpecularColor"].SetValue(Vector3.Zero);

            // Back light.
            effect.Parameters["DirLight2Direction"].SetValue(new Vector3(0.4545195f, -0.7660444f, 0.4545195f));
            effect.Parameters["DirLight2DiffuseColor"].SetValue(new Vector3(0.3231373f, 0.3607844f, 0.3937255f));
            effect.Parameters["DirLight2SpecularColor"].SetValue(new Vector3(0.3231373f, 0.3607844f, 0.3937255f));

            Vector3 diffuseColor      = Vector3.One;
            Vector3 emissiveColor     = Vector3.Zero;
            Vector3 ambientLightColor = new Vector3(0.05333332f, 0.09882354f, 0.1819608f);
            Vector4 diffuse           = new Vector4();
            Vector3 emissive          = new Vector3();
            float   alpha             = 1;

            diffuse.X = diffuseColor.X * alpha;
            diffuse.Y = diffuseColor.Y * alpha;
            diffuse.Z = diffuseColor.Z * alpha;
            diffuse.W = alpha;

            emissive.X = (emissiveColor.X + ambientLightColor.X * diffuseColor.X) * alpha;
            emissive.Y = (emissiveColor.Y + ambientLightColor.Y * diffuseColor.Y) * alpha;
            emissive.Z = (emissiveColor.Z + ambientLightColor.Z * diffuseColor.Z) * alpha;

            effect.Parameters["DiffuseColor"].SetValue(diffuse);
            effect.Parameters["EmissiveColor"].SetValue(emissive);
            effect.Parameters["SpecularColor"].SetValue(Vector3.One);
            effect.Parameters["SpecularPower"].SetValue(64);


            DicDrawablePointPerColor  = new Dictionary <Color, List <Tile3D> >();
            DicTile3DByTileset        = new Dictionary <int, Tile3DHolder>();
            ListDrawableArrowPerColor = new List <Tile3D>();

            for (int L = 0; L < Map.LayerManager.ListLayer.Count; L++)
            {
                CreateMap(Map, Map.LayerManager.ListLayer[L], L);
            }

            foreach (KeyValuePair <int, Tile3DHolder> ActiveTileSet in DicTile3DByTileset)
            {
                ActiveTileSet.Value.Finish(GameScreen.GraphicsDevice);
            }

            float        Z               = Map.LayerManager.ListLayer[0].ArrayTerrain[0, 0].Position.Z * 32;
            Map2D        GroundLayer     = Map.LayerManager.ListLayer[0].LayerGrid;
            DrawableTile ActiveTerrain   = GroundLayer.GetTile(0, 0);
            Terrain3D    ActiveTerrain3D = ActiveTerrain.Terrain3DInfo;

            Cursor = ActiveTerrain3D.CreateTile3D(0, Point.Zero,
                                                  0, 0, Z, 0, Map.TileSize, new List <Texture2D>()
            {
                sprCursor
            }, Z, Z, Z, Z, 0)[0];
        }
Exemplo n.º 8
0
        void InitializeBehaviors()
        {
            Delegater delegater = repo.Delegater;

            /*
             * FPS
             */
            fps = new FrameRateCounter();
            delegater.Bind(Groups.FrameRate, fps);

            /*
             * Camera
             */
            DefaultCamera camera = new DefaultCamera(GraphicsDevice)
            {
                ClearColor = Color.CornflowerBlue
            };

            delegater.Bind(Groups.Camera, camera);

            /*
             * Background
             */
            // bug: spritebatch.Begin(AlphaBlend) makes sure that this quad gets drawn in the background
            // which means that some important renderstates are getting set, but not by me
            FullScreenQuad background = new FullScreenQuad()
            {
                Top       = new Color(25, 31, 32),
                Bottom    = new Color(71, 81, 90),
                DrawOrder = 0
            };

            delegater.Bind(Groups.Background, background);

            /*
             * Statue
             */
            StatueInformation statueInformation = new StatueInformation()
            {
                StatueSettings = StatueSettings[0]
            };

            delegater.Bind(Groups.Statue, statueInformation);

            Statue statue = new Statue()
            {
                DrawOrder = 2 // to fix some troubles with blobs getting viewed through the statue
            };

            delegater.Bind(Groups.Statue, statue);

            StatueMouseController statueController = new StatueMouseController();

            delegater.Bind(Groups.Statue, statueController);

            /*
             * Game Information
             */
            GameInformation gameInfo = new GameInformation()
            {
                GameMode = GameMode.Regular
            };

            delegater.Bind(Groups.GameInformation, gameInfo);

            GameInformationDisplay gameInfoDisplay = new GameInformationDisplay()
            {
                DrawOrder = 3
            };

            delegater.Bind(Groups.GameInformation, gameInfoDisplay);

            /*
             * Blob Production
             */
            DirtProducer blobProducer = new DirtProducer();

            delegater.Bind(Groups.DirtProduction, blobProducer);

            /*
             * Game State Control
             */
            GameStateController stateController = new GameStateController();

            delegater.Bind(Groups.GameStateControl, stateController);

            /*
             * Menu stuff
             */
            StatueInformation menuStatueInformation = new StatueInformation()
            {
                StatueSettings = StatueSettings[0]
            };

            delegater.Bind(Groups.MenuStatuePreview, menuStatueInformation);

            Statue menuStatue = new Statue()
            {
                DrawOrder = 2
            };

            delegater.Bind(Groups.MenuStatuePreview, menuStatue);

            StatuePreviewSpinner statueSpinner = new StatuePreviewSpinner();

            delegater.Bind(Groups.MenuStatuePreview, statueSpinner);

            MenuItemsDisplay menuItems = new MenuItemsDisplay()
            {
                DrawOrder = 3
            };

            delegater.Bind(Groups.MenuItemsDisplay, menuItems);

            /*
             * Intro
             */
            Intro intro = new Intro();

            delegater.Bind(Groups.Intro, intro);



            // omg, lousy hack.. these two lines makes sure we get to see the damn preview model in menu screen :P
            // im too tired to find the reason.. the code is such a mess already
            stateController.GameState = GameState.Playing;
            stateController.GameState = GameState.Menu;
            stateController.GameState = GameState.Intro;
        }
Exemplo n.º 9
0
 private void Awake()
 {
     instance      = this;
     this.m_camera = this.GetComponent <Camera>();
 }