private void StartFiring(UnitView viewComponent, UnitSide ownSide) { _fireHandle = Observable.Interval(TimeSpan.FromSeconds(_attackSpeed)) .Subscribe(_ => { Fire(ownSide, viewComponent); }).AddTo(viewComponent); _isDisposed = false; }
public void Configure(UnitView viewComponent, UnitSide unitSide, float attackSpeed) { _unitView = viewComponent; _unitSide = unitSide; _attackSpeed = attackSpeed; _signalBus.Subscribe <GameStateChangeSignal>(GameStateChanged); }
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() }); } }
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); }