public void AddGold(short goldToAdd)
    {
        string decodingGold = B64X.Decode(gold);
        short  existsGold   = short.Parse(decodingGold);

        existsGold += goldToAdd;
        gold        = B64X.Encode(existsGold.ToString());
        WriteGoldCount();
    }
    /// <summary>
    /// Потерять жизнь
    /// </summary>
    /// <param name="amount">Количество</param>
    public void LoseLife(int amount = 1)
    {
        string currentLiveDecodedStr = B64X.Decode(currentLivesCount);
        int    currentLiveDecoded    = int.Parse(currentLiveDecodedStr);

        currentLiveDecoded -= amount;

        currentLivesCount = B64X.Encode(currentLiveDecoded.ToString());

        OnLivesCountChange.Invoke();

        if (currentLiveDecoded == 0)
        {
            EndGame();
        }
    }
    /// <summary>
    /// Добавить золото
    /// </summary>
    /// <param name="amount">Количество</param>
    public void AddGold(int amount)
    {
        // Расшифровываем
        string decodingGold = B64X.Decode(currentGold);
        int    existsGold   = int.Parse(decodingGold);

        // Прибавляем
        existsGold += amount;

        // Кодируем обратно
        string encodingGold = B64X.Encode(existsGold.ToString());

        currentGold = encodingGold;

        OnGoldChange.Invoke();
    }
Beispiel #4
0
    void Update()
    {
        if (currentGold != TitleScript.gold)
        {
            short  price        = towerLevel.price;
            string decodingGold = B64X.Decode(TitleScript.gold);
            short  existsGold   = short.Parse(decodingGold);
            if (price > existsGold && button.interactable)
            {
                button.interactable = false;
            }
            else if (price <= existsGold && !button.interactable)
            {
                button.interactable = true;
            }

            currentGold = TitleScript.gold;
        }
    }
    void CheckGoldChange()
    {
        if (tower == null)
        {
            return;
        }

        TowerLevel towerData    = tower.towerData;
        int        price        = towerData.price;
        string     decodingGold = B64X.Decode(levelManager.currentGold);
        int        existsGold   = int.Parse(decodingGold);

        if (price > existsGold && button.interactable)
        {
            button.interactable = false;
        }
        else if (price <= existsGold && !button.interactable)
        {
            button.interactable = true;
        }

        currentGold = levelManager.currentGold;
    }
Beispiel #6
0
    void GoldLabelChange()
    {
        string decodingGold = B64X.Decode(levelManager.currentGold);

        textMeshPro.text = decodingGold;
    }
Beispiel #7
0
    void LifeLabelChange()
    {
        string decodingLife = B64X.Decode(levelManager.currentLivesCount);

        textMeshPro.text = decodingLife;
    }
 /// <summary>
 /// Отобразить количество золота
 /// </summary>
 void WriteGoldCount()
 {
     goldDisplay.GetComponent <Text>().text = B64X.Decode(gold);
 }