Esempio n. 1
0
 public void Reload()
 {
     //reloadTimer = (1f / reloadSpeed) + (.5f - (reloadSpeed / 10));
     if (currentMagazine < magazineSize)
     {
         int heldAmmo = playerAmmo.GetAmount(ammoType);
         reloadSpeed = playerProperties.handSpeed * reloadSpeedModifier;
         anim.SetTrigger("Reload");
         anim.SetFloat("Reload Speed", reloadSpeed);
         if (heldAmmo >= magazineSize)
         {
             playerAmmo.RemoveAmmo((int)magazineSize - (int)currentMagazine, ammoType);
             currentMagazine = magazineSize;
         }
         else if (heldAmmo > 0)
         {
             while (currentMagazine < magazineSize && heldAmmo > 0)
             {
                 currentMagazine++;
                 playerAmmo.RemoveAmmo(1, ammoType);
                 heldAmmo = playerAmmo.GetAmount(ammoType);
             }
         }
     }
 }
Esempio n. 2
0
    // Update is called once per frame
    void LateUpdate()
    {
        Weapon equippedWeapon;
        Shoot  tempShoot;

        if (weaponSwitch.equippedWeapon != null)
        {
            equippedWeapon = weaponSwitch.equippedWeapon.GetComponent <Weapon>();
            if (equippedWeapon.weaponType == Weapon.WeaponType.Gun)
            {
                tempShoot = (Shoot)equippedWeapon;
                if (displayAmmoCountToggle.isOn)
                {
                    text.text = (int)tempShoot.currentMagazine + "\n" + playerAmmo.GetAmount(tempShoot.ammoType);
                }
                else
                {
                    int tempInt = (int)tempShoot.currentMagazine;
                    text.text = tempInt.ToString();
                }
            }
            else
            {
                text.text = "\u221E";
            }
        }
        else
        {
            text.text = "";
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        float tempWeight = 0;

        for (int i = 0; i < playerInventory.inventory.Count; i++)
        {
            tempWeight += (playerInventory.inventory[i].itemWeight * (float)playerInventory.itemNumberInStack[i]);
        }
        for (int i = 0; i < playerArmor.equippedArmor.Length; i++)
        {
            if (playerArmor.equippedArmor[i] != null)
            {
                tempWeight += playerArmor.equippedArmor[i].itemWeight;
            }
        }
        for (int i = 0; i < 5; i++)
        {
            tempWeight += playerAmmo.GetAmount((AmmoEnum.AmmoType)i) * ammoWeight;
        }
        currentWeight = tempWeight;

        properties.SetEncumbered(currentWeight > maxWeight);

        duffleImage.fillAmount = (currentWeight / maxWeight);


        lastWeight = currentWeight;
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        Shoot tempShoot = null;

        if (weaponSwitch.equippedWeapon != null)
        {
            if (weaponSwitch.equippedWeapon.GetComponent <Weapon>().weaponType == Weapon.WeaponType.Gun)
            {
                tempShoot = weaponSwitch.equippedWeapon.GetComponent <Shoot>();
            }
        }
        for (int i = 0; i < 6; i++)
        {
            int tempAmmo = ammo.GetAmount((AmmoEnum.AmmoType)i);
            if (tempAmmo < 1)
            {
                Color c = ammoImage[i].color;
                c.a = .5f;
                ammoImage[i].color  = c;
                amountText[i].text  = tempAmmo.ToString();
                amountText[i].color = Color.red;
            }
            else
            {
                Color c = ammoImage[i].color;
                c.a = 1f;
                ammoImage[i].color  = c;
                amountText[i].text  = tempAmmo.ToString();
                amountText[i].color = Color.black;
            }
            if (tempShoot != null && tempShoot.ammoType == (AmmoEnum.AmmoType)i)
            {
                ammoImage[i].color = Color.blue;
            }
            else
            {
                ammoImage[i].color = Color.white;
            }
        }
    }