Exemplo n.º 1
0
        // 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);
            }
        }
Exemplo n.º 2
0
        // Listen for values in respective classes ( PUI_Inventory )
        private void UiUpdate(InventorySlotAmmo item, int clipLeft)
        {
            DividedBarShaderController bar = null;

            UIMappings.TryGetValue(item.Slot, out bar);

            if (ItemEquippableEvents.currentItem != null &&
                ItemEquippableEvents.currentItem.ItemDataBlock.inventorySlot.Equals(item.Slot) &&
                ItemEquippableEvents.IsCurrentItemShootableWeapon())
            {
                //Debug.Log("Ammo update event (main or sub weapon): " + "MaxAmmo: " + item.BulletClipSize + " Current ammo: " + clipLeft + " Inventory slot: " + item.Slot);
                BulletsInMag.maxAmmo = item.BulletClipSize;
                BulletsInMag.UpdateCurrentAmmo(clipLeft);
                BulletsInMag.UpdateAmmoGridDivisions();
                BulletsInMag.inventorySlot = item.Slot;
            }


            if (bar)
            {
                //Debug.Log("Ammo update event: " + "MaxAmmo: " + item.BulletClipSize + " Current ammo: " + clipLeft + " maxCap: " + item.BulletsMaxCap + " RelInPack " + item.RelInPack + " Inventory slot: " + item.Slot);
                bar.maxAmmo     = item.BulletsMaxCap;
                bar.currentAmmo = (int)(bar.maxAmmo * item.RelInPack);
                bar.SetFill(item.RelInPack);

                if (item.Slot.Equals(InventorySlot.Consumable) || item.Slot.Equals(InventorySlot.ResourcePack) || item.Slot.Equals(InventorySlot.ConsumableHeavy))
                {
                    bar.UpdatePackOrConsumableDivisions();
                }
            }
        }
Exemplo n.º 3
0
        private void SetupInventoryLinkData()
        {
            m_inventoryToAmmoDisplayMapping.Add(InventorySlot.GearStandard, transform.FindDeepChild("MainWeapon").gameObject.AddComponent <DividedBarShaderController>());
            m_inventoryToAmmoDisplayMapping.Add(InventorySlot.GearSpecial, transform.FindDeepChild("SubWeapon").gameObject.AddComponent <DividedBarShaderController>());
            m_inventoryToAmmoDisplayMapping.Add(InventorySlot.GearClass, transform.FindDeepChild("Tool").gameObject.AddComponent <DividedBarShaderController>());
            m_inventoryToAmmoDisplayMapping.Add(InventorySlot.ResourcePack, transform.FindDeepChild("Pack").gameObject.AddComponent <DividedBarShaderController>());
            m_inventoryToAmmoDisplayMapping.Add(InventorySlot.Consumable, transform.FindDeepChild("Consumable").gameObject.AddComponent <DividedBarShaderController>());
            m_inventoryToAmmoDisplayMapping.Add(InventorySlot.ConsumableHeavy, m_inventoryToAmmoDisplayMapping[InventorySlot.Consumable]);

            m_healthDisplay    = transform.FindDeepChild("HP").gameObject.AddComponent <DividedBarShaderController>();
            m_oxygenDisplay    = transform.FindDeepChild("Air").gameObject.AddComponent <DividedBarShaderController>();
            m_infectionDisplay = transform.FindDeepChild("Infection").gameObject.AddComponent <DividedBarShaderController>();

            m_numberBulletsInMagDisplay = transform.FindDeepChild("NumberedAmmo").gameObject.AddComponent <TextMeshPro>();

            m_numberBulletsInMagDisplay.lineSpacing = -30f;

            m_numberBulletsInMagDisplay.alignment          = TextAlignmentOptions.Center;
            m_numberBulletsInMagDisplay.fontSize           = 80f;
            m_numberBulletsInMagDisplay.enableWordWrapping = false;
            m_numberBulletsInMagDisplay.fontStyle          = FontStyles.Bold;
            m_numberBulletsInMagDisplay.richText           = true;
            m_numberBulletsInMagDisplay.color = DividedBarShaderController.NormalColor;
            m_bulletsInMagDisplay             = transform.FindDeepChild("Ammo").gameObject.AddComponent <DividedBarShaderController>();
        }
Exemplo n.º 4
0
 void OnDestroy()
 {
     ItemEquippableEvents.OnPlayerWieldItem    -= ItemSwitched;
     InventoryAmmoEvents.OnInventoryAmmoUpdate -= UiUpdate;
     objectiveDisplay = null;
     Health           = null;
     Infection        = null;
 }
Exemplo n.º 5
0
        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);
        }