Exemplo n.º 1
0
 void Update()
 {
     FadeImage.color = UIFader.GetUIColor();
     if (UIFader.isFaded)
     {
         FadeImage.raycastTarget = false;
     }
 }
Exemplo n.º 2
0
    void Update()
    {
        if (inputControl.HasInputs())
        {
            UseItemKey = inputControl.GetInput("Flashlight");
        }

        CanReload = oilPercentage < canReloadPercent;

        if (Inventory.CheckItemIDInventory(lanternInventoryID) && switcher.currentLightObject == switcherID)
        {
            if (Input.GetKeyDown(UseItemKey) && !anim.isPlaying && !isPressed)
            {
                if (!isSelected && switcher.currentItem != switcherID)
                {
                    switcher.selectItem(switcherID);
                }
                else
                {
                    Deselect();
                }
                isPressed = true;
            }
            else if (isPressed)
            {
                isPressed = false;
            }
        }

        if (isSelected)
        {
            if (oilPercentage > 0)
            {
                oilPercentage -= Time.deltaTime * (100 / oilLifeInSec);

                if (oilPercentage <= reductionFactor)
                {
                    reduceIntensity -= lightReductionRate / 100;
                    reductionFactor -= lightReductionRate;
                    StartCoroutine(Reduce());

                    int spriteInt = Mathf.RoundToInt(reductionFactor + lightReductionRate);
                    currentSprite = spritePrefix + spriteInt;
                }
            }

            OilSprite.sprite = Resources.Load <Sprite>("Icons/OilPercentagle/" + currentSprite);
        }
        else
        {
            if (!isSelecting)
            {
                LanternLight.gameObject.SetActive(false);
                LanternGO.SetActive(false);
            }
        }

        if (showSprite)
        {
            OilSprite.color = UIFader.GetUIColor();
        }

        oilPercentage   = Mathf.Clamp(oilPercentage, 0, 100);
        reductionFactor = Mathf.Clamp(reductionFactor, 0, 100);
        LanternLight.transform.GetChild(0).GetComponent <MeshRenderer>().material.SetColor("_TintColor", FlameTint);
    }
Exemplo n.º 3
0
    void Update()
    {
        if (inputManager.HasInputs())
        {
            UseItemKey = inputManager.GetInput("Flashlight");
        }

        CanReload = batteryPercentage < canReloadPercent;

        if (inventory.CheckItemIDInventory(FlashlightInventoryID) && !isReloading && switcher.currentLightObject == switcherID)
        {
            if (Input.GetKeyDown(UseItemKey) && !AnimationComp.isPlaying && !isPressed)
            {
                if (!isSelected && switcher.currentItem != switcherID)
                {
                    switcher.selectItem(switcherID);
                }
                else
                {
                    Deselect();
                }

                isPressed = true;
            }
            else if (isPressed)
            {
                isPressed = false;
            }
        }

        if (isSelected)
        {
            BatterySprite.color = UIFader.GetUIColor();
        }

        if (isOn)
        {
            LightObject.enabled = true;
            batteryPercentage  -= Time.deltaTime * (100 / batteryLifeInSec);
        }
        else
        {
            LightObject.enabled = false;
        }

        batteryPercentage = Mathf.Clamp(batteryPercentage, 0, 100);

        if (batteryPercentage > 95.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_100;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 1, Time.deltaTime);
        }
        else if (batteryPercentage <= 95.0f && batteryPercentage > 90.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_95;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.95f, Time.deltaTime);
        }
        else if (batteryPercentage <= 90.0f && batteryPercentage > 85.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_90;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.9f, Time.deltaTime);
        }
        else if (batteryPercentage <= 85.0f && batteryPercentage > 80.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_85;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.85f, Time.deltaTime);
        }
        else if (batteryPercentage <= 80.0f && batteryPercentage > 75.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_80;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.8f, Time.deltaTime);
        }
        else if (batteryPercentage <= 75.0f && batteryPercentage > 70.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_75;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.75f, Time.deltaTime);
        }
        else if (batteryPercentage <= 70.0f && batteryPercentage > 65.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_70;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.7f, Time.deltaTime);
        }
        else if (batteryPercentage <= 65.0f && batteryPercentage > 60.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_65;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.65f, Time.deltaTime);
        }
        else if (batteryPercentage <= 60.0f && batteryPercentage > 55.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_60;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.6f, Time.deltaTime);
        }
        else if (batteryPercentage <= 55.0f && batteryPercentage > 50.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_55;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.55f, Time.deltaTime);
        }
        else if (batteryPercentage <= 50.0f && batteryPercentage > 45.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_50;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.5f, Time.deltaTime);
        }
        else if (batteryPercentage <= 45.0f && batteryPercentage > 40.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_45;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.45f, Time.deltaTime);
        }
        else if (batteryPercentage <= 40.0f && batteryPercentage > 35.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_40;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.4f, Time.deltaTime);
        }
        else if (batteryPercentage <= 35.0f && batteryPercentage > 30.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_35;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.35f, Time.deltaTime);
        }
        else if (batteryPercentage <= 30.0f && batteryPercentage > 25.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_30;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.3f, Time.deltaTime);
        }
        else if (batteryPercentage <= 25.0f && batteryPercentage > 20.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_25;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.25f, Time.deltaTime);
        }
        else if (batteryPercentage <= 20.0f && batteryPercentage > 15.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_20;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.2f, Time.deltaTime);
        }
        else if (batteryPercentage <= 15.0f && batteryPercentage > 10.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_15;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.15f, Time.deltaTime);
        }
        else if (batteryPercentage <= 10.0f && batteryPercentage > 5.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_10;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.1f, Time.deltaTime);
        }
        else if (batteryPercentage <= 5.0f && batteryPercentage > 1.0f)
        {
            BatterySprite.sprite  = BatterySprites.Battery_5;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0.05f, Time.deltaTime);
        }
        else if (batteryPercentage <= 1.0f)
        {
            BatterySprite.color   = Color.red;
            BatterySprite.sprite  = BatterySprites.Battery_0_red;
            LightObject.intensity = Mathf.Lerp(LightObject.intensity, 0, Time.deltaTime * 2);
        }
    }