Example #1
0
    // combine items in equipment
    public void Combine()
    {
        if (radio.GetIsSelected() && items[0] != null && items[0].GetIsSelected()) // if radio and first battery are selected
        {
            radio.AddBattery();                                                    // invoke AddBattery method from Radio to attached radio
            items[0].gameObject.SetActive(false);                                  // mark battery as inactive
            items[0] = null;                                                       // delete battery link from equipment
            stuff[0] = false;                                                      // mark battery as not in equipment
        }

        if (items[1] != null && items[1].GetIsSelected() && items[2] != null && items[2].GetIsSelected())                    // if uv light and second battery are selected
        {
            items[2].GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/Interacive/latarka-charged"); // change UV light sprite to charged sprite
            items[2].ChangeIsSelectedStatus();                                                                               // unselect UV light
            items[1].gameObject.SetActive(false);                                                                            // mark battery as inactive
            items[1] = null;                                                                                                 // delete battery link from equipment
            stuff[1] = false;                                                                                                // mark battery as not in equipment
        }

        if (items[2] != null && items[2].GetIsSelected() && items[2].GetComponent <SpriteRenderer>().sprite.name == "latarka-charged" && items[3] != null && items[3].GetIsSelected() && items[3].GetComponent <SpriteRenderer>().sprite.name == "note") // combine charged uv light with undecoded note
        {
            items[3].gameObject.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Sprites/Interacive/note-code");                                                                                                                        // load decoded note sprite
            items[2].ChangeIsSelectedStatus();                                                                                                                                                                                                           // unselect UV light
            items[3].ChangeIsSelectedStatus();                                                                                                                                                                                                           // unselect note
        }
        // define other cases

        // redifine case scenario don wrong combination
        // foreach (CollectableObject item in items) if (item != null && item.GetIsSelected()) item.ChangeIsSelectedStatus(); // on wrong combination or if success, deselect all selected items
    }