public void SelectItem(int id)
    {
        if (previousID != -1)
        {
            // Turn off previous ID selected
            InventoryPageClick tile = IPC.getItemTile(previousID).GetComponent <InventoryPageClick>();
            tile.Deselect();
        }
        // Name
        Text name = RightPanel.transform.GetChild(0).GetComponent <Text>();
        // Image
        Image image = RightPanel.transform.GetChild(1).GetComponent <Image>();
        // Description
        Text description = RightPanel.transform.GetChild(2).GetComponent <Text>();
        // Amount
        Text amount = RightPanel.transform.GetChild(3).GetComponent <Text>();

        // check if it has been collected
        if (IC.checkCollected(id))
        {
            Item item = IDC.getItem(id);
            // set the selected rect
            InventoryPageClick tile = IPC.getItemTile(id).GetComponent <InventoryPageClick>();
            tile.Select();
            previousID = id;

            name.text        = item.getName();
            image.sprite     = IDC.getSprite(id);
            description.text = item.getDescription();
            if (IC.getCollectedAmount(id) > 99)
            {
                amount.text = "99+";
            }
            else
            {
                amount.text = IC.getCollectedAmount(id).ToString();
            }
        }
        else
        {
            // set the selected rect
            InventoryPageClick tile = IPC.getItemTile(id).GetComponent <InventoryPageClick>();
            tile.Select();
            previousID = id;

            // not collected, so set as default
            name.text        = "Locked";
            image.sprite     = locked;
            description.text = "Locked";
            amount.text      = "0";
        }
    }
    void LoadLab()
    {
        // Populate the Rows of the lab inventory
        for (int i = 0; i < Content.transform.childCount; i++)
        {
            // Go to 0 to 9 (1-10) for each inventory item
            for (int j = 0; j < rowLength; j++)
            {
                int id = i * rowLength + j;
                // LPSC
                Content.transform.GetChild(i).transform.GetChild(j).GetComponent <LabPageClick>().setID(id);
                // icon
                Image image = Content.transform.GetChild(i).transform.GetChild(j).GetComponent <Image>();
                // count (1) child is text
                Text count = Content.transform.GetChild(i).transform.GetChild(j).transform.GetChild(1).GetComponent <Text>();
                // print ("check " + IC.checkCollected (id) + " " + id);
                if (IC.checkCollected(id))
                {
                    // use IDC
                    image.sprite = IDC.getSprite(id);
                    count.text   = IC.getCollectedAmount(id).ToString();
                }
                else
                {
                    count.text = "";
                }
            }
        }
        // Set ID for the item slots so it can be identified
        // Child 0, 1 get the component to set the ID
        SlotOne.transform.GetChild(1).GetComponent <LabPageItemSlotClick>().setID(0);
        SlotTwo.transform.GetChild(1).GetComponent <LabPageItemSlotClick>().setID(1);

        // Set result to -1 so it cannot be affected
        ResultSlot.GetComponent <LabPageItemSlotClick>().setID(-1);
    }
示例#3
0
    void CreateCards()
    {
        if (wait1 < 5 || CardHolder.transform.childCount != 0)
        {
            return;
        }
        else
        {
            wait1 = 0;
        }

        // materialize the Cards on the screen ui
        int OpenCount = IC.getHowManyToOpen();

        for (int i = 0; i < OpenCount; i++)
        {
            // call random
            int id = RNGcontroller.getRandom();
            // look up id in directory of items, make the item
            Item   item        = IDC.getItem(id);
            string name        = item.getName();
            string description = item.getDescription();
            Sprite spritetouse = IDC.getSprite(id);

            Transform  place       = CardPlaces.transform.GetChild(i).transform;
            Vector3    position    = place.position;
            GameObject CardCreated = Instantiate(Card, position, Quaternion.identity);

            // Access BF_Card for the card and set the item to the script
            BF_Card BFC = CardCreated.transform.GetChild(0).GetComponent <BF_Card>();
            BFC.setItem(item);

            // Edit item image
            SpriteRenderer spriterenderer = CardCreated.transform.GetChild(1).transform.GetChild(2).GetComponent <SpriteRenderer>();
            spriterenderer.sprite = spritetouse;
            // edit the Card to have the Name
            TextMesh namemesh = CardCreated.transform.GetChild(1).transform.GetChild(3).GetComponent <TextMesh>();
            namemesh.text = name;
            // edit the description
            TextMesh descriptionmesh = CardCreated.transform.GetChild(1).transform.GetChild(4).GetComponent <TextMesh>();
            descriptionmesh.text = description;

            // parent is Cards holder
            CardCreated.transform.parent = CardHolder.transform;
        }
    }
    void MakeCards()
    {
        if (wait >= 5)
        {
            wait = 0;
        }
        else
        {
            return;
        }

        // Destroy old cards
        for (int i = 0; i < CardHolder.transform.childCount; i++)
        {
            Destroy(CardHolder.transform.GetChild(i).gameObject);
        }
        // Drop Chest
        GameObject ChestDropped = Instantiate(Chest, new Vector3(1, 7, 1), Quaternion.identity);

        Destroy(ChestDropped, 3f);
        // Check IC for how many to open
        int amount = IC.getHowManyToOpen();

        // Create the cards
        for (int i = 0; i < amount; i++)
        {
            GameObject newcard = Instantiate(Card, CardPlaces.transform.GetChild(i).transform.position, Quaternion.identity);
            // Roll RNG
            int id = RNGC.getRandom();

            // Set icon of card
            newcard.transform.GetChild(1).GetComponent <SpriteRenderer>().sprite = IDC.getSprite(id);
            IC.AddToInventory(id);

            newcard.transform.SetParent(CardHolder.transform);
        }

        // Increment IC
        IC.IncrementNumberOpened();
    }
