Пример #1
0
    /// <summary>
    /// Shoots bullets with identical time between each bullet
    /// </summary>
    /// <param name="instance"></param>
    /// <param name="shooter"></param>
    /// <param name="direction"></param>
    /// <returns></returns>
    private IEnumerator CoShootBullets(WeaponInstance instance, WeaponShooterBase shooter)
    {
        for (int i = 0; i < ClusterCount; i++)
        {
            foreach (Projectile projectile in AmmunitionList)
            {
                //Decide the origin of each bullet
                Vector2 position = ForceLinear ? fireingPoint : shooter.GetProjectilesSpawnPoint();

                Projectile newAmmo = Instantiate(
                    original: projectile,
                    position: position,
                    rotation: Quaternion.identity
                    );

                newAmmo.Direction = ForceLinear ? fireingDirectionOrigin : shooter.GetCurrentAimingDirection();

                WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();
                hurtbox.Shooter = shooter;
                hurtbox.Weapon  = instance;
            }

            //Waiting for next bullet
            yield return(new WaitForSeconds(WaitTime));
        }
    }
Пример #2
0
 protected override void OnFire(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction)
 {
     fireingPointOrigin     = shooter.gameObject.transform.position;
     horizontalDirection    = shooter.gameObject.GetComponent <Flippable>().Direction;
     fireingDirectionOrigin = shooter.GetCurrentAimingDirection();
     shooter.StartCoroutine(CoShootBullets(instance, shooter));
 }
Пример #3
0
    protected override void OnFire(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction)
    {
        for (int i = 0; i < BlastCount; i++)
        {
            Vector3 newAmmoPosition;
            if (direction == Vector2.right || direction == Vector2.left)
            {
                newAmmoPosition = new Vector3
                                      (shooter.GetProjectilesSpawnPoint().x,
                                      shooter.GetProjectilesSpawnPoint().y + Height / BlastCount * i);
            }
            else
            {
                newAmmoPosition = new Vector3
                                      (shooter.GetProjectilesSpawnPoint().x + (Height / BlastCount * i - Height / 2),
                                      shooter.GetProjectilesSpawnPoint().y);
            }

            Projectile newAmmo = Instantiate(
                original: Ammunition,
                position: newAmmoPosition,
                rotation: Quaternion.identity
                );

            newAmmo.Direction = direction;

            WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();
            hurtbox.Shooter = shooter;
            hurtbox.Weapon  = instance;
        }
    }
Пример #4
0
    /// <summary>
    /// Shoots bullets with identical time between each bullet
    /// </summary>
    /// <param name="instance"></param>
    /// <param name="shooter"></param>
    /// <param name="direction"></param>
    /// <returns></returns>
    private IEnumerator CoShootBullets(WeaponInstance instance, WeaponShooterBase shooter)
    {
        for (int i = 0; i < ClusterCount; i++)
        {
            //Decide the origin of each bullet
            Vector2 position = ForceLinear ? fireingPointOrigin : shooter.GetProjectilesSpawnPoint();

            Projectile newAmmo = Instantiate(
                original: Ammunition,
                position: position,
                rotation: Quaternion.identity
                );


            Vector2 Aim = ForceLinear ? fireingDirectionOrigin : shooter.GetCurrentAimingDirection();


            // Decides how much each bullet should ne rotated
            if (Aim == Vector2.left)
            {
                newAmmo.transform.Rotate(((90f / ((float)ClusterCount - 1)) * i));
            }
            else if (Aim == Vector2.right)
            {
                newAmmo.transform.Rotate(((90f / ((float)ClusterCount - 1)) * i) * -1);
            }
            else if (Aim == Vector2.up)
            {
                if (horizontalDirection == Direction1D.Left)
                {
                    newAmmo.transform.Rotate(((180f / ((float)ClusterCount - 1)) * i) * -1 + 90);
                }
                else
                {
                    newAmmo.transform.Rotate(((-180f / ((float)ClusterCount - 1)) * i) * -1 - 90);
                }
            }
            else if (Aim == Vector2.down)
            {
                if (horizontalDirection == Direction1D.Left)
                {
                    newAmmo.transform.Rotate(((-180f / ((float)ClusterCount - 1)) * i) * -1 + 90);
                }
                else
                {
                    newAmmo.transform.Rotate(((180f / ((float)ClusterCount - 1)) * i) * -1 - 90);
                }
            }

            WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();
            hurtbox.Shooter = shooter;
            hurtbox.Weapon  = instance;

            //Waiting for next bullet
            yield return(new WaitForSeconds(WaitTime));
        }
    }
