public void UpdateAir(float val) { if (m_oxygenDisplay) { if (val < .95f && m_currentState == WatchState.Inventory) { m_oxygenDisplay.SetFill(val); m_oxygenDisplay.UpdateFill((int)(val * 100f)); m_oxygenDisplay.ToggleRendering(true); if (val < 0.5) { m_oxygenDisplay.SetColor(Color.Lerp(Color.red, m_normalOxygenCol, val * 1.6f)); } else { m_oxygenDisplay.SetColor(Color.cyan); } } else { m_oxygenDisplay.ToggleRendering(false); } } }
public void UpdateHealth(float health) { if (m_healthDisplay) { m_healthDisplay.UpdateFill((int)(health * 100f)); m_healthDisplay.SetColor(Color.Lerp(m_normalHealthCol, m_normalHealthCol * 1.8f, 1 - health)); } }
public void UpdateInfection(float infection) { if (m_infectionDisplay) { if (infection < 0.01f) { m_infectionDisplay.ToggleRendering(false); } else if (m_currentState == WatchState.Inventory) { m_infectionDisplay.ToggleRendering(true); m_infectionDisplay.UpdateFill((int)(infection * 100f)); m_infectionDisplay.SetFill(infection); m_infectionDisplay.SetColor(Color.Lerp(m_normalInfectionCol, m_normalInfectionCol * 1.6f, infection)); } } }
private void Setup() { ItemEquippableEvents.OnPlayerWieldItem += ItemSwitched; InventoryAmmoEvents.OnInventoryAmmoUpdate += UiUpdate; transform.SetParent(Controllers.offhandController.transform); transform.localPosition = handOffset; transform.localRotation = handRotationOffset; inventoryMeshes = transform.FindChildRecursive("Inventory_UI").GetComponentsInChildren <MeshRenderer>(); objectiveParent = transform.FindChildRecursive("WardenObjective").gameObject; RectTransform watchObjectiveTransform = objectiveParent.GetComponent <RectTransform>(); objectiveDisplay = objectiveParent.AddComponent <TextMeshPro>(); objectiveDisplay.enableAutoSizing = true; objectiveDisplay.fontSizeMin = 18; objectiveDisplay.fontSizeMax = 36; StartCoroutine(SetRectSize(watchObjectiveTransform, new Vector2(42, 34f))); objectiveDisplay.color = DividedBarShaderController.normalColor * 1.35f; UIMappings.Add(InventorySlot.GearStandard, transform.FindChildRecursive("MainWeapon").gameObject.AddComponent <DividedBarShaderController>()); UIMappings.Add(InventorySlot.GearSpecial, transform.FindChildRecursive("SubWeapon").gameObject.AddComponent <DividedBarShaderController>()); UIMappings.Add(InventorySlot.GearClass, transform.FindChildRecursive("Tool").gameObject.AddComponent <DividedBarShaderController>()); UIMappings.Add(InventorySlot.ResourcePack, transform.FindChildRecursive("Pack").gameObject.AddComponent <DividedBarShaderController>()); UIMappings.Add(InventorySlot.Consumable, transform.FindChildRecursive("Consumable").gameObject.AddComponent <DividedBarShaderController>()); UIMappings.Add(InventorySlot.ConsumableHeavy, UIMappings[InventorySlot.Consumable]); Health = transform.FindChildRecursive("HP").gameObject.AddComponent <DividedBarShaderController>(); Infection = transform.FindChildRecursive("Infection").gameObject.AddComponent <DividedBarShaderController>(); BulletsInMag = transform.FindChildRecursive("Ammo").gameObject.AddComponent <DividedBarShaderController>(); Health.SetColor(new Color(0.33f, 0f, 0f)); Infection.SetColor(new Color(0.533f / 3f, 1 / 3f, 0.8f / 3f)); Health.maxAmmo = 100; Health.currentAmmo = 100; Infection.maxAmmo = 100; Infection.currentAmmo = 0; Health.UpdateShaderVals(5, 2); Infection.UpdateShaderVals(5, 2); }