Пример #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();
    }
Пример #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();
        }
    }
Пример #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();
    }
Пример #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;
    }
Пример #6
0
    void GoldLabelChange()
    {
        string decodingGold = B64X.Decode(levelManager.currentGold);

        textMeshPro.text = decodingGold;
    }
Пример #7
0
    void LifeLabelChange()
    {
        string decodingLife = B64X.Decode(levelManager.currentLivesCount);

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