public A()
 {
     Primary             = new Weapon.SMG();
     Secondary           = new Weapon.Pistol();
     Tertiary            = new Weapon.BAM16A4();
     Tertiary.Attachment = "Starburst";
 }
Exemplo n.º 2
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     = "";
        }
    }
Exemplo n.º 3
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;
                }
            }
        }
    }
 public C()
 {
     Primary   = new Weapon.Pistol();
     Secondary = new Weapon.Sniper();
     Tertiary  = new Weapon.BoltActionSniper();
 }