Example #1
0
    public void addPuppet(GameObject puppet)
    {
        if (puppets.Count < 6)
        {
            if (buildingMaterials >= 20 && food >= 20)
            {
                setWood(-20);
                setFood(-20);
                int           puppetId      = findEmptyPuppetSlot();
                GameObject    newPuppet     = Instantiate(puppet);
                PuppetManager puppetManager = newPuppet.GetComponent <PuppetManager>();
                puppetManager.puppetId = puppetId;

                //puppetSlots[puppetId].SetActive(true);
                PuppetPanel slotScript = (PuppetPanel)puppetSlots[puppetId].GetComponent(typeof(PuppetPanel));
                slotScript.puppetSlot = newPuppet;
                puppets.Add(newPuppet);
            }
            else
            {
                showEventPanel("You don't have enough resources to create a puppet!");
                if (puppets.Count == 0)
                {
                    gameOverScreen.SetActive(true);
                }
            }
        }
        else
        {
            Debug.Log("No slots available");
        }
    }
Example #2
0
 public void checkSlots()
 {
     foreach (GameObject puppet in puppets)
     {
         PuppetManager puppetManager     = puppet.GetComponent <PuppetManager>();
         GameObject    slot              = puppetSlots[puppetManager.puppetId];
         PuppetPanel   puppetPanelScript = slot.GetComponent <PuppetPanel>();
         puppetPanelScript.puppetSlot = puppet;
     }
 }
Example #3
0
 public int findEmptyPuppetSlot()
 {
     foreach (GameObject slot in puppetSlots)
     {
         PuppetPanel puppetPanel = slot.GetComponent <PuppetPanel>();
         if (puppetPanel.puppetSlot == null)
         {
             return(puppetPanel.slotId);
         }
     }
     return(0);
 }