Ejemplo n.º 1
0
    public void BuyGun(GameEnums.Gun guntype)
    {
        int cost = CustomizationHandler.ShopCosts.ItemsCost(guntype.ToString());

        if (PlayerStaticRunTimeData.coins >= cost)
        {
            for (int i = 0; i < PlayerStaticRunTimeData.playerFirePointData.gunsConfigurations.Length; i++)
            {
                if (PlayerStaticRunTimeData.playerFirePointData.gunsConfigurations[i].locationPath.ToString() == gunPoint.locationPath)
                {
                    PlayerStaticRunTimeData.playerFirePointData.gunsConfigurations[i].gunType            = gunTypeToBuy;
                    PlayerStaticRunTimeData.playerFirePointData.gunsConfigurations[i].gunDataType        = GameEnums.GunDataType.LrLd;
                    PlayerStaticRunTimeData.customizationFirePointData.gunsConfigurations[i].gunType     = gunTypeToBuy;
                    PlayerStaticRunTimeData.customizationFirePointData.gunsConfigurations[i].gunDataType = GameEnums.GunDataType.LrLd;

                    currentGunDataType = GameEnums.GunDataType.LrLd;
                }
            }

            PlayerStaticRunTimeData.coins -= cost;
            PlayerDataDebug.RefreshStatistics();
            PersistentPlayerDataHandler.SaveData(PlayerStaticRunTimeData.playerTruckData, PlayerStaticRunTimeData.playerFirePointData, new PlayerSessionData(0, 0));

            buyButton.gameObject.GetComponentInChildren <Text>().text = "";

            changeGunButton.onClick.RemoveAllListeners();
            buyButton.onClick.RemoveAllListeners();
            damageStat.GetComponentInChildren <Button>().onClick.RemoveAllListeners();
            rateOfFireStat.GetComponentInChildren <Button>().onClick.RemoveAllListeners();


            SelectGun();
        }
    }
Ejemplo n.º 2
0
    private void ChangeGun()
    {
        if (gunPoint.gunsLocation.childCount > 0)
        {
            ObjectPoolersHolder.Instance.GunsPooler.ReturnToPool(gunPoint.gunsLocation.GetChild(0).gameObject, gunPoint.gunsLocation.GetChild(0).gameObject.name);
        }

        gunTypeCount++;

        if (gunTypeCount > System.Enum.GetNames(typeof(GameEnums.Gun)).Length - 1)
        {
            gunTypeCount = 0;
        }

        gunTypeToBuy = (GameEnums.Gun)gunTypeCount;

        GameObject gun = ObjectPoolersHolder.Instance.GunsPooler.Spawn(gunTypeToBuy.ToString(), gunPoint.gunsLocation.position, Quaternion.identity);

        gun.transform.parent           = gunPoint.gunsLocation;
        gun.transform.localPosition    = Vector3.zero;
        gun.transform.localEulerAngles = new Vector3(0, gunPoint.allowableAnglesOnPoint.StartDirectionAngle, 0);
        rateOfFireStat.SetActive(false);
        damageStat.SetActive(false);
        buyButton.gameObject.GetComponentInChildren <Text>().text = "Buy Gun " + CustomizationHandler.ShopCosts.ItemsCost(gunTypeToBuy.ToString()).ToString();
        buyButton.onClick.RemoveAllListeners();
        buyButton.onClick.AddListener(() => BuyGun(gunTypeToBuy));
    }
Ejemplo n.º 3
0
 public void SetAllGunsToRandom()
 {
     for (int i = 0; i < gunsConfigurations.Length; i++)
     {
         int           randomGunNumber = Random.Range(0, System.Enum.GetNames(typeof(GameEnums.Gun)).Length);
         GameEnums.Gun randomGun       = (GameEnums.Gun)randomGunNumber;
         gunsConfigurations[i].gunType = randomGun;
     }
 }
