Example #1
0
    public void UpgradeGunData(GameEnums.GunDataType gunDataTypeToBuy, int cost)
    {
        if (PlayerStaticRunTimeData.coins >= cost)
        {
            FirePointData.GunConfiguration PlayerConfigFromPath        = PlayerStaticRunTimeData.playerTruckData.firePointData.GetConfigOnLocation(gunPoint.locationPath);
            FirePointData.GunConfiguration CustomizationConfigFromPath = PlayerStaticRunTimeData.customizationTruckData.firePointData.GetConfigOnLocation(gunPoint.locationPath);

            PlayerConfigFromPath.gunDataType        = gunDataTypeToBuy;
            CustomizationConfigFromPath.gunDataType = gunDataTypeToBuy;

            currentGunDataType = gunDataTypeToBuy;

            int    gunType          = (int)PlayerConfigFromPath.gunDataType;
            char[] typeNumbersChars = gunType.ToString().ToCharArray();


            menuHandler.customization.RateOfFireStat.GetComponent <Slider>().value     = typeNumbersChars[0] - 48;
            menuHandler.customization.DamageStat.GetComponent <Slider>().value         = typeNumbersChars[1] - 48;
            menuHandler.customization.TargetingSpeedStat.GetComponent <Slider>().value = typeNumbersChars[2] - 48;


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

            CustomizationState.Instance.RefreshPlayerStats();
        }
        else
        {
            WarningWindow.Instance.ShowWarning(WarningStrings.DontHaveMoney());
        }
    }
Example #2
0
    private void SelectGun()
    {
        CustomizationState.Instance.RefreshPlayerStats();

        CustomizationHandler.Instance.StartCoroutine(CustomizationHandler.Instance.CameraTracking(Camera.main.transform.position, transform.position + gunPoint.gunsLocation.up * 2 + gunPoint.gunsLocation.forward * 2, gunPoint.gunsLocation.position));

        FirePointData.GunConfiguration ConfigFromPath = PlayerStaticRunTimeData.playerTruckData.firePointData.GetConfigOnLocation(gunPoint.locationPath);

        if (ConfigFromPath.gunType != GameEnums.Gun.None)
        {
            menuHandler.customization.RateOfFireStat.SetActive(true);
            menuHandler.customization.DamageStat.SetActive(true);
            menuHandler.customization.TargetingSpeedStat.SetActive(true);

            currentGunDataType = ConfigFromPath.gunDataType;
            int    gunType          = (int)currentGunDataType;
            char[] typeNumbersChars = gunType.ToString().ToCharArray();


            menuHandler.customization.RateOfFireStat.GetComponent <Slider>().value     = typeNumbersChars[0] - 48;
            menuHandler.customization.DamageStat.GetComponent <Slider>().value         = typeNumbersChars[1] - 48;
            menuHandler.customization.TargetingSpeedStat.GetComponent <Slider>().value = typeNumbersChars[2] - 48;

            menuHandler.customization.RateOfFireStat.GetComponentInChildren <Button>().onClick.AddListener(() => UpgradeRateOfFire());
            menuHandler.customization.DamageStat.GetComponentInChildren <Button>().onClick.AddListener(() => UpgradeDamage());
            menuHandler.customization.TargetingSpeedStat.GetComponentInChildren <Button>().onClick.AddListener(() => UpgradeTargetingSpeed());

            menuHandler.customization.RateOfFireStat.GetComponentInChildren <Button>().GetComponentInChildren <Text>().text     = UpgradeRateOfFireCost();
            menuHandler.customization.DamageStat.GetComponentInChildren <Button>().GetComponentInChildren <Text>().text         = UpgradeDamageCost();
            menuHandler.customization.TargetingSpeedStat.GetComponentInChildren <Button>().GetComponentInChildren <Text>().text = UpgradeTargetingSpeedCost();
        }

        menuHandler.customization.ChangeGunButton.SetActive(true);
        menuHandler.customization.ChangeGunButton.GetComponent <Button>().onClick.AddListener(() => ChangeGun());

        menuHandler.BackButton.GetComponent <Button>().onClick.RemoveAllListeners();
        menuHandler.BackButton.GetComponent <Button>().onClick.AddListener(() => BackToGunsOverView());

        CustomizationHandler.Instance.ShopGunButtonsRenderSetActive(false);
    }
Example #3
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());
        }
    }