Exemplo n.º 1
0
    public void RefreshItemWheel()
    {
        if (GameManager.Inventory == null || GameManager.Inventory.Items == null)
        {
            return;
        }

        int slot      = 0;
        int itemIndex = 0;

        // dont use first slot for now
        _itemQuads [slot].GetComponent <Renderer>().enabled      = false;
        _itemCountQuads [slot].GetComponent <Renderer>().enabled = false;
        slot++;

        // show what we can
        while ((slot < 5) && (itemIndex <= GameManager.Inventory.Items.Count - 1))
        {
            _itemQuads [slot].GetComponent <Renderer>().enabled = true;
            _itemQuads [slot].GetComponent <Renderer>().material.mainTexture = GameManager.Inventory.Items [itemIndex].GetTexture();
            _itemQuads [slot].GetComponent <ItemQuad>().invItem = GameManager.Inventory.Items [itemIndex];

            _itemCountQuads [slot].GetComponent <Renderer>().enabled = true;
            _itemCountQuads [slot].GetComponent <Renderer>().material.mainTexture = CountQuadFactory.GetTextureForCount(GameManager.Inventory.Items [itemIndex].Quantity);

            slot++;
            itemIndex++;
        }

        // hide any unfilled.
        while (slot < 5)
        {
            _itemQuads [slot].GetComponent <Renderer>().enabled      = false;
            _itemCountQuads [slot].GetComponent <Renderer>().enabled = false;
            slot++;
        }
    }
Exemplo n.º 2
0
    public void RefreshWeaponWheel()
    {
        int weaponToShow = _currentWeapon;
        int weaponPos    = 1;
        int weaponsShown = 0;

        // no items means skip to the section where we hide the quads.
        bool bPlacedAll = (GameManager.Inventory.Weapons.Count == 0);

        while (!bPlacedAll)
        {
            // show proper texture
            _weaponQuads [weaponPos].gameObject.GetComponent <Renderer>().enabled = true;
            _weaponQuads [weaponPos].gameObject.GetComponent <Renderer>().material.mainTexture = GameManager.Inventory.Weapons [weaponToShow].IconTexture;

            WeaponQuad wq = _weaponQuads [weaponPos].gameObject.GetComponent <WeaponQuad>();
            wq.Title       = GameManager.Inventory.Weapons [weaponToShow].Title;
            wq.Description = GameManager.Inventory.Weapons [weaponToShow].Description;

            _weaponCountQuads [weaponPos].gameObject.GetComponent <Renderer>().enabled = true;
            _weaponCountQuads [weaponPos].gameObject.GetComponent <Renderer>().material.mainTexture = CountQuadFactory.GetTextureForCount(GameManager.Inventory.Weapons [weaponToShow].Quantity);

            weaponToShow = (weaponToShow + 1) % GameManager.Inventory.Weapons.Count;
            weaponPos    = (weaponPos + 1) % 3;
            weaponsShown++;


            // placed 3 or all of our stuff, stop trying
            bPlacedAll = (weaponsShown == 3 || weaponsShown == GameManager.Inventory.Weapons.Count);
        }

        // *** hide the slots that didn't get filled ***
        while (weaponsShown < 3)
        {
            _weaponQuads [weaponPos].gameObject.GetComponent <Renderer>().enabled      = false;
            _weaponCountQuads [weaponPos].gameObject.GetComponent <Renderer>().enabled = false;


            weaponPos = (weaponPos + 1) % 3;
            weaponsShown++;
        }

        // select the weapon
        if (GameManager.Inventory.Weapons.Count > 0 &&
            (GameManager.Inventory.CurrentWeapon != GameManager.Inventory.Weapons [_currentWeapon]))
        {
            GameManager.Inventory.CurrentWeapon = GameManager.Inventory.Weapons [_currentWeapon];
        }
    }