Beispiel #1
0
    public void BuySemiAutomaticGun()
    {
        Weapon.SemiAutomatic semi = (Weapon.SemiAutomatic)weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eSemiAutomatic);

        if (semi == null)
        {
            semi = new Weapon.SemiAutomatic();
            if (Main.S.gold >= semi.GetBuyingPrice())
            {
                audioSourceBuing.Play();
                UnlockWeaponSwapUI();
                Main.S.gold             -= semi.GetBuyingPrice();
                UI.S.gold.text           = "Gold: " + Main.S.gold;
                UI.S.semiUpgrade.text    = "Cost: " + semi.GetMoneyForUpgrade() + "$";
                UI.S.semiReloadTime.text = "Reload Spd.: " + semi.GetReloadSpeed() + " -> " + (semi.GetReloadSpeed() - 0.05f);
                UI.S.semiDamage.text     = "Damage: " + semi.GetDamage() + " -> " + (semi.GetDamage() + 1.5f);
                weapon.weapons.Add(semi);
                weapon.AddRifleAmmo(24);
            }
        }
        else
        {
            if (semi.GetMaxLevel() > semi.GetLevel())
            {
                audioSourceBuing.Play();
            }
            weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eSemiAutomatic).Upgrade();
        }
    }
Beispiel #2
0
    public void OnLoadLevel()
    {
        this.AddRifleAmmo(SaveSystem.GetData().riffleAmmo);

        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetCurrentAmmo(SaveSystem.GetData().PisCurrentAmmo);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetAmmo(SaveSystem.GetData().PisAmmo);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetCapacity(SaveSystem.GetData().PisCapacity);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetLevel(SaveSystem.GetData().PisLevel);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetFireRate(SaveSystem.GetData().PisFireRate);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetMoneyForUpgrade(SaveSystem.GetData().PisMoneyForUpgrade);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetBuyPrice(SaveSystem.GetData().PisBuyingPrice);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetReloadSpeed(SaveSystem.GetData().PisReloadSpeed);
        this.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).SetDamage(SaveSystem.GetData().PisDamage);

        if (SaveSystem.GetData().isSemiExist)
        {
            Weapon.SemiAutomatic semi = new Weapon.SemiAutomatic();
            semi.SetCurrentAmmo(SaveSystem.GetData().SemiCurrentAmmo);
            semi.SetAmmo(SaveSystem.GetData().SemiAmmo);
            semi.SetCapacity(SaveSystem.GetData().SemiCapacity);
            semi.SetLevel(SaveSystem.GetData().SemiLevel);
            semi.SetFireRate(SaveSystem.GetData().SemiFireRate);
            semi.SetMoneyForUpgrade(SaveSystem.GetData().SemiMoneyForUpgrade);
            semi.SetBuyPrice(SaveSystem.GetData().SemiBuyingPrice);
            semi.SetReloadSpeed(SaveSystem.GetData().SemiReloadSpeed);
            semi.SetDamage(SaveSystem.GetData().SemiDamage);
            this.weapons.Add(semi);
        }

        if (SaveSystem.GetData().isAutoExist)
        {
            Weapon.Automatic auto = new Weapon.Automatic();
            auto.SetCurrentAmmo(SaveSystem.GetData().AutoCurrentAmmo);
            auto.SetAmmo(SaveSystem.GetData().AutoAmmo);
            auto.SetCapacity(SaveSystem.GetData().AutoCapacity);
            auto.SetLevel(SaveSystem.GetData().AutoLevel);
            auto.SetFireRate(SaveSystem.GetData().AutoFireRate);
            auto.SetMoneyForUpgrade(SaveSystem.GetData().AutoMoneyForUpgrade);
            auto.SetBuyPrice(SaveSystem.GetData().AutoBuyingPrice);
            auto.SetReloadSpeed(SaveSystem.GetData().AutoReloadSpeed);
            auto.SetDamage(SaveSystem.GetData().AutoDamage);
            this.weapons.Add(auto);
        }

        if (SaveSystem.GetData().isRifleExist)
        {
            Weapon.SniperRifle rifle = new Weapon.SniperRifle();
            rifle.SetCurrentAmmo(SaveSystem.GetData().RifleCurrentAmmo);
            AddSniperAmmo(SaveSystem.GetData().RifleAmmo);
            rifle.SetCapacity(SaveSystem.GetData().RifleCapacity);
            rifle.SetLevel(SaveSystem.GetData().RifleLevel);
            rifle.SetFireRate(SaveSystem.GetData().RifleFireRate);
            rifle.SetMoneyForUpgrade(SaveSystem.GetData().RifleMoneyForUpgrade);
            rifle.SetBuyPrice(SaveSystem.GetData().RifleBuyingPrice);
            rifle.SetReloadSpeed(SaveSystem.GetData().RifleReloadSpeed);
            rifle.SetDamage(SaveSystem.GetData().RifleDamage);
            this.weapons.Add(rifle);
        }
    }
