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

        existsGold += goldToAdd;
        gold        = B64X.Encode(existsGold.ToString());
        WriteGoldCount();
    }
Esempio n. 2
0
    /// <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();
        }
    }
Esempio n. 3
0
    /// <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();
    }
Esempio n. 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;
    }
Esempio n. 6
0
    void GoldLabelChange()
    {
        string decodingGold = B64X.Decode(levelManager.currentGold);

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

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