Esempio n. 1
0
    void Start()
    {
        //FH = GameObject.Find("GameManager").GetComponent<scr_FileHandler>();
        BM = GameObject.FindGameObjectWithTag("bag").GetComponent <scr_bagMovement>();

        score = transform.Find("score").GetComponent <Text>();
        scoreUntillNextMedal = transform.Find("scoreUntillNextMedal").GetComponent <Text>();
        scoreMax             = transform.Find("scoreMax").GetComponent <Text>();
        remainingBags        = transform.Find("bagsleft").GetComponent <Text>();;
        gold = transform.Find("gold").GetComponent <Text>();
        //bagsLeft[0] = GameObject.Find("Bag_Wheat1");
        //bagsLeft[1] = GameObject.Find("Bag_Wheat2");
        //bagsLeft[2] = GameObject.Find("Bag_Wheat3");

        //Searching the scene for GameObject
        potionSelect = GameObject.Find("active0");

        for (int i = 0; i < bagsLeft.Length; i++)
        {
            bagsLeft[i] = GameObject.Find("bagWheat" + i.ToString());


            // Debug.Log("How many bags are left: " + GM.GetRemainingBags());
            //Finds active potions
        }
        for (int i = 0; i < activePotions.Length; i++)
        {
            activePotions[i] = FH.GetEquipedPotions(i);
        }

        //SpriteRenderer sr = new SpriteRenderer();
        //sr = potionsLeft[i].GetComponent<SpriteRenderer>();
        //sr.sprite = potionsSprites[0];

        for (int i = 0; i < potionsLeft.Length; i++)
        {
            potionsLeft[i] = GameObject.Find("Potion" + i.ToString());
            potionsLeft[i].GetComponent <SpriteRenderer>().sprite = potionsSprites[activePotions[i]];
        }

        //for (int i = 0; i < potionsLeft.Length; i++)
        //{
        //    potionSelect[i] = GameObject.Find("active" + i.ToString());
        //    //potionSelect[i].gameObject.SetActive
        //    //potionsLeft[i].GetComponent<SpriteRenderer>().sprite
        //}
    }
Esempio n. 2
0
    void Start()
    {
        potionSelected    = false;
        selectedTransform = null;
        ableToMove        = true;
        Inventory_BG      = transform.FindChild("Inventory_BG");
        potion_info_BG    = GameObject.Find("potion_info_BG").transform;
        accept            = GameObject.Find("potion_accept").gameObject;
        decline           = GameObject.Find("potion_decline").gameObject;

        FH     = GetComponent <scr_FileHandler>();
        m_gold = FH.GetGold();
        potion_info_Picture = GameObject.Find("potionPicture").GetComponent <SpriteRenderer>();
        potion_info_BG.gameObject.SetActive(false);
        accept.SetActive(false);
        decline.SetActive(false);
        potion_info_Picture.gameObject.SetActive(false);


        canvas  = transform.FindChild("Canvas");
        m_texts = new Text[canvas.childCount];
        for (int i = 0; i < m_texts.Length; i++)
        {
            m_texts[i]         = canvas.GetChild(i).GetComponent <Text>();
            m_texts[i].enabled = false;
        }
        Equipment_BG   = transform.FindChild("Equipment_BG");
        potion_0_0     = GameObject.Find("potion_0_0").transform;
        equipmentSlots = GameObject.FindGameObjectsWithTag("slot");
        for (int i = 0; i < equipmentSlots.Length; i++)
        {
            ES[i]             = equipmentSlots[i].GetComponent <scr_EquipmentSlot>();
            equipedPotions[i] = FH.GetEquipedPotions(i);
        }
        InvetoryPotion[,] potions = FH.GetInventory();

        for (int x = 0; x < equipedPotions.Length; x++)
        {
            for (int i = 0; i < InventorySize.x; i++)
            {
                for (int y = 0; y < InventorySize.y; y++)
                {
                    InvetoryPotion IP = new InvetoryPotion();
                    IP.m_potionType  = potions[i, y].m_potionType;
                    IP.m_description = potionDescritions[IP.m_potionType];
                    IP.m_unlocked    = potions[i, y].m_unlocked;
                    GameObject obj = (GameObject)Instantiate(l_potionTypes[IP.m_potionType], Inventory_BG);
                    obj.transform.position = new Vector2(potion_0_0.position.x + InvetoryItemSpace.x * i, potion_0_0.position.y - InvetoryItemSpace.y * y);
                    IP.m_obj         = obj;
                    IP.m_goldCost    = UnityEngine.Random.Range(5, 15);
                    IP.m_bought      = potions[i, y].m_bought;
                    IP.m_originalPos = obj.transform.position;


                    if (IP.m_potionType == equipedPotions[x] && ES[x].GetAttachedPotion() == null)
                    {
                        Debug.Log("Setting");
                        ES[x].SetAttachedPotion(obj);
                        IP.m_unlocked = true;
                        IP.m_bought   = true;
                    }
                    l_Inventory.Add(IP);
                    SpriteRenderer sr = IP.m_obj.GetComponent <SpriteRenderer>();
                    if (!IP.m_bought)
                    {
                        sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, 0.2f);
                    }
                    if (!IP.m_unlocked)
                    {
                        sr.color = Color.black;
                    }
                }
            }
        }
    }
    PotionType GetPotionType()
    {
        int index = FH.GetEquipedPotions(GM.GetRemainingBags());

        return(m_potionType[index]);
    }