Example #1
0
    private void Update()
    {
        if (Time.timeScale == 0)
        {
            if (footsteps.isPlaying)
            {
                footsteps.Stop();
            }
            return;
        }
        // Alcohol effects
        float alcohol = PlayerStats.alcohol;

        weaponCamera.BlockCount = 512.0f - (alcohol / PlayerStats.GetAlcoholLimit()) * 384.0f;

        tick += Time.deltaTime;

        if (tick > 0.25f)
        {
            tick -= 0.25f;

            if (PlayerStats.healTime > 0.0f)
            {
                PlayerStats.Heal(healPerTick);
            }
            PlayerStats.RemoveHealTime(0.25f);
        }

        // At one point I want to check the type of the ground and if the player is grounded.
        if (character.velocity.magnitude >= 1.0f && !footsteps.isPlaying)
        {
            footsteps.Play();
        }
        else if (character.velocity.magnitude < 1.0f && footsteps.isPlaying)
        {
            footsteps.Stop();
        }

        // I update the randomness here.
        FakeControls.Update();
        FakeControls.SetRandomness(alcohol / PlayerStats.GetAlcoholLimit() * 0.5f);
    }
Example #2
0
    void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }

        float horizontalRotation = FakeControls.GetMouseX();

        transform.Rotate(0.0f, horizontalRotation * rotationSpeed, 0.0f);

        verticalRotation -= FakeControls.GetMouseY();
        verticalRotation  = Mathf.Clamp(verticalRotation, -verticalRotationLimit, verticalRotationLimit);
        Camera.main.transform.localRotation = Quaternion.Euler(verticalRotation * rotationSpeed, 0.0f, 0.0f);

        Vector3 movement = new Vector3(FakeControls.GetHorizontal(), 0.0f, FakeControls.GetVertical());

        controller.Move(new Vector3(0.0f, -gravity * Time.deltaTime, 0.0f));
        controller.Move(transform.TransformDirection(movement) * Time.deltaTime * speed);
    }
Example #3
0
    private void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }

        float bobAmount = Mathf.Abs(FakeControls.GetVertical()) + Mathf.Abs(FakeControls.GetHorizontal());

        bobAmount = Mathf.Clamp01(bobAmount);

        bobTimer += maxHeadBobSpeed * bobAmount;
        if (bobTimer > 2 * Mathf.PI)
        {
            bobTimer -= 2 * Mathf.PI;
        }

        if (bobAmount == 0)
        {
            if (bobTimer < -0.05f)
            {
                bobTimer += maxHeadBobSpeed * Time.deltaTime;
            }
            else if (bobTimer > 0.05f)
            {
                bobTimer -= maxHeadBobSpeed * Time.deltaTime;
            }
            else
            {
                bobTimer = 0.0f;
            }
        }

        Vector3 newPos = originalPos + Vector3.up * Mathf.Sin(bobTimer) * maxHeadOffset;;

        transform.localPosition = newPos;
    }