コード例 #1
0
        private IEnumerator LoadWeaponProcess()
        {
            Player.Entities[0].Tags.Add(EntityTags.PerformingCommand);
            yield return(LowerWeapon(false));

            _state = State.Reloading;
            UIChargeCircle.ManualStart(_current.Ammo.Template.ReloadText);
            var reloadPerAmmo = _current.Ammo.ReloadSpeed / _current.Ammo.Amount.MaxValue;
            var totalAmmo     = _current.Ammo.Amount.MaxValue - _current.Ammo.Amount.Value;
            int current       = 0;

            while (true)
            {
                if (_current == null || _state != State.Reloading)
                {
                    break;
                }
                current++;
                UIChargeCircle.ManualSetPercent((float)current / totalAmmo);
                if (!_current.Ammo.TryLoadOneAmmo(Player.Entities[0]))
                {
                    break;
                }
                yield return(reloadPerAmmo);
            }
            UIChargeCircle.StopCharge();
            if (_state == State.None || _state == State.Reloading)
            {
                yield return(RaiseWeapon());
            }
        }
コード例 #2
0
 public override bool TryComplete(float dt)
 {
     if (base.TryComplete(dt) || _ammo == null)
     {
         return(true);
     }
     if (!Graph.GetVariable <bool>(GraphVariables.Reloading))
     {
         return(true);
     }
     if (_reloadTimer > 0)
     {
         _reloadTimer -= dt;
         return(false);
     }
     _current++;
     UIChargeCircle.ManualSetPercent((float)_current / _totalAmmo);
     _reloadTimer = _reloadPerAmmo;
     if (!World.Get <AmmoSystem>().TryLoadOneAmmo(Graph.Entity, _ammo))
     {
         return(true);
     }
     return(false);
 }