Ejemplo n.º 1
0
        private static void UpdateItemInfoText(InventorySlotAmmo item, int clipLeft, RadialItem radialItem)
        {
            if (item == null)
            {
                return;
            }
            if (item.Slot == InventorySlot.GearStandard || item.Slot == InventorySlot.GearSpecial)
            {
                string ammoStatus = clipLeft + "\n----\n" + ((int)(item.BulletsMaxCap * item.RelInPack)).ToString();
                radialItem.SetInfoText(ammoStatus);
            }

            if (item.Slot == InventorySlot.GearClass)
            {
                if (!radialItem.Active)
                {
                    return;
                }
                radialItem.SetInfoText($"{(int)(item.RelInPack * 100f)}%");
            }

            if (item.Slot == InventorySlot.Consumable || item.Slot == InventorySlot.ResourcePack)
            {
                int CurrentValue = (int)(item.BulletsMaxCap * item.RelInPack) + clipLeft;
                radialItem.SetInfoText(CurrentValue.ToString());
                radialItem.Active = CurrentValue > 0;
                if (!radialItem.Active)
                {
                    radialItem.SetInfoText("");
                }
            }
        }
Ejemplo n.º 2
0
        public void AddRadialItem(string text, Action OnExecuted, out RadialItem newItem)
        {
            RadialItem item = new GameObject("RadialItem").AddComponent <RadialItem>();

            item.transform.SetParent(transform);
            item.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
            item.transform.localScale = Vector3.one;
            item.scale = m_scale;
            item.Setup(OnExecuted, VRAssets.RadialBG);
            item.SetText(text);
            newItem = item;
            radialItems.Add(item);
        }
Ejemplo n.º 3
0
 private void CheckForQuickSelectOutsideMenu()
 {
     if (m_lastHovered && m_lastHovered.Active)
     {
         GameObject hand     = GetHand();
         float      distance = Vector3.Distance(transform.position, hand.transform.position);
         if (distance > m_outsideofMenuDistance)
         {
             closest = m_lastHovered;
             Hide();
         }
     }
 }
Ejemplo n.º 4
0
        private void TryGetIcon(InventorySlotAmmo item, RadialItem radialItem)
        {
            if (m_retrievedIcons.ContainsKey(item.Slot))
            {
                return;
            }
            if (item.Slot == InventorySlot.GearMelee || item.Slot == InventorySlot.GearSpecial || item.Slot == InventorySlot.GearStandard || item.Slot == InventorySlot.GearClass)
            {
                if (PlayerBackpackManager.LocalBackpack.TryGetBackpackItem(item.Slot, out BackpackItem bp))
                {
                    if (bp == null || bp.Instance == null)
                    {
                        Log.Debug($"Got null BP or instance for {item.Slot}");
                        return;
                    }
                    ItemEquippable equippable = bp.Instance.Cast <ItemEquippable>();
                    if (equippable == null || equippable.GearIDRange == null)
                    {
                        Log.Debug("Equippable was null or GearIDRange was null when retrieving icon!");
                        return;
                    }
                    if (GearIconRendering.TryGetGearIconSprite(equippable.GearIDRange.GetChecksum(), out Sprite icon))
                    {
                        if (icon == null)
                        {
                            m_retrievedIcons[item.Slot] = null;
                            Log.Debug($"Failed to retrieve icon for {equippable.ArchetypeName}");
                            return;
                        }
                        m_retrievedIcons[item.Slot] = icon;

                        if (item.Slot == InventorySlot.GearMelee)
                        {
                            radialItem.SetIcon(icon, 1.5f);
                        }
                        else
                        {
                            radialItem.SetIcon(icon);
                        }

                        Log.Debug($"Retrieved icon for {equippable.ArchetypeName}!");
                    }
                    else
                    {
                        m_retrievedIcons[item.Slot] = null;
                        Log.Debug($"Failed to retrieve icon for {equippable.ArchetypeName}");
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void SelectClosestRadialItem()
        {
            RadialItem lastClosest     = closest;
            float      closestDistance = 9999f;

            GameObject hand = GetHand();

            if (closest != null && Vector3.Distance(closest.transform.position, hand.transform.position) > m_maxDistance * m_scale)
            {
                closest = null;
            }

            foreach (RadialItem item in radialItems)
            {
                if (item != closest)
                {
                    item.Deselect();
                }
            }

            foreach (RadialItem item in radialItems)
            {
                if (!item.Active)
                {
                    continue;
                }
                float distance = Vector3.Distance(item.transform.position, hand.transform.position);
                if (distance < closestDistance)
                {
                    closestDistance = distance;
                    closest         = item;
                }
            }

            if (closest != null && closest != lastClosest)
            {
                if (closestDistance < m_maxDistance * m_scale)
                {
                    CellSound.Post(AK.EVENTS.GAME_MENU_SELECT_GEAR, closest.transform.position);
                    SteamVR_InputHandler.TriggerHapticPulse(0.02f, 40f, 0.25f, Controllers.GetDeviceFromInteractionHandType(targetHand));
                    closest.Select();
                    m_lastHovered = closest;
                }
                else
                {
                    closest = null;
                }
            }
        }
Ejemplo n.º 6
0
        public void Hide()
        {
            if (!m_canvas.enabled)
            {
                return;
            }
            m_canvas.enabled = false;
            if (closest != null)
            {
                closest.Execute();
                closest = null;
            }
            else
            {
                Log.Debug($"Radial menu closed after {Time.time - m_lastOpenTime} seconds...");
                OnMenuClosedWithoutItem?.Invoke(Time.time - m_lastOpenTime);
            }

            foreach (RadialItem item in radialItems)
            {
                item.Hide();
            }
        }