Esempio n. 1
0
        private void StartFiring(UnitView viewComponent, UnitSide ownSide)
        {
            _fireHandle = Observable.Interval(TimeSpan.FromSeconds(_attackSpeed))
                          .Subscribe(_ => { Fire(ownSide, viewComponent); }).AddTo(viewComponent);

            _isDisposed = false;
        }
Esempio n. 2
0
 public void Configure(UnitView viewComponent, UnitSide unitSide, float attackSpeed)
 {
     _unitView    = viewComponent;
     _unitSide    = unitSide;
     _attackSpeed = attackSpeed;
     _signalBus.Subscribe <GameStateChangeSignal>(GameStateChanged);
 }
Esempio n. 3
0
 private void Fire(UnitSide ownSide, UnitView view)
 {
     if (Physics.Raycast(view.Position, view.Transform.forward, out var hit, _gameSettings.WeaponRange,
                         Constants.Constants.UnitLayer))
     {
         _signalBus.Fire(new UnitHitSignal
         {
             OwnSide = ownSide,
             UnitId  = hit.collider.gameObject.GetInstanceID()
         });
     }
 }
Esempio n. 4
0
 public UnitController(UnitModel unitModel,
                       UnitView unitView,
                       UnitSide unitSide,
                       UnitWeapon unitWeapon,
                       SignalBus signalBus,
                       GameSettings gameSettings,
                       HitEffect hitEffect)
 {
     _unitModel    = unitModel;
     _unitView     = unitView;
     _unitSide     = unitSide;
     _unitWeapon   = unitWeapon;
     _signalBus    = signalBus;
     _gameSettings = gameSettings;
     _hitEffect    = hitEffect;
     _hitEffect.transform.parent = _unitView.transform;
     _unitModel.Configure();
     _unitView.Configure(_unitModel);
     _unitWeapon.Configure(unitView, unitSide, _unitModel.AttackSpeed);
 }