Ejemplo n.º 4
0
    private void ChangeGun()
    {
        gunTypeCount++;

        if (gunTypeCount > System.Enum.GetNames(typeof(GameEnums.Gun)).Length - 1)
        {
            gunTypeCount = 1;
        }

        gunTypeToBuy = (GameEnums.Gun)gunTypeCount;

        PlayerStaticRunTimeData.customizationTruckData.firePointData.GetConfigOnLocation(gunPoint.locationPath).gunType = gunTypeToBuy;
        CustomizationState.Instance.RefreshPlayerTruckVisualBy(PlayerStaticRunTimeData.customizationTruckData);

        menuHandler.customization.RateOfFireStat.SetActive(false);
        menuHandler.customization.DamageStat.SetActive(false);
        menuHandler.customization.TargetingSpeedStat.SetActive(false);

        menuHandler.customization.BuyButton.SetActive(true);
        menuHandler.customization.BuyButton.GetComponentInChildren <Text>().text = CustomizationHandler.Instance.shopCosts.ItemsCost(gunTypeToBuy.ToString()).ToString() + "$";
        menuHandler.customization.BuyButton.GetComponent <Button>().onClick.RemoveAllListeners();
        menuHandler.customization.BuyButton.GetComponent <Button>().onClick.AddListener(() => BuyGun(gunTypeToBuy));

        if (((GameEnums.Gun)gunTypeCount).ToString().Contains("Gun2"))
        {
            menuHandler.customization.GunInfoWindow.SetActive(true);
            menuHandler.customization.GunInfoWindow.GetComponentInChildren <LocalizedText>().ResetText();
            menuHandler.customization.GunInfoWindow.GetComponentInChildren <Text>().text = menuHandler.customization.TargetingSpeedStat.GetComponentInChildren <Text>().text
                                                                                           + "\n" + menuHandler.customization.GunInfoWindow.GetComponentInChildren <Text>().text;
        }
        else if (((GameEnums.Gun)gunTypeCount).ToString().Contains("Gun3"))
        {
            menuHandler.customization.GunInfoWindow.SetActive(true);
            menuHandler.customization.GunInfoWindow.GetComponentInChildren <LocalizedText>().ResetText();
            menuHandler.customization.GunInfoWindow.GetComponentInChildren <Text>().text = menuHandler.customization.RateOfFireStat.GetComponentInChildren <Text>().text
                                                                                           + "\n" + menuHandler.customization.GunInfoWindow.GetComponentInChildren <Text>().text;
        }
        else
        {
            menuHandler.customization.GunInfoWindow.SetActive(false);
        }

        menuHandler.BackButton.GetComponent <Button>().onClick.RemoveAllListeners();
        menuHandler.BackButton.GetComponent <Button>().onClick.AddListener(() => BackToGunsOverView());
    }
Ejemplo n.º 5
0
    public void BuyGun(GameEnums.Gun guntype)
    {
        int cost = CustomizationHandler.Instance.shopCosts.ItemsCost(guntype.ToString());

        if (PlayerStaticRunTimeData.coins >= cost)
        {
            FirePointData.GunConfiguration PlayerConfigFromPath        = PlayerStaticRunTimeData.playerTruckData.firePointData.GetConfigOnLocation(gunPoint.locationPath);
            FirePointData.GunConfiguration CustomizationConfigFromPath = PlayerStaticRunTimeData.customizationTruckData.firePointData.GetConfigOnLocation(gunPoint.locationPath);

            PlayerConfigFromPath.gunType     = gunTypeToBuy;
            PlayerConfigFromPath.gunDataType = GameEnums.GunDataType.LrLdLs;

            CustomizationConfigFromPath.gunType     = gunTypeToBuy;
            CustomizationConfigFromPath.gunDataType = GameEnums.GunDataType.LrLdLs;

            currentGunDataType = GameEnums.GunDataType.LrLdLs;

            PlayerStaticRunTimeData.coins -= cost;
            PlayerStaticDataHandler.SaveData(PlayerStaticRunTimeData.playerTruckData, new PlayerSessionData(0, 0, 0));

            menuHandler.customization.BuyButton.GetComponentInChildren <Text>().text = "";

            menuHandler.customization.ChangeGunButton.GetComponent <Button>().onClick.RemoveAllListeners();

            menuHandler.customization.BuyButton.SetActive(false);
            menuHandler.customization.BuyButton.GetComponent <Button>().onClick.RemoveAllListeners();
            menuHandler.customization.RateOfFireStat.GetComponentInChildren <Button>().onClick.RemoveAllListeners();
            menuHandler.customization.DamageStat.GetComponentInChildren <Button>().onClick.RemoveAllListeners();
            menuHandler.customization.TargetingSpeedStat.GetComponentInChildren <Button>().onClick.RemoveAllListeners();

            menuHandler.customization.GunInfoWindow.SetActive(false);

            SelectGun();
        }
        else
        {
            WarningWindow.Instance.ShowWarning(WarningStrings.DontHaveMoney());
        }
    }
Ejemplo n.º 6
0
    public void BuyGun(GameEnums.Gun guntype)
    {
        int cost = CustomizationHandler.ShopCosts.ItemsCost(guntype.ToString());

        if (PlayerStaticRunTimeData.coins >= cost)
        {
            for (int i = 0; i < PlayerStaticRunTimeData.playerFirePointData.gunsConfigurations.Length; i++)
            {
                if (PlayerStaticRunTimeData.playerFirePointData.gunsConfigurations[i].locationPath.ToString() == gunPoint.locationPath)
                {
                    PlayerStaticRunTimeData.playerFirePointData.gunsConfigurations[i].gunType = gunTypeToBuy;
                }
            }

            PlayerStaticRunTimeData.coins -= cost;
        }

        changeGunButton.onClick.RemoveAllListeners();
        buyButton.onClick.RemoveAllListeners();

        PlayerDataDebug.RefreshStatistics();
    }