Ejemplo n.º 1
0
 private void Start()
 {
     _headTitleContainer      = GameObject.FindGameObjectWithTag("HeadTitle");
     _playerHeadTitle         = _headTitleContainer.GetComponent <TextMeshProUGUI>();
     _playerHeadTitle.enabled = false;
     _inventoryControl        = _player.GetComponent <InventoryControl>();
     _menuHandler             = GameObject.FindGameObjectWithTag("EventSystem").GetComponent <MainMenuHandler>();
     _playerStatus            = _player.GetComponent <PlayerStatusHandler>();
     ItemUtil.InitializeMatcher();
     _ammoBarTransform = _ammoBar.GetComponent <RectTransform>();
     UpdateAmmoBar();
 }
Ejemplo n.º 2
0
        private void UpdateAmmoBar()
        {
            _needRecalcAmmoBar = false;
            _currentWeapon     = _inventoryControl.CurrentItem;

            if (_currentWeapon != null)
            {
                if (_currentWeapon.GameItem.activeSelf && _magazine > 0 && _triggeredEvent.Equals(EventType.AMMO_DISCHARGE))
                {
                    RederAmmoBarWithinShots(1);
                    _triggeredEvent = EventType.INFO;
                }
                else if (_triggeredEvent.Equals(EventType.AMMO_RELOAD))
                {
                    RenderFullAmmoBar();
                    _triggeredEvent = EventType.INFO;
                }
                else if (_currentWeapon.GameItem.activeSelf && _magazine == 0)
                {
                    _magazine = _currentWeapon.GameItem.GetComponent <IDamagable>().Magazine;
                    var type = ItemUtil.DetermineMagazineTypeByWeapon(_currentWeapon);
                    _ammoMaxForCurrentWeapon = (int)type;
                    RenderFullAmmoBar();
                }
                else if (_currentWeapon.GameItem.activeSelf)
                {
                    _magazine = _currentWeapon.GameItem.GetComponent <IDamagable>().Magazine;
                    var type = ItemUtil.DetermineMagazineTypeByWeapon(_currentWeapon);
                    _ammoMaxForCurrentWeapon = (int)type;
                    if (_ammoMaxForCurrentWeapon != 0)
                    {
                        RenderAmmoBarWithinMagazine();
                    }
                }

                if (!_currentWeapon.GameItem.activeSelf)
                {
                    RenderMinAmmoBar();
                }
            }
            else if (_currentWeapon == null)
            {
                RenderMinAmmoBar();
            }
        }