Beispiel #1
0
    //fires next projectile in line. if no special projectile loaded, fires a default bouncing projectile
    private void FireCannon()
    {
        if (shotCooldown > 0f)
        {
            return;
        }

        GameObject nuProjectile = Instantiate <GameObject>(projectilePrefab);

        nuProjectile.transform.position = cannonBarrel.transform.position + muzzlePoint;
        ProjectileScript projScrip = nuProjectile.GetComponent <ProjectileScript>();

        //here we check the special bullets loaded
        ProjectileScript.ProjectileType nextType = loadedProjectile ? loadedType : ProjectileScript.ProjectileType.Bouncer;
        if (loadedProjectile)
        {
            loadedProjectile = false;
        }

        projScrip.Shoot(cannonBarrel.transform.position + muzzlePoint, GameSettings.instance.projectileStartSpeed * cannonBarrel.forward, nextType);

        //we set the cooldown
        cooldownGraphic.fillAmount = 1f;
        cooldownGraphic.transform.GetChild(0).gameObject.SetActive(true);
        shotCooldown = GameSettings.instance.shootCooldown;
    }
Beispiel #2
0
    //method to buy a special projectile from the in game store
    public void BuyBullet(int typeID)
    {
        ProjectileScript.ProjectileType type = (ProjectileScript.ProjectileType)typeID;

        if (CannonScript.instance.loadedProjectile)
        {
            warningLabel.text = "! Warning: Can't buy a new bullet with one already on the chamber !";
            warningLabel.gameObject.SetActive(true);
            return;
        }

        int gold  = PlayerPrefs.GetInt("Wallet", CurrencySettings.instance.startingGold);
        int price = CurrencySettings.instance.fragmentProjectile;

        if (type == ProjectileScript.ProjectileType.Explosive)
        {
            price = CurrencySettings.instance.explosiveProjectile;
        }
        else if (type == ProjectileScript.ProjectileType.Roller)
        {
            price = CurrencySettings.instance.rollingProjectile;
        }

        if (gold < price)
        {
            warningLabel.text = "! Warning: Not enough gold to buy a " + type.ToString() + " projectile !";
            warningLabel.gameObject.SetActive(true);
            return;
        }

        gold -= price;
        PlayerPrefs.SetInt("Wallet", gold);
        goldLabel.text = "Gold: " + gold;

        PlayFabManager.instance.UpdateGoldStat(gold);

        PlayFabManager.instance.StartCloudStatUpdate();

        //PlayFabManager.instance.SetGoldStat(gold); //previous non-cloudscript version

        CannonScript.instance.LoadSpecialProjectile(type);
    }
Beispiel #3
0
 //method that loads a special bullet to the chamber
 public void LoadSpecialProjectile(ProjectileScript.ProjectileType type)
 {
     loadedProjectile = true;
     loadedType       = type;
 }