Ejemplo n.º 1
0
 //Setting infinite ammo active in every weapon, and initiate cool-down
 public void SetInfiniteAmmo(bool isInfinite)
 {
     foreach (Weapon WeaponCheck in Weapons)
     {
         WeaponCheck.hasInfiniteAmmo = isInfinite;
         WeaponCheck.InitiateCooldown(true);
     }
 }
Ejemplo n.º 2
0
    public void AddWeapon(GameObject WeaponToAdd, WeaponPickup Pickup)
    {
        Weapon NewWeapon = WeaponToAdd.GetComponent <Weapon>();

        //If what we're picking up does not actually contain a weapon component, stop functionality
        if (NewWeapon == null)
        {
            if (Pickup != null)
            {
                Pickup.CleanupPickup(false);
            }
            return;
        }

        //Get Weapon Name
        string WeaponName = NewWeapon.GetWeaponName();

        //Checks to see if we're trying to pick up a weapon we already own
        foreach (Weapon WeaponCheck in Weapons)
        {
            if (WeaponCheck.GetWeaponName() == WeaponName)
            {
                if (Pickup != null)
                {
                    Pickup.CleanupPickup(false);
                }

                return;
            }
        }

        //Assigning weapon owner, used for determining who dealt damage
        NewWeapon.Owner = gameObject;

        //adding to array of owned weapons, childing weapon to owner
        Weapons.Add(NewWeapon);
        WeaponToAdd.transform.parent = transform;

        //reseting position and rotation
        WeaponToAdd.transform.rotation = new Quaternion(0, 0, 0, 0);
        WeaponToAdd.transform.position = WeaponAttachPoint.position;

        //If picked up from weapon pickup, say pickup was successful
        if (Pickup != null)
        {
            Pickup.CleanupPickup(true);
        }

        //If this is the first weapon we're picking up, switch to it
        if (Weapons.Count == 1)
        {
            SwitchWeapon(true);
        }

        UpdateCooldown(Weapons.Count - 1, NewWeapon);
    }