Exemplo n.º 1
0
    // Reload missile weapon
    public void reload()
    {
        bool  foundAmmo  = false;
        float reloadTime = Time.time;

        if (missileWeapon != null)
        {
            foreach (ItemBS i in inventory)
            {
                //print(i.name);
                AmmoBS a = i.GetComponent <AmmoBS>();
                // if a is Ammo, and a is compatible with the right weapon
                if ((a != null) && (a.isCompatible(missileWeapon)) && (a != missileWeapon.ClipItem))
                {
                    print("Reloading " + missileWeapon.name);
                    missileWeapon.reload(a);
                    foundAmmo = true;
                    break;
                }
            }
            if (foundAmmo == true)
            {
                reloadTime += missileWeapon.reloadTime;
            }
        }

        // makes it so you cant move and reload
        busyState = reloadTime;
        canSprint = false;
    }
Exemplo n.º 2
0
 // reloads the weapon, returns the old clip
 public void reload(AmmoBS newClip)
 {
     //print("Reloading " + item.name + " with " + newClip.name);
     if (newClip.isCompatible(this))
     {
         AmmoBS oldClip = ClipItem;
         ClipItem   = newClip;
         nextAttack = Time.time + reloadTime;
         if (oldClip.rounds <= 0)
         {
             character.dropItem(oldClip.item);
         }
     }
 }
Exemplo n.º 3
0
    // return how many rounds left there are for the missile weapon
    public int getTotalRounds()
    {
        int total = 0;

        if (missileWeapon != null)
        {
            foreach (ItemBS i in inventory)
            {
                if (i != null)
                {
                    AmmoBS a = i.GetComponent <AmmoBS>();
                    if (a != null && a.ammoType == missileWeapon.ammoType)
                    {
                        total += a.rounds;
                    }
                }
            }
        }

        return(total);
    }