private IProjectile InstantiateProjectile()
    {
        IProjectile projectile = _projectileFactory.Create(this, _parentObject.transform);

        projectile.Dispose();
        return(projectile);
    }
Exemple #2
0
    public GameObject Spawn(ProjectileInfo info, float angle)
    {
        Quaternion projectileRotation = MathfExt.QuaternionFromAngle2D(angle);
        GameObject projectile         = ProjectileFactory.Create(info.ProjectileType, transform.position, projectileRotation, info.CollisionLayer);

        projectile.GetComponent <IProjectileLogic>().OnInitialize(info, projectileRotation * Vector2.up);
        return(projectile);
    }
Exemple #3
0
 public void ShootAt(Vector3 targetPosition)
 {
     transform.LookAt(targetPosition);
     if (Time.time > lastAttackTime + coolDown)
     {
         ProjectileFactory.Create(opposantLayerMask, transform.position, transform.rotation);
         lastAttackTime = Time.time;
     }
 }
 public void GetAndRelease(AbstractGameObject player)
 {
     if (availableFireballs > 0)
     {
         availableFireballs--;
         FireBall newFireball = (FireBall)ProjectileFactory.Create(ProjectileType.FireBall, player, GetPosition(player));
         FireBalls.Add(newFireball);
         newFireball.CoolDown = 0;
         GameGrid.Instance.Add(newFireball);
         EventManager.Instance.TriggerFireballFire(newFireball);
     }
 }
Exemple #5
0
    public override bool Fire()
    {
        var canFire = base.Fire();

        if (!canFire)
        {
            return(false);
        }

        var arrow = _projectileFactory.Create();

        arrow.transform.position = (Vector2)_renderer.transform.position;// + Direction * .15f;
        arrow.Rigidbody.velocity = Direction * ChargedFirePower;

        return(true);
    }
        private void Shoot(Vector2 mousePos)
        {
            Vector3 vectorToTarget        = new Vector3(mousePos.x, mousePos.y, _shootingPivot.position.z) - _shootingPivot.position;
            Vector3 rotatedVectorToTarget = Quaternion.Euler(0, 0, 90f) * vectorToTarget;

            Quaternion targetRotation = Quaternion.LookRotation(forward: Vector3.forward, upwards: rotatedVectorToTarget);

            var indexToShoot = (int)(_state.PlayerState.LoadProgress / 0.33f);

            indexToShoot = Mathf.Clamp(indexToShoot, 0, 2);
            var projectileData = _projectileDataContainer.GetDataForColor(_state.PlayerState.Ammo[indexToShoot]);

            _state.PlayerState.UseAmmo(indexToShoot);
            _audioManager.PlayShot();

            var projectile = _projectileFactory.Create(projectileData, _shootingPivot.position, targetRotation);

            projectile.SetForce((mousePos - new Vector2(_shootingPivot.position.x, _shootingPivot.position.y))
                                .normalized);

            _state.PlayerState.TimeToReload = _data.ReloadSeconds;
            _state.PlayerState.LoadProgress = 0f;
        }
Exemple #7
0
 protected IProjectile FactoryRequest()
 {
     freshInstance = ProjectileFactory.Create(projectilesToPool, this);
     ProjectileCollisionListener.AddToWatchedProjectiles(freshInstance);
     return(freshInstance);
 }