Пример #5
0
    /// <summary>
    /// Fires the weapon from the provided weapon shooter
    /// </summary>
    public void Fire(WeaponInstance instance, WeaponShooterBase shooter)
    {
        OnFire(instance, shooter, shooter.GetCurrentAimingDirection());

        if (!Cheats.InfiniteAmmo)
        {
            instance.Durability--;
        }

        instance.LastFireTime = DateTime.Now;
    }
Пример #6
0
    protected override void OnFire(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction)
    {
        for (int i = 0; i < BlastCount; i++)
        {
            Projectile newAmmo = Instantiate(
                original: Ammunition,
                position: shooter.GetProjectilesSpawnPoint(),
                rotation: Quaternion.identity
                );

            newAmmo.Direction = direction;
            newAmmo.transform.Rotate((i - BlastCount / 2) * MaxAngle);

            WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();
            hurtbox.Shooter = shooter;
            hurtbox.Weapon  = instance;
        }
    }
Пример #7
0
    /// <summary>
    /// Shoots bullets with identical time between each bullet
    /// </summary>
    /// <param name="instance"></param>
    /// <param name="shooter"></param>
    /// <param name="direction"></param>
    /// <returns></returns>
    private IEnumerator CoShootBullets(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction)
    {
        for (int a = 0; a < NumberOfShots; a++)
        {
            for (int i = 0; i < BulletsPerShot; i++)
            {
                foreach (Projectile projectile in AmmunitionList)
                {
                    Vector2 position = ForceLinear ? fireingPoint : shooter.GetProjectilesSpawnPoint();

                    Vector3 newAmmoPosition;
                    if (direction == Vector2.right || direction == Vector2.left)
                    {
                        newAmmoPosition = new Vector3
                                              (position.x,
                                              position.y + Height / BulletsPerShot * i);
                    }
                    else
                    {
                        newAmmoPosition = new Vector3
                                              (position.x + (Height / BulletsPerShot * i - Height / 2),
                                              position.y);
                    }

                    Projectile newAmmo = Instantiate(
                        original: projectile,
                        position: newAmmoPosition,
                        rotation: Quaternion.identity
                        );

                    newAmmo.Direction = direction;

                    WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();
                    hurtbox.Shooter = shooter;
                    hurtbox.Weapon  = instance;

                    newAmmo.Direction = ForceLinear ? fireingDirectionOrigin : shooter.GetCurrentAimingDirection();
                }
            }

            //Waiting for next bullet
            yield return(new WaitForSeconds(WaitTime));
        }
    }
Пример #8
0
    protected override void OnFire(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction)
    {
        for (int i = 0; i < BlastCount; i++)
        {
            Projectile newAmmo = Instantiate(
                original: Ammunition,
                position: shooter.GetProjectilesSpawnPoint(),
                rotation: Quaternion.identity
                );

            //Rotates the bullet random amount
            RandomValueBetween randomAngle = new RandomValueBetween(-MaxAngle / 2, MaxAngle / 2);
            int angle = randomAngle.PickInt();
            newAmmo.Direction = direction;
            newAmmo.transform.Rotate(angle);

            WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();
            hurtbox.Shooter = shooter;
            hurtbox.Weapon  = instance;
        }
    }
Пример #9
0
    protected override void OnFire(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction)
    {
        float rotation = Ammunition.name.Equals("InstantHurtbox") ? UnityEngine.Random.Range(0f, 360f) : 0f;

        Projectile newAmmo = Instantiate(
            original: Ammunition,
            position: shooter.GetProjectilesSpawnPoint() + (direction * Distance),
            rotation: Quaternion.Euler(0f, 0f, rotation)
            );

        if (rotation == 0)
        {
            newAmmo.Direction = direction;
        }

        WeaponFireHurtbox hurtbox = newAmmo.GetComponentInChildren <WeaponFireHurtbox>();

        hurtbox.Shooter = shooter;
        hurtbox.Weapon  = instance;

        newAmmo.transform.eulerAngles = newAmmo.transform.eulerAngles.SetY(0);
    }
Пример #10
0
 /// <summary>
 /// Fires the weapon from the provided weapon shooter
 /// </summary>
 /// <param name="shooter"></param>
 public void Fire(WeaponShooterBase shooter)
 {
     Template.Fire(this, shooter);
 }
Пример #11
0
 /// <summary>
 /// Fires the weapon from the provided weapon shooter
 /// </summary>
 /// <param name="direction"></param>
 protected abstract void OnFire(WeaponInstance instance, WeaponShooterBase shooter, Vector2 direction);