Beispiel #3
0
    private void Start()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");
        GameObject weapon = GameObject.FindGameObjectWithTag("Weapon");

        _player = player.GetComponentInChildren <Player>();
        _weapon = weapon.GetComponentInChildren <Weapon>();
        S       = this;

        //TEXTS

        if (_weapon.GetWeapon().GetType() != Weapon.WeaponType.ePistol)
        {
            ammo.text = _weapon.GetWeapon().GetCurrentAmmo() + "/" + _weapon.GetWeapon().GetCapacity() + "  [" + _weapon.GetRifleAmmo() + "]";
        }
        else
        {
            ammo.text = _weapon.GetWeapon().GetCurrentAmmo() + "/" + _weapon.GetWeapon().GetCapacity();
        }
        weaponName.text = _weapon.GetWeapon().GetName();

        gold.text     = "Gold: " + Main.S.gold;
        wave.text     = "Wave: " + (int)(Main.S.waveCounter);
        hpAmount.text = _player.GetHP().ToString();

        Weapon.Pistol pistol = (Weapon.Pistol)_weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol);
        pistolUpgrade.text = "Cost: " + pistol.GetMoneyForUpgrade() + "$";

        Weapon.SemiAutomatic semi = (Weapon.SemiAutomatic)_weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eSemiAutomatic);
        if (semi == null)
        {
            semi             = new Weapon.SemiAutomatic();
            semiUpgrade.text = "Cost: " + semi.GetBuyingPrice() + "$\n \n ";
        }
        else
        {
            semiUpgrade.text = "Cost: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eSemiAutomatic).GetMoneyForUpgrade() + "$";
            if (semi.GetLevel() == semi.GetMaxLevel())
            {
                UI.S.semiUpgrade.text    = "MAX LEVEL REACHED";
                UI.S.semiReloadTime.text = "";
                UI.S.semiDamage.text     = "";
            }
        }

        Weapon.Automatic auto = (Weapon.Automatic)_weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eAutomatic);
        if (auto == null)
        {
            auto             = new Weapon.Automatic();
            autoUpgrade.text = "Cost: " + auto.GetBuyingPrice() + "$\n \n ";
        }
        else
        {
            autoUpgrade.text = "Cost: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eAutomatic).GetMoneyForUpgrade() + "$";
        }

        Weapon.SniperRifle snip = (Weapon.SniperRifle)_weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eSniperRifle);
        if (snip == null)
        {
            snip = new Weapon.SniperRifle();
            sniperUpgrade.text = "Cost: " + snip.GetBuyingPrice() + "$\n \n ";
        }
        else
        {
            autoUpgrade.text = "Cost: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eSniperRifle).GetMoneyForUpgrade() + "$";
        }

        //Sklep - Panel HP
        if (_player.GetHpLevel() == _player.GetMaxHpLevel())
        {
            hpUpgrade.text = "Health level: " + Player.S.GetHpLevel() + " / " + Player.S.GetMaxHpLevel() + "\n" +
                             " " +
                             "\nCost: " + Player.S.GetHpUpgradeCost() + "$\n ";
            // hpUpgrade.text = "25$\nHEAL";
        }
        else
        {
            hpUpgrade.text = "Health level: " + Player.S.GetHpLevel() + " / " + Player.S.GetMaxHpLevel() + "\n" +
                             Player.S.GetMaxHP() + " -> " + (Player.S.GetMaxHP() + Player.S.GetHpBonusPerLevel()) +
                             "\nCost: " + Player.S.GetHpUpgradeCost() + "$\n ";
            // hpUpgrade.text = "25$\nHEAL";
        }

        //Sklep - Panel Ammo
        if (_weapon.GetWeapon().GetType() == Weapon.WeaponType.ePistol)
        {
            buyAmmoText.text           = "+" + Main.S.GetComponent <Shop>().rifleAmmoPiecesToBuy + "\nCost: " + Main.S.GetComponent <Shop>().rifleAmmoPrice + "$\n ";
            buyAmmoButton.interactable = false;
            buyAmmoButton.GetComponent <Image>().enabled = false;
            buyAmmoText.text += "You can not buy ammunation for " + _weapon.GetWeapon().GetName();
        }
        else if (_weapon.GetWeapon().GetType() == Weapon.WeaponType.eSniperRifle)
        {
            buyAmmoText.text           = "\nAmmo for Sniper\n+" + Main.S.GetComponent <Shop>().rifleAmmoPiecesToBuy + "\nCost: " + Main.S.GetComponent <Shop>().rifleAmmoPrice + "$\n ";
            buyAmmoButton.interactable = true;
            buyAmmoButton.GetComponent <Image>().enabled = true;
            buyAmmoText.text += "\n \n ";
        }
        else
        {
            buyAmmoText.text           = "\nAmmo for machine guns\n+" + Main.S.GetComponent <Shop>().rifleAmmoPiecesToBuy + "\nCost: " + Main.S.GetComponent <Shop>().rifleAmmoPrice + "$\n ";
            buyAmmoButton.interactable = true;
            buyAmmoButton.GetComponent <Image>().enabled = true;
            buyAmmoText.text += "\n \n ";
        }

        gunReloadTime.text = "Reload Spd.: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).GetReloadSpeed() + " -> " + (_weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).GetReloadSpeed() - 0.05f);
        gunDamage.text     = "Damage: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).GetDamage() + " -> " + (_weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.ePistol).GetDamage() + 1);
        if (pistol.GetLevel() == pistol.GetMaxLevel())
        {
            UI.S.pistolUpgrade.text = "MAX LEVEL REACHED";
            UI.S.gunReloadTime.text = "";
            UI.S.gunDamage.text     = "";
        }


        Weapon.SemiAutomatic semic = (Weapon.SemiAutomatic)_weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eSemiAutomatic);
        if (semic != null)
        {
            semiReloadTime.text = "Reload Spd.: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eSemiAutomatic).GetReloadSpeed() + " -> " + (_weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eSemiAutomatic).GetReloadSpeed() - 0.05f);
            semiDamage.text     = "Damage: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eSemiAutomatic).GetDamage() + " -> " + (_weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eSemiAutomatic).GetDamage() + 1.5f);
        }
        else
        {
            semiReloadTime.text = "";
            semiDamage.text     = "";
        }

        Weapon.Automatic autom = (Weapon.Automatic)_weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eAutomatic);
        if (autom != null)
        {
            autoReloadTime.text = "Reload Spd.: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eAutomatic).GetReloadSpeed() + " -> " + (_weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eAutomatic).GetReloadSpeed() - 0.05f);
            autoDamage.text     = "Damage: " + _weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eAutomatic).GetDamage() + " -> " + (_weapon.weapons.Find(gun => gun.GetType() == Weapon.WeaponType.eAutomatic).GetDamage() + 2);
            if (auto.GetLevel() == auto.GetMaxLevel())
            {
                UI.S.autoUpgrade.text    = "MAX LEVEL REACHED";
                UI.S.autoReloadTime.text = "";
                UI.S.autoDamage.text     = "";
            }
        }
        else
        {
            autoReloadTime.text = "";
            autoDamage.text     = "";
        }

        Weapon.SniperRifle sniper = (Weapon.SniperRifle)_weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eSniperRifle);
        if (sniper != null)
        {
            sniperReloadTime.text = "Reload Spd.: " + sniper.GetReloadSpeed() + " -> " + (sniper.GetReloadSpeed() - 0.05f);
            sniperDamage.text     = "Damage: " + sniper.GetDamage() + " -> " + (sniper.GetDamage() + 4);
            if (sniper.GetLevel() == sniper.GetMaxLevel())
            {
                UI.S.sniperUpgrade.text    = "MAX LEVEL REACHED";
                UI.S.sniperReloadTime.text = "";
                UI.S.sniperDamage.text     = "";
            }
        }
        else
        {
            sniperReloadTime.text = "";
            sniperDamage.text     = "";
        }
    }
