private void ReturnProjectile(ProjectileView view, WeaponType type) { UnsubscribeProjectile(view); view.GetRigidbody().velocity = Vector3.zero; view.Hide(); Observable.Timer(TimeSpan.FromSeconds(0.5f)).Subscribe(_ => { var poolManager = CoreManager.Instance.GetData <PoolManager>(); poolManager.ReturnItem <WeaponType>((int)type, view); _fireRate[type]--; EventHolder <GameEventType> .Dispatcher.Broadcast(GameEventType.AmmoChange, type, _fireRate[type]); }).AddTo(_disposable); }
private void LaunchProjectile(ProjectileView view, Vector3 direction, IWeapon weapon, float force) { view.Init(weapon.GetWeaponType()); SubscribeProjectile(view); var rigid = view.GetRigidbody(); rigid.AddForce(direction * force, ForceMode.Impulse); var data = view.gameObject.AddComponent <CollisionData>(); data.Type = weapon.GetWeaponType(); data.Damage = weapon.GetDamage(); view.StartTimer(); IncreaseFireRateValue(weapon.GetWeaponType()); _projectiles.Add(view); }