Beispiel #1
0
        /// <summary>
        /// Update inventory slots to match the player's actual available
        /// weapons. Also called by the ShopScript when the player purchases
        /// a weapon.
        /// </summary>
        public void updateWeaponSlots()
        {
            if (playerShoot == null)
            {
                // try to find it again
                playerShoot = GameObject.FindGameObjectWithTag("Player")?.GetComponentInChildren <PlayerShoot>(true);
            }

            if (playerShoot == null || playerShoot.guns == null)
            {
                return;
            }

            // filled slots
            for (int i = 0; i < playerShoot.guns.Count; ++i)
            {
                updateWeaponSlot(i);
            }
            // empty slots
            for (int i = playerShoot.guns.Count; i < inventorySlots.Count; ++i)
            {
                PlayerInventorySlot p = inventorySlots[i];
                p.sprite.color = new Color(0, 0, 0, 0);
                p.infoBlock.SetActive(false);
            }
            updateSelectedGrid();
        }
Beispiel #2
0
        /// <summary>
        /// Update a specific inventory slot.
        /// </summary>
        /// <param name="slot">associated weapon slot</param>
        private void updateWeaponSlot(int slot)
        {
            PlayerInventorySlot p = inventorySlots[slot];
            WeaponStats         w = playerShoot.guns[slot].GetComponentInChildren <WeaponStats>(true);

            p.sprite.sprite = w.image;
            p.sprite.color  = new Color(1, 1, 1, 1);
            p.name.text     = w.fullName;
            p.family.text   = $"{w.actionToString()} {w.weaponFamily}";
            // Strength, jitter, delay
            p.statsLeft.text = $"Strength: {w.strength}\nDeviation: {w.deviation}\nDelay: {w.fireDelay}";
            // Projectile type, bullet cost, value (modify based on what the shopkeep will pay for it)
            p.statsRight.text = $"{w.projectileTypeToString()}\nBullet Cost: {w.bulletCost}\nValue: {w.buybackPrice}";
        }