コード例 #1
0
ファイル: Lighting.cs プロジェクト: ozma9/ShadersAndLighting
        public Lighting()
        {
            screenBackBuffer = new RenderTarget2D(GV.Graphics.GraphicsDevice, GV.GameSize.X, GV.GameSize.Y, false, SurfaceFormat.Color, DepthFormat.None);
            lightingBuffer   = new RenderTarget2D(GV.Graphics.GraphicsDevice, GV.GameSize.X, GV.GameSize.Y, false, SurfaceFormat.Color, DepthFormat.None);

            hasEffects      = true;
            ambientLighting = 0.9f;

            mapHandler   = new MapHandler();
            lightHandler = new LightHandler();
            UpdateCampFireLights();

            mouseLight = new LightSource();
            mouseLight.sourceTexture = Textures.SHADER_sun;
            mouseLight.location      = new Rectangle(0, 0, Textures.SHADER_sun.Width * 2, Textures.SHADER_sun.Height * 2);
            MouseColourPicker();
            showMouseLight = true;
        }
コード例 #2
0
        public GameManager(GameLayout game, string contentDirectory)
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = contentDirectory;

            Template = new Template();
            penumbra = new PenumbraComponent(this);

            Services.AddService(penumbra);

            gameLayout = game;

            // Systems
            systems.Add(renderer         = new Renderer());
            systems.Add(collisionHandler = new CollisionHandler());
            systems.Add(physicsHandler   = new PhysicsHandler());
            systems.Add(animationHandler = new AnimationHandler(Content));
            systems.Add(lightHandler     = new LightHandler(penumbra));
        }
コード例 #3
0
    // Fixed update is performed on each physic update (Delta time).
    void FixedUpdate()
    {
        if (canClimb)
        {
            float verticalAxis = 0.0f;

            if (isMobile)
            {
                verticalAxis = joyStickAxis.GetAxis("Vertical");
            }
            else
            {
                verticalAxis = Input.GetAxis("Vertical");
            }
            Debug.Log("VerticalAxis: " + verticalAxis);
            if (verticalAxis > 0.0f && !topOfLadder)
            {
                transform.position += Vector3.up / 10f;
            }
            else if (verticalAxis < 0.0f)
            {
                transform.position -= Vector3.up / 10f;
            }
        }

        Ray        ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0.0f));
        RaycastHit hit;

        // Perform a ray cast down the Z axis relative to the camera transform, with a distance of 2.5 units.
        if (Physics.Raycast(ray, out hit, 2.5f))
        {
            bool actionPressed = isMobile ? mobileControls.GetAction() : Input.GetAxisRaw("Action") == 1;

            // If the object the ray intersects with is a battery (Battery Tag)
            if (hit.collider.tag == "Battery")
            {
                hoveringOverInteractable = true;

                // Get the Halo effect component for the game object and enable it if the cursor is over it.
                halo         = (Behaviour)hit.collider.gameObject.GetComponent("Halo");
                halo.enabled = true;

                // If the action button is pressed (Defined in InputManager under Axes). E on PC X on controller.
                if (actionPressed)
                {
                    // Remove the game object from the scene.
                    Destroy(hit.collider.gameObject);
                    hoveringOverInteractable = false;
                    halo.enabled             = false;
                    // Add a random amount of battery life to the flashlight.
                    LightHandler.AddBatteryLife(Random.Range(30, 45));
                }
            }
            else if (hit.collider.tag == "Clock")
            {
                hoveringOverInteractable = true;

                // Get the Halo effect component for the game object and enable it if the cursor is over it.
                halo         = (Behaviour)hit.collider.gameObject.GetComponent("Halo");
                halo.enabled = true;

                // If the action button is pressed (Defined in InputManager under Axes). E on PC X on controller.
                if (actionPressed)
                {
                    // Remove the game object from the scene.
                    Destroy(hit.collider.gameObject);
                    hoveringOverInteractable = false;
                    halo.enabled             = false;
                    GameManager.AddTime(Random.Range(10, 20));
                }
            }
            else if (hit.collider.tag == "Key")
            {
                hoveringOverInteractable = true;

                // Get the Halo effect component for the game object and enable it if the cursor is over it.
                halo         = (Behaviour)hit.collider.gameObject.GetComponent("Halo");
                halo.enabled = true;

                // If the action button is pressed (Defined in InputManager under Axes). E on PC X on controller.
                if (actionPressed)
                {
                    // Remove the game object from the scene.
                    Destroy(hit.collider.gameObject);
                    hoveringOverInteractable = false;
                    halo.enabled             = false;
                    hasKey = true;
                }
            }
            else if (hit.collider.tag == "Door")
            {
                hoveringOverInteractable = true;

                if (actionPressed)
                {
                    if (hit.collider.transform.localEulerAngles.y < 91.0f)
                    {
                        hit.collider.gameObject.transform.localEulerAngles += new Vector3(0.0f, 2.5f, 0.0f);
                    }
                }
            }
            else if (hit.collider.tag == "DoorExit")
            {
                hoveringOverInteractable = true;

                if (actionPressed)
                {
                    hoveringOverInteractable = false;
                    if (hasKey)
                    {
                        GameManager.gameOver = true;
                    }
                }
                // There was no ray cast intersection within the rays trace distance.
            }
            else
            {
                hoveringOverInteractable = false;
                if (halo != null)
                {
                    halo.enabled = false;
                }
            }
        }
    }