예제 #1
0
    // Update is called once per frame
    private void Update()
    {
        //if the player is tired, show the overlay
        if (vitals.getEnergy() < 50.0f)
        {
            inTiredState = true;

            float calcAlpha = (1.0f / 50.0f) * (50.0f - vitals.getEnergy());

            energyOverlay.color = new Color(energyOverlay.color.r, energyOverlay.color.g, energyOverlay.color.b, calcAlpha);

            //lower the player speed based on the energy
            playerController.modifyNormalSpeed(normalSpeed - ((50 - vitals.getEnergy()) / 22));
            playerController.modifySprintSpeed(sprintSpeed - ((50 - vitals.getEnergy()) / 22));
        }
        else if (vitals.getEnergy() >= 50.0f && inTiredState)
        {
            inTiredState = false;

            //reset some values back to their original state
            playerController.modifyNormalSpeed(normalSpeed);
            playerController.modifySprintSpeed(sprintSpeed);
            vitals.setEnergy(50.0f, true);

            destroyScript();
        }

        //if the player is hyper
        if (vitals.getEnergy() > 50.0f)
        {
            inHyperState = true;

            FPPCamera.fieldOfView = initialFOV + vitals.getEnergy() / 8.0f;

            //increase the player speed as they get more hyper
            playerController.modifyNormalSpeed(normalSpeed + (vitals.getEnergy() / 12));
            playerController.modifySprintSpeed(sprintSpeed + (vitals.getEnergy() / 12));

            //slowly lower the speed to a normal value
            vitals.setEnergy(((50.0f / reduceEnergySpeed) * Time.deltaTime) * -1);
        }
        else if (vitals.getEnergy() <= 50.0f && inHyperState)
        {
            inHyperState = false;

            //reset some values back to their original state
            FPPCamera.fieldOfView = initialFOV;
            playerController.modifyNormalSpeed(normalSpeed);
            playerController.modifySprintSpeed(sprintSpeed);
            vitals.setEnergy(50.0f, true);

            destroyScript();
        }
    }
예제 #2
0
    public void useItem(Item item, bool fromHand)
    {
        Debug.Log("Using Item: " + item + " - " + fromHand);
        switch (item.itemID)
        {
        //Add cases for each item ID that has an effect when consumed.
        case 0:
        {
            print("Drunk dat drink");
            //Add stat increases here
            vitals.setEnergy(30);         //increases energy levels by 30

            audioSource.PlayOneShot(burpSound, 1.0f);

            break;
        }

        case 1:
        {
            print("Drunk dat alc");
            //Add stat increases here
            vitals.setSoberness(-30);         //lowers your soberness levels by 30

            audioSource.PlayOneShot(burpSound, 1.0f);

            break;
        }

        case 2:
        {
            print("Where did you get this?");
            //Add stat increases here
            break;
        }
        }

        //When the item is used, and is 'Destroyed when used', destroys the item
        if (item.destroyWhenUsed == true)
        {
            if (fromHand == true)
            {
                Destroy(GameObject.Find("FPPCamera").GetComponent <PickupDrop>().itemInHand.gameObject);
                itemHolding = -1;
            }
            else
            {
                updateItems(item.itemID, false);
            }
        }
    }
예제 #3
0
    private void resetPlayer()
    {
        if (!alreadyResetting)
        {
            alreadyResetting = true;

            Debug.Log("Knocked out sequence finished.");

            audioSource.PlayOneShot(bird, 1.0f);

            //sets the player position to the nearest respawn point
            player.transform.position = findClosedPoint().transform.position;
            player.transform.rotation = Quaternion.Euler(0, 0, 0);

            //Freezes all the rotation axis
            player.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;

            switch (CurrentMode)
            {
            case Mode.Dead:
                //gets a reference to the health that's attached to the player and then reset the health
                vitals.setHealth(100);
                break;

            case Mode.Drunk:
                vitals.setSoberness(100.0f, true);
                break;

            case Mode.Exhausted:
                vitals.setEnergy(50);
                break;

            default:
                break;
            }
            vitals.setKnockedOutState(false);
        }

        Transform fadeTopPos    = fadeTop.transform;
        Transform fadeBottomPos = fadeBottom.transform;

        //Moves the top black overlay down to the centre
        if (fadeTop.GetComponent <RectTransform>().localPosition.y < 1200)
        {
            fadeTop.transform.position = Vector3.Lerp(fadeTopPos.position, new Vector3(fadeTopPos.position.x, fadeTopPos.position.y + 4.0f), 100.0f * Time.deltaTime);
        }

        //moves the bottom black overlay up to the centre
        if (fadeBottom.GetComponent <RectTransform>().localPosition.y > -1200)
        {
            fadeBottom.transform.position = Vector3.Lerp(fadeBottomPos.position, new Vector3(fadeBottomPos.position.x, fadeBottomPos.position.y - 4.0f), 100.0f * Time.deltaTime);
        }
        else
        {
            //re-enables the disabled scripts
            playerController.enabled = true;
            CamMouseLook.enabled     = true;

            //since the reset seqence has finished, destroy the script
            alreadyResetting = false;
            destroyScript();
        }
    }