public void AddAlienToFloor(int id)
    {
        // Using it's data we know what type it is, so we instantiate it on the floor. this allows us to retain a ghost copy in the inventory
        createdAlien = Instantiate(aliensArray[idManager.GetAlienType(id)]);                                                                                                // Instantiate an alien based on it's type
        createdAlien.GetComponent <AlienBase>().SetID(id);                                                                                                                  // Set the id of the new alien to the id of the inventory alien

        GameObject.Find("DataManager").GetComponent <IDManager>().SetInventorySlot(id, idManager.GetInventorySlot(id));                                                     // Set the inventory slot to be the slot of the inventory alien
        GameObject.Find("DataManager").GetComponent <IDManager>().SetPosition(id, 2);                                                                                       // Set it's position to be on the floor

        createdAlien.transform.position = new Vector3(Random.Range(0.0f, 2.0f), Random.Range(0.0f, 3.0f), 0);                                                               // Randomize it's position

        GameObject.Find("Inventory").GetComponent <InventoryManager>().AlienOnFloor(false, GameObject.Find("DataManager").GetComponent <IDManager>().GetInventorySlot(id)); // Make it's inventory slot un-interactable
    }
Beispiel #2
0
    public void CreatePanel(int alienID)
    {
        // Set the slider values; We divide by 2 as 2 is the cap at which no stat can surpass. This can be altered
        defenceBar.value       = idManager.GetDefence(alienID) / 2;
        attackSpeedBar.value   = idManager.GetAttackSpeed(alienID) / 2;
        movementSpeedBar.value = idManager.GetMovementSpeed(alienID) / 2;
        damageBar.value        = idManager.GetDamage(alienID) / 2;
        healthBar.value        = idManager.GetHealth(alienID) / 2;
        rangeBar.value         = idManager.GetRange(alienID) / 2;
        alienImage.sprite      = alienImages[idManager.GetAlienType(alienID)]; // Change the alien icon

        alienPosition = idManager.GetPosition(alienID);                        // Set the alienPosition variable to the aliens position so we know which button we are using

        if (scene == 0)
        {
            switch (alienPosition)
            {
            case 0:
                moveBtn.GetComponentInChildren <Text>().text = "Not Owned";
                killBtn.interactable = false;     // If we don't own the alien we can't kill it
                break;

            case 1:
                moveBtn.GetComponentInChildren <Text>().text = "Inv->Floor";
                killBtn.interactable = true;     // If we own the alien and it's in our inventory we can kill it
                break;

            case 2:
                moveBtn.GetComponentInChildren <Text>().text = "Floor->Inv";
                killBtn.interactable = false;     // As a precaution you have to move the alien to your inventory if you want to kill it
                break;
            }
        }
        else if (scene == 2)
        {
            switch (alienPosition)
            {
            case 1:
                moveBtn.GetComponentInChildren <Text>().text = "Inv->BrdSlot";
                break;

            case 3:
                moveBtn.GetComponentInChildren <Text>().text = "BrdSlot->Inv";
                break;
            }
        }

        clickedAlienID = alienID; // Saved so we know which alien we need to move in MoveButtonClicked()
    }
Beispiel #3
0
 public void AddToBreedingSlot(int alienID)
 {
     if (!slot1Occupied || !slot2Occupied)
     {
         idManager.SetPosition(alienID, 3);
         itemParent.transform.GetChild(idManager.GetInventorySlot(alienID)).GetChild(0).GetComponent <Button>().interactable = false; // Make the aliens inventory slot un-interactable
         if (!slot1Occupied)
         {
             id1           = alienID;                                                                                                   // Set the first id slot variable to the alien ID
             slot1Occupied = true;                                                                                                      // Set the first slot variable to be occupied
             Alien1Slot.transform.GetChild(0).GetChild(0).GetComponent <Image>().enabled = true;                                        // Enable the image
             Alien1Slot.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite  = alienIcons[idManager.GetAlienType(alienID)]; // Set the sprite based on the alien type
         }
         else if (!slot2Occupied)
         {
             id2           = alienID;
             slot2Occupied = true;
             Alien2Slot.transform.GetChild(0).GetChild(0).GetComponent <Image>().enabled = true;
             Alien2Slot.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite  = alienIcons[idManager.GetAlienType(alienID)];
         }
         statPanel.ClosePanel();
     }
 }
Beispiel #4
0
    public void AddToInventory(int alienID)
    {
        if (idManager.GetInventorySlot(alienID) == -1) // If the alien doesn't have a pre-defined slot
        {
            // Get an empty slot index
            for (int i = 0; i < invSlots.Length; i++)
            {
                if (invSlots[i].IsEmpty())
                {
                    emptySlotIndex = i;
                    break;
                }
            }

            // Set the inventory slot of the alien to the empty one we just found
            idManager.SetInventorySlot(alienID, emptySlotIndex);
        }
        else
        {
            // If the alien already has a slot then set the empty slot index to that slot
            emptySlotIndex = idManager.GetInventorySlot(alienID);
        }

        // Set slot value to a string of the aliens stats. Slot4 = "1/0/1/etc.." so we can retrieve anywhere
        PlayerPrefs.SetString("slot" + emptySlotIndex.ToString(), alienID.ToString());

        // Set the image of the slot to be identical to the alien
        itemParent.transform.GetChild(emptySlotIndex).GetChild(0).GetChild(0).GetComponent <Image>().enabled = true;
        itemParent.transform.GetChild(emptySlotIndex).GetChild(0).GetChild(0).GetComponent <Image>().sprite  = alienIcons[idManager.GetAlienType(alienID)];

        if (idManager.GetPosition(alienID) == 2) // If the alien is on the floor make it's button un-interactable
        {
            itemParent.transform.GetChild(emptySlotIndex).GetChild(0).GetComponent <Button>().interactable = false;
        }

        // Set the inventory slot we're inserting into to be not empty
        invSlots[emptySlotIndex].MakeNotEmpty();
    }