Example #1
0
    private void updateInventoryPanel()
    {
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation player      = State.getNations()[playerIndex];

        if (PlayerCalculator.canUpgradeWarehouse(player))
        {
            expandWarehouseButton.interactable = true;
        }
        else
        {
            expandWarehouseButton.interactable = false;
        }
        storageCapacity.text = player.numberOfResourcesAndGoods().ToString() + "/" +
                               player.GetCurrentWarehouseCapacity().ToString();

        int       numResources = 11;
        Transform storage      = inventoryContent.GetComponent <Transform>();

        for (int i = 0; i < numResources; i++)
        {
            string           name   = storage.GetChild(i).name;
            MyEnum.Resources res    = (MyEnum.Resources)System.Enum.Parse(typeof(MyEnum.Resources), name);
            Text             amount = storage.GetChild(i).GetComponentInChildren <Text>();
            amount.text = player.getNumberResource(res).ToString();
        }
        int beginGoods        = 11;
        int endOfStoragePanel = 23;

        for (int i = beginGoods; i < endOfStoragePanel; i++)
        {
            string       name = storage.GetChild(i).name;
            MyEnum.Goods good = (MyEnum.Goods)System.
                                Enum.Parse(typeof(MyEnum.Goods), name);

            Text amount = storage.GetChild(i).GetComponentInChildren <Text>();
            amount.text = player.getNumberGood(good).ToString();
        }
    }