示例#5
0
    void CreateCards()
    {
        if (wait > 4)
        {
            wait = 0;
        }
        else
        {
            return;
        }

        // Delete old CardHolder cards
        for (int i = 0; i < CardHolder.transform.childCount; i++)
        {
            Destroy(CardHolder.transform.GetChild(i).gameObject);
        }

        // Create amount
        int OpenAmount = IC.getHowManyToOpen();

        for (int i = 0; i < OpenAmount; i++)
        {
            GameObject newcard = Instantiate(card, CardPlaces.transform.GetChild(i).position, Quaternion.identity);

            int id = PRC.getRandom();
            // Set the icon
            newcard.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = IDC.getSprite(id);

            // Add to the inventory
            IC.AddToInventory(id);

            newcard.transform.SetParent(CardHolder.transform);
        }

        // Increment IC
        IC.IncrementNumberOpened();
    }
示例#6
0
    public void MakeCards()
    {
        for (int i = 0; i < IC.getHowManyToOpen(); i++)
        {
            // Random is for the different colour bottoms
            int choose = Random.Range(0, 3);
            int id;
            if (choose == 0)
            {
                GameObject CreatedCard = Instantiate(Card1, Positions.transform.GetChild(i).transform.position, Quaternion.identity);
                CreatedCard.transform.SetParent(CardHolder.transform);

                // Image
                SpriteRenderer renderer = CreatedCard.transform.GetChild(1).GetComponent <SpriteRenderer> ();
                // Name
                TextMesh name = CreatedCard.transform.GetChild(2).GetComponent <TextMesh> ();

                // Call rng controller for stuff
                id = RNGC.getRandom();
                Item item = IDC.getItem(id);

                // change icon
                renderer.sprite = IDC.getSprite(id);

                // change name
                name.text = item.getName();

                // add to the inventory
                IC.AddToInventory(id);
            }
            else if (choose == 1)
            {
                GameObject CreatedCard = Instantiate(Card2, Positions.transform.GetChild(i).transform.position, Quaternion.identity);
                CreatedCard.transform.SetParent(CardHolder.transform);

                // Image
                SpriteRenderer renderer = CreatedCard.transform.GetChild(1).GetComponent <SpriteRenderer> ();
                // Name
                TextMesh name = CreatedCard.transform.GetChild(2).GetComponent <TextMesh> ();

                // Call rng controller for stuff
                id = RNGC.getRandom();
                Item item = IDC.getItem(id);

                // change icon
                renderer.sprite = IDC.getSprite(id);

                // change name
                name.text = item.getName();

                // add to the inventory
                IC.AddToInventory(id);
            }
            else if (choose == 2)
            {
                GameObject CreatedCard = Instantiate(Card3, Positions.transform.GetChild(i).transform.position, Quaternion.identity);
                CreatedCard.transform.SetParent(CardHolder.transform);

                // Image
                SpriteRenderer renderer = CreatedCard.transform.GetChild(1).GetComponent <SpriteRenderer> ();
                // Name
                TextMesh name = CreatedCard.transform.GetChild(2).GetComponent <TextMesh> ();

                // Call rng controller for stuff
                id = RNGC.getRandom();
                Item item = IDC.getItem(id);

                // change icon
                renderer.sprite = IDC.getSprite(id);

                // change name
                name.text = item.getName();

                // add to the inventory
                IC.AddToInventory(id);
            }
        }

        // Increment IC
        IC.IncrementNumberOpened();
    }