Exemplo n.º 1
0
 //Throws the equipped throwable to the ground unarmed
 public void DropThrowable(Throwable_Class throwableToDrop)
 {
     throwableToDrop.transform.position = ItemDropPosition.position;
     throwableToDrop.transform.rotation = ItemDropPosition.rotation;
     throwableToDrop.Release(ThrowableDropForce, GetComponent <Collider>());
     throwableToDrop.TurnOnInteraction();
     throwableToDrop = null;
 }
    public override void Fire()
    {
        if (currentWeaponState == State.Ready && currentAmmo > 0)
        {
            currentAmmo = currentAmmo - 1;
            //////////////////////////////////////////////////////////////
            if (PrimaryWeaponAudioSource.clip != Clip_Shot)
            {
                PrimaryWeaponAudioSource.clip = Clip_Shot;
            }

            StartCoroutine(ShotSound());
            ///////////////////////////////////////////////////////////////////

            // Play Shot sound ////////////////////////////////////////////////////
            //WeaponAudioSource.clip = Clip_Shot;
            //WeaponAudioSource.Play();
            ///////////////////////////////////////////////////////////////////////

            foreach (GameObject i in projectileOrigins)
            {
                Rigidbody clone =
                    Instantiate(projectile,
                                i.transform.position,
                                i.transform.rotation);

                Projectile_Class projectileClone = clone.GetComponent <Projectile_Class>();

                if (projectileClone != null)
                {
                    projectileClone.ProjectileDamage = projectileClone.ProjectileDamage * DamageModifer;
                }

                Throwable_Class throwableClone = clone.GetComponent <Throwable_Class>();

                if (throwableClone != null)
                {
                    throwableClone.SetLive();
                }

                clone.transform.Rotate
                    (Random.Range(-1 * ProjectileSpread, ProjectileSpread),
                    Random.Range(-1 * ProjectileSpread, ProjectileSpread),
                    0);

                clone.AddForce(clone.transform.forward * projectileSpeed);
            }

            StartCoroutine(FireRateCoolDown());
        }
    } /////
Exemplo n.º 3
0
    //Allows a new throwable to enter the intventory, if the inventory is full, a throwable is dropped
    public void EquipNewThrowable(Throwable_Class ThrowableToPickup)
    {
        if (EquippedThrowableScript != null)
        {
            DropThrowable(EquippedThrowableScript);
        }

        ThrowableToPickup.TurnOffInteraction();
        EquippedThrowableScript = ThrowableToPickup;

        //EquippedRangedWeaponScipt.transform.localScale = new Vector3(1, 1, 1);

        StartCoroutine(EquipCoolDown());
    }
Exemplo n.º 4
0
    public void DropEverything()
    {
        foreach (RangedWeapon_Class x in RangedWeapons)
        {
            if (x != null)
            {
                //RangedWeapons[EquippedRangedWeaponIndex].Refresh();
                //RangedWeapons[EquippedRangedWeaponIndex] = null;
                x.gameObject.SetActive(true);
                x.transform.position = ItemDropPosition.position;
                x.transform.rotation = ItemDropPosition.rotation;
                x.transform.parent   = null;
                x.gameObject.AddComponent <Rigidbody>();
                Rigidbody weaponToDrop = x.GetComponent <Rigidbody>();
                weaponToDrop.AddForce(weaponToDrop.transform.forward * WeaponDropForce);
                if (x.currentAmmo == 0 && x.reserveAmmo == 0)
                {
                    Destroy(x.gameObject);
                }
                if (x != null)
                {
                    x.TurnOnInteraction();
                }
            }
        }

        for (int i = 0; i < RangedWeapons.Count; i++)
        {
            RangedWeapons[i] = null;
        }

        if (EquippedRangedWeaponScipt != null)
        {
            DropRangedWeapon(EquippedRangedWeaponScipt);
        }

        EquippedRangedWeaponScipt = null;

        EquippedRangedWeaponIndex = 0;

        if (EquippedThrowableScript != null)
        {
            DropThrowable(EquippedThrowableScript);
            EquippedThrowableScript = null;
        }
    }
Exemplo n.º 5
0
 //Throws the equipped throwable and arms it
 public void ThrowThrowable()
 {
     EquippedThrowableScript.Release(ThrowableForce, GetComponent <Collider>());
     EquippedThrowableScript.SetLive();
     EquippedThrowableScript = null;
 }