Ejemplo n.º 1
0
        void UpdateList()
        {
            IWeaponsHolder weapons = inventory.Weapons;
            IAmmoHolder    ammo    = inventory.Ammo;

            List <WeaponIndex> available = weapons.GetAvailableWeaponsInGame();
            int availableAmount          = available.Count;

            if (availableAmount == 0)
            {
                weaponSelectionObj.SetActive(false);
                noAvailableWeaponsObj.SetActive(true);
            }
            else
            {
                weaponSelectionObj.SetActive(true);
                noAvailableWeaponsObj.SetActive(false);
            }

            int counter = 0;

            foreach (WeaponButton b in buttons.Values)
            {
                if (counter < availableAmount)
                {
                    IWeaponItem w = weapons.Get(available[counter]);
                    IAmmoItem   a = ammo.Get(w.AmmoType);

                    //if (!w.IsAmmo || (w.IsAmmo && a.CurrentAmount > 0))
                    {
                        b.Set(w, a, SelectWeapon, ammoList.HighlightAmmo);
                    }
                    //else
                    //{
                    //    b.gameObject.SetActive(false);
                    //}
                }
                else
                {
                    // disable other buttons
                    b.gameObject.SetActive(false);
                }

                counter++;
            }
        }
Ejemplo n.º 2
0
        void UpdateWheel()
        {
            if (inventory == null)
            {
                inventory = GameController.Instance.Inventory;
            }

            IWeaponsHolder weapons = inventory.Weapons;
            IAmmoHolder    ammo    = inventory.Ammo;

            List <WeaponIndex> available = weapons.GetAvailableWeaponsInGame();
            int availableAmount          = available.Count;

            GameObject wheel = GetWheel(availableAmount);

            if (wheel == null)
            {
                return;
            }

            int counter = 0;

            var bs = wheel.GetComponentsInChildren <WeaponWheelButton>(true);

            foreach (WeaponWheelButton b in bs)
            {
                b.SetColors(defaultColor, highlitedColor, disabledColor);

                if (counter < availableAmount)
                {
                    IWeaponItem w = weapons.Get(available[counter]);
                    IAmmoItem   a = ammo.Get(w.AmmoType);

                    b.Set(w, a, Select, Highlight, Unhighlight);
                }
                else
                {
                    // disable buttons without weapon
                    b.Disable();
                }

                counter++;
            }
        }