Beispiel #4
0
    private void UpdateButtonsStatus()
    {
        foreach (GameObject gameObject in shopPanelsArray)
        {
            Image image = gameObject.GetComponent <Image>();
            if (gameObject.name == "BuyAmmo")
            {
                if (Main.S.gold >= rifleAmmoPrice && weapon.GetWeapon().GetType() != Weapon.WeaponType.ePistol)
                {
                    image.color = greenToBuy;
                }
                else
                {
                    image.color = redToBuy;
                }
            }
            else if (gameObject.name == "BuyHealth")
            {
                if (Main.S.gold >= Player.S.GetHpUpgradeCost())
                {
                    image.color = greenToBuy;
                }
                else
                {
                    image.color = redToBuy;
                }
                if (Player.S.GetMaxHpLevel() == Player.S.GetHpLevel())
                {
                    image.color = yellowToBuy;
                }
            }
            else if (gameObject.name == "BuyGun")
            {
                Weapon.Pistol pistol = (Weapon.Pistol)weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.ePistol);
                if (Main.S.gold >= pistol.GetMoneyForUpgrade())
                {
                    image.color = greenToBuy;
                }
                else
                {
                    image.color = redToBuy;
                }
                if (pistol.GetMaxLevel() == pistol.GetLevel())
                {
                    image.color = yellowToBuy;
                }
            }
            else if (gameObject.name == "BuySemiAutomaticGun")
            {
                Weapon.SemiAutomatic semi = (Weapon.SemiAutomatic)weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eSemiAutomatic);
                if (semi == null)
                {
                    semi = new Weapon.SemiAutomatic();
                    if (Main.S.gold >= semi.GetBuyingPrice())
                    {
                        image.color = greenToBuy;
                    }
                    else
                    {
                        image.color = redToBuy;
                    }
                }
                else
                {
                    if (Main.S.gold >= semi.GetMoneyForUpgrade())
                    {
                        image.color = greenToBuy;
                    }
                    else
                    {
                        image.color = redToBuy;
                    }
                }

                if (semi.GetMaxLevel() == semi.GetLevel())
                {
                    image.color = yellowToBuy;
                }
            }
            else if (gameObject.name == "BuyAutomaticGun")
            {
                Weapon.Automatic auto = (Weapon.Automatic)weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eAutomatic);
                if (auto == null)
                {
                    auto = new Weapon.Automatic();
                    if (Main.S.gold >= auto.GetBuyingPrice())
                    {
                        image.color = greenToBuy;
                    }
                    else
                    {
                        image.color = redToBuy;
                    }
                }
                else
                {
                    if (Main.S.gold >= auto.GetMoneyForUpgrade())
                    {
                        image.color = greenToBuy;
                    }
                    else
                    {
                        image.color = redToBuy;
                    }
                }

                if (auto.GetMaxLevel() == auto.GetLevel())
                {
                    image.color = yellowToBuy;
                }
            }
            else if (gameObject.name == "BuyFencyUpgrade")
            {
                DefensiveObject baricadeObject = DefensiveObjectsArray[1].prefabs.GetComponent <DefensiveObject>(); //PŁOT
                if (Main.S.gold >= baricadeObject.upgradePrice)
                {
                    image.color = greenToBuy;
                }
                else
                {
                    image.color = redToBuy;
                }
                if (baricadeObject.maxLevel == baricadeObject.currentLevel)
                {
                    image.color = yellowToBuy;
                }
            }
            else if (gameObject.name == "BuySpikeUpgrade")
            {
                DefensiveSpikes spikesObject = DefensiveObjectsArray[0].prefabs.GetComponent <DefensiveSpikes>(); //KOLCE
                if (Main.S.gold >= spikesObject.upgradePrice)
                {
                    image.color = greenToBuy;
                }
                else
                {
                    image.color = redToBuy;
                }
                if (spikesObject.maxLevel == spikesObject.currentLevel)
                {
                    image.color = yellowToBuy;
                }
            }
            else if (gameObject.name == "BuySniperRifle")
            {
                Weapon.SniperRifle rifle = (Weapon.SniperRifle)weapon.weapons.Find(w => w.GetType() == Weapon.WeaponType.eSniperRifle);
                if (rifle == null)
                {
                    rifle = new Weapon.SniperRifle();
                    if (Main.S.gold >= rifle.GetBuyingPrice())
                    {
                        image.color = greenToBuy;
                    }
                    else
                    {
                        image.color = redToBuy;
                    }
                }
                else
                {
                    if (Main.S.gold >= rifle.GetMoneyForUpgrade())
                    {
                        image.color = greenToBuy;
                    }
                    else
                    {
                        image.color = redToBuy;
                    }
                }

                if (rifle.GetMaxLevel() == rifle.GetLevel())
                {
                    image.color = yellowToBuy;
                }
            }
        }
    }