Beispiel #1
0
    public void Breed()
    {
        statPanel.ClosePanel();
        GameObject.Find("Inventory").GetComponent <OpenCloseInv>().OpenClose();

        // Here would be all the logic for which parents make which babies
        babyToMake = "Qayrat";

        switch (babyToMake)
        {
        case "Jaotop":
            babyInstance = Instantiate(alienArray[0]);
            babyType     = 0;
            break;

        case "Qayrat":
            babyInstance = Instantiate(alienArray[1]);
            babyType     = 1;
            break;
        }

        // set the min and max
        babyInstance.GetComponent <AlienBase>().SetDefenceMinMax(Mathf.Min(idManager.GetDefence(id1), idManager.GetDefence(id2)) * 0.9f,
                                                                 Mathf.Max(idManager.GetDefence(id1), idManager.GetDefence(id2)) * 1.1f);

        babyInstance.GetComponent <AlienBase>().SetAttackSpeedMinMax(Mathf.Min(idManager.GetAttackSpeed(id1), idManager.GetAttackSpeed(id2)) * 0.9f,
                                                                     Mathf.Max(idManager.GetAttackSpeed(id1), idManager.GetAttackSpeed(id2)) * 1.1f);

        babyInstance.GetComponent <AlienBase>().SetMovementSpeedMinMax(Mathf.Min(idManager.GetMovementSpeed(id1), idManager.GetMovementSpeed(id2)) * 0.9f,
                                                                       Mathf.Max(idManager.GetMovementSpeed(id1), idManager.GetMovementSpeed(id2)) * 1.1f);

        babyInstance.GetComponent <AlienBase>().SetDamageMinMax(Mathf.Min(idManager.GetDamage(id1), idManager.GetDamage(id2)) * 0.9f,
                                                                Mathf.Max(idManager.GetDamage(id1), idManager.GetDamage(id2)) * 1.1f);

        babyInstance.GetComponent <AlienBase>().SetHealthMinMax(Mathf.Min(idManager.GetHealth(id1), idManager.GetHealth(id2)) * 0.9f,
                                                                Mathf.Max(idManager.GetHealth(id1), idManager.GetHealth(id2)) * 1.1f);

        babyInstance.GetComponent <AlienBase>().SetRangeMinMax(Mathf.Min(idManager.GetRange(id1), idManager.GetRange(id2)) * 0.9f,
                                                               Mathf.Max(idManager.GetRange(id1), idManager.GetRange(id2)) * 1.1f);

        babyInstance.GetComponent <AlienBase>().GenerateBase();
        babyInstance.GetComponent <AlienBase>().GenerateScore();
        babyInstance.GetComponent <AlienBase>().GenerateID(babyType, 1);
        id3 = babyInstance.GetComponent <AlienBase>().GetID();
        invent.AddToInventory(id3);
        Destroy(babyInstance);

        GameObject.Find("Alien3Panel").GetComponent <Animator>().SetBool("babyFade", true);

        idManager.SetPosition(id3, 3);
        itemParent.transform.GetChild(idManager.GetInventorySlot(id3)).GetChild(0).GetComponent <Button>().interactable = false;
        Alien3Slot.transform.GetChild(0).GetChild(0).GetComponent <Image>().enabled = true;                                    // Enable the image
        Alien3Slot.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite  = alienIcons[idManager.GetAlienType(id3)]; // Set the sprite based on the alien type

        RemoveFromBreedingSlot(id1);
        RemoveFromBreedingSlot(id2);
    }
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()
    }