GameScript.updateUI C# (CSharp) Method

updateUI() public method

public updateUI ( ) : void
return void
    public void updateUI()
    {
        Debug.Log("UpdateUI");

        txtFirstCurrencyName.text = "";
        txtFirstCurrencyValue.text = "";
        txtSecondCurrencyName.text = "";
        txtSecondCurrencyValue.text = "";

        Currency firstCurrency = null;
        Currency secondCurrency = null;

        if (Spil.PlayerData.Wallet.Currencies.Count > 0)
        {
            firstCurrency = Spil.PlayerData.Wallet.Currencies[0];
            txtFirstCurrencyName.text = firstCurrency.Name + ":";
        }

        if (Spil.PlayerData.Wallet.Currencies.Count > 1)
        {
            secondCurrency = Spil.PlayerData.Wallet.Currencies[1];
            txtSecondCurrencyName.text = secondCurrency.Name + ":";
        }

        PlayerCurrency playerFirstCurrency = null;
        PlayerCurrency playerSecondCurrency = null;

        for (int i = 0; i < Spil.PlayerData.Wallet.Currencies.Count; i++)
        {
            if (firstCurrency != null && firstCurrency.Id == Spil.PlayerData.Wallet.Currencies[i].Id)
            {
                playerFirstCurrency = Spil.PlayerData.Wallet.Currencies[i];
            }
            if (secondCurrency != null && secondCurrency.Id == Spil.PlayerData.Wallet.Currencies[i].Id)
            {
                playerSecondCurrency = Spil.PlayerData.Wallet.Currencies[i];
            }
        }

        if (playerFirstCurrency != null)
        {
            txtFirstCurrencyValue.text = playerFirstCurrency.CurrentBalance.ToString();
        } else {
            txtFirstCurrencyValue.text = "";
        }

        if (playerSecondCurrency != null)
        {
            txtSecondCurrencyValue.text = playerSecondCurrency.CurrentBalance.ToString();
        } else {
            txtSecondCurrencyValue.text = "";
        }

        showInventory();
    }