Example #1
0
    public void BuyPriAmmo()
    {
        PlayerWeapons   weapon  = playerWeapon.GetComponent <PlayerWeapons>();
        BulletInventory bullets = playerWeapon.GetComponent <BulletInventory>();

        if (bullets.GetPriTotalBullets() < bullets.GetPriMaxTotalBullets())
        {
            int BulletsToBuy = bullets.GetPriMaxTotalBullets() - bullets.GetPriTotalBullets();
            int CashNeeded   = 20 * BulletsToBuy;

            // if hvae enough money to fill up to max total bullets
            if (weapon.GetCash() >= CashNeeded)
            {
                weapon.AddCash(-CashNeeded);
                bullets.SetPriTotalBullets(bullets.GetPriMaxTotalBullets());
            }
            else
            {
                // Not enough money to buy all of the "needed to fill up to max total bullets"
                // So we buy until have no money
                int BulletsICanBuy = weapon.GetCash() / 20;

                weapon.AddCash(-(BulletsICanBuy * 20));
                bullets.SetPriTotalBullets(bullets.GetPriTotalBullets() + BulletsICanBuy);
            }
        }
    }
Example #2
0
    public void BuySecAmmo()
    {
        PlayerWeapons   weapon  = playerWeapon.GetComponent <PlayerWeapons>();
        BulletInventory bullets = playerWeapon.GetComponent <BulletInventory>();

        if (weapon.GetSecWeapon() == "228 Compact")
        {
            if (bullets.GetSecTotalBullets() < bullets.GetSecMaxTotalBullets())
            {
                int BulletsToBuy = bullets.GetSecMaxTotalBullets() - bullets.GetSecTotalBullets();
                int CashNeeded   = 7 * BulletsToBuy;

                // if hvae enough money to fill up to max total bullets
                if (weapon.GetCash() >= CashNeeded)
                {
                    weapon.AddCash(-CashNeeded);
                    bullets.SetSecTotalBullets(bullets.GetSecMaxTotalBullets());
                }
                else
                {
                    // Not enough money to buy all of the "needed to fill up to max total bullets"
                    // So we buy until have no money
                    int BulletsICanBuy = weapon.GetCash() / 7;

                    weapon.AddCash(-(BulletsICanBuy * 7));
                    bullets.SetSecTotalBullets(bullets.GetSecTotalBullets() + BulletsICanBuy);
                }
            }
        }
        else if (weapon.GetSecWeapon() == "Desert Eagle")
        {
            if (bullets.GetSecTotalBullets() < bullets.GetSecMaxTotalBullets())
            {
                int BulletsToBuy = bullets.GetSecMaxTotalBullets() - bullets.GetSecTotalBullets();
                int CashNeeded   = 28 * BulletsToBuy;

                // if hvae enough money to fill up to max total bullets
                if (weapon.GetCash() >= CashNeeded)
                {
                    weapon.AddCash(-CashNeeded);
                    bullets.SetSecTotalBullets(bullets.GetSecMaxTotalBullets());
                }
                else
                {
                    // Not enough money to buy all of the "needed to fill up to max total bullets"
                    // So we buy until have no money
                    int BulletsICanBuy = weapon.GetCash() / 28;

                    weapon.AddCash(-(BulletsICanBuy * 28));
                    bullets.SetSecTotalBullets(bullets.GetSecTotalBullets() + BulletsICanBuy);
                }
            }
        }
    }
Example #3
0
    public void BuyPistol2()
    {
        PlayerWeapons weapon = playerWeapon.GetComponent <PlayerWeapons>();

        if (weapon.GetCash() - 200 >= 0)
        {
            weapon.AddCash(-200);
            weapon.SetSecWeapon("Desert Eagle");
        }
    }
Example #4
0
    public void BuyPistol1()
    {
        PlayerWeapons weapon = playerWeapon.GetComponent <PlayerWeapons>();

        if (weapon.GetCash() - 100 >= 0)
        {
            weapon.AddCash(-100);
            weapon.SetSecWeapon("228 Compact");
        }
    }
Example #5
0
    public void BuyRifle2()
    {
        PlayerWeapons weapon = playerWeapon.GetComponent <PlayerWeapons>();

        if (weapon.GetCash() - 700 >= 0)
        {
            weapon.AddCash(-700);
            weapon.SetPriWeapon("M4A1");
        }
    }
Example #6
0
    public void BuyRifle1()
    {
        PlayerWeapons weapon = playerWeapon.GetComponent <PlayerWeapons>();

        if (weapon.GetCash() - 600 >= 0)
        {
            weapon.AddCash(-600);
            weapon.SetPriWeapon("AK-47");
        }
    }