예제 #1
0
        protected override void OnInit()
        {
            _player.QuickSlot.OnInputChanged += newId => {
                var index = _player.QuickslotInventory.ConvertQuickSlotIDToIndex(newId);
                var item  = _player.QuickslotInventory.GetInventoryItem(index);

                // remove all old connectionss
                if (_item != null)
                {
                    item._shootData.OnAvailableBulletsChange -= newCount => { UpdateAvailableAmmo(newCount); };
                    item._shootData.OnReloadTimeChanged      -= (currentReloadTime, reloadTime) => { UpdateReloadTime(currentReloadTime, reloadTime); };
                }


                _item = null;

                if (item != null && item.CanShoot)
                {
                    _item = item;

                    // update available ammo
                    UpdateAvailableAmmo(item._shootData.AvailableBullets);
                    item._shootData.OnAvailableBulletsChange += newCount => { UpdateAvailableAmmo(newCount); };
                    item._shootData.OnReloadTimeChanged      += (currentReloadTime, reloadTime) => { UpdateReloadTime(currentReloadTime, reloadTime); };

                    // update max ammo
                    var gunStats = new GunDataController().LoadGun(_item.ID).WeaponStats;
                    UpdateMaxAmmo(gunStats.ClipSize);
                }
                else
                {
                    // hide all ammo
                    Hide();
                }
            };
        }
예제 #2
0
    // *************** PUBLIC **************

    public void Init()
    {
        _gunRefs        = new Dictionary <string, Gun>();
        _dataController = new GunDataController();
    }