示例#1
0
    void Inventory()
    {
        if (Building.Inventory == null)
        {
            return;
        }

        if (_showAInventory == null)
        {
            _showAInventory = new ShowAInventory(Building.Inventory, _gaveta.gameObject, _invIniPos.transform.localPosition);
            ShowProductionReport();
        }
        else if (oldBuildID != Building.MyId)
        {
            oldBuildID    = Building.MyId;
            oldItemsCount = Building.Inventory.InventItems.Count;

            _showAInventory.DestroyAll();
            _showAInventory = new ShowAInventory(Building.Inventory, _gaveta.gameObject, _invIniPos.transform.localPosition);

            //so when a new building is clicked changes
            ShowProductionReport();
        }
        else if (_showAInventory != null && (oldItemsCount != Building.Inventory.InventItems.Count ||
                                             Building.IsToReloadInv()))
        {
            //if new items got in the inv needs to redo Stats in case is a new production
            if (oldItemsCount != Building.Inventory.InventItems.Count)
            {
                ReloadStatsWhenNeeded(true);
                oldItemsCount = Building.Inventory.InventItems.Count;
            }
            _showAInventory.UpdateToThisInv(Building.Inventory);
        }

        ReloadStatsWhenNeeded();

        _showAInventory.ManualUpdate();
        _inv.text = BuildStringInv(Building);
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        updCount++;
        //means is showing
        if (Vector3.Distance(transform.position, iniPos) < 0.1f)
        {
            if (updCount > 6)
            {
                updCount = 0;
                LoadMenu();
                //print("Reloaded");
            }
        }

        if (_showAInventory != null)
        {
            _showAInventory.UpdateToThisInv(_person.Inventory);
        }

        //if click gen
        if (_genBtnRect.Contains(Input.mousePosition) && Input.GetMouseButtonUp(0))
        {
            MakeThisTabActive(_general);
        }
        //ig click inv
        else if (_invBtnRect.Contains(Input.mousePosition) && Input.GetMouseButtonUp(0))
        {
            MakeThisTabActive(_gaveta);
        }

        //then update inv info all the time
        if (_person != null && _inv != null && !string.IsNullOrEmpty(_inv.text))
        {
            _inv.text = BuildStringInv(_person);
        }
    }