// Handle selection effect and grid updates private void ItemSwitched(ItemEquippable item) { DividedBarShaderController UIBar = null; foreach (DividedBarShaderController d in UIMappings.Values) { d.SetUnselected(); } UIMappings.TryGetValue(item.ItemDataBlock.inventorySlot, out UIBar); if (UIBar) { UIBar.SetSelected(); } if (ItemEquippableEvents.IsCurrentItemShootableWeapon()) { //Debug.Log("Item changed event: " + "MaxAmmo: " + item.GetMaxClip() + " Current ammo: " + item.GetCurrentClip() + " Inventory slot: " + item.ItemDataBlock.inventorySlot); BulletsInMag.maxAmmo = item.GetMaxClip(); BulletsInMag.currentAmmo = item.GetCurrentClip(); BulletsInMag.UpdateAmmoGridDivisions(); BulletsInMag.inventorySlot = item.ItemDataBlock.inventorySlot; } else { BulletsInMag.currentAmmo = 0; BulletsInMag.UpdateShaderVals(1, 1); } }
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); }
private void UpdateBulletGridDivisions(ItemEquippable item) { if (ItemEquippableEvents.IsCurrentItemShootableWeapon()) { if (!VRConfig.configUseNumbersForAmmoDisplay.Value) { m_bulletsInMagDisplay.MaxValue = item.GetMaxClip(); m_bulletsInMagDisplay.CurrentValue = item.GetCurrentClip(); m_bulletsInMagDisplay.UpdateAmmoGridDivisions(); } } else { m_bulletsInMagDisplay.CurrentValue = 0; m_bulletsInMagDisplay.UpdateShaderVals(1, 1); m_numberBulletsInMagDisplay.text = ""; m_numberBulletsInMagDisplay.ForceMeshUpdate(false); } }
private void SetInitialPlayerStatusValues() { m_healthDisplay.SetColor(m_normalHealthCol); m_infectionDisplay.SetColor(m_normalInfectionCol); m_oxygenDisplay.SetColor(m_normalOxygenCol); m_healthDisplay.MaxValue = 100; m_healthDisplay.CurrentValue = 100; m_oxygenDisplay.MaxValue = 100; m_oxygenDisplay.CurrentValue = 100; m_infectionDisplay.MaxValue = 100; m_infectionDisplay.CurrentValue = 0; m_healthDisplay.UpdateShaderVals(5, 2); m_infectionDisplay.UpdateShaderVals(5, 2); m_oxygenDisplay.UpdateShaderVals(5, 2); UpdateAir(100f); }