示例#1
0
        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);
        }
示例#2
0
        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);
        }