Exemplo n.º 1
0
    public void LoseRandomBodyPart()
    {
        if (playerHealthBuffer > 0)
        {
            playerHealthBuffer--;

            return;
        }

        List <BodypartInfo.BodyPart> currentBodyParts = new List <BodypartInfo.BodyPart>();

        if (hasHands)
        {
            currentBodyParts.Add(BodypartInfo.BodyPart.Hands);
        }

        if (hasLegs)
        {
            currentBodyParts.Add(BodypartInfo.BodyPart.Legs);
        }

        if (hasChest)
        {
            currentBodyParts.Add(BodypartInfo.BodyPart.Chest);
        }

        if (hasHead)
        {
            currentBodyParts.Add(BodypartInfo.BodyPart.Head);
        }

        if (hasHeart)
        {
            currentBodyParts.Add(BodypartInfo.BodyPart.Heart);
        }

        //Choose random body part

        if (currentBodyParts.Count == 0)
        {
            return;
        }

        int randInt = Random.Range(0, currentBodyParts.Count);

        BodypartInfo.BodyPart dropPart = currentBodyParts[randInt];

        SetBodyPart(dropPart, false);
    }
Exemplo n.º 2
0
    public bool SetBodyPart(BodypartInfo.BodyPart bodyPartToSet, bool isAdd)
    {
        if (bodyPartToSet == BodypartInfo.BodyPart.Hands && (!hasHands || !isAdd))
        {
            hasHands = isAdd;

            if (isAdd)
            {
                audioSource.PlayOneShot(soundRepo.gainBodyPart);
            }

            if (!isAdd)
            {
                equippedItem = ItemInfo.ItemType.None;
                DropEquippedItem();
            }

            return(true);
        }

        if (bodyPartToSet == BodypartInfo.BodyPart.Legs && (!hasLegs || !isAdd))
        {
            hasLegs = isAdd;

            if (isAdd)
            {
                audioSource.PlayOneShot(soundRepo.gainBodyPart);
            }

            return(true);
        }

        if (bodyPartToSet == BodypartInfo.BodyPart.Chest && (!hasChest || !isAdd))
        {
            hasChest = isAdd;

            if (isAdd)
            {
                BufferHealthModifier(chestHealth);
                audioSource.PlayOneShot(soundRepo.gainBodyPart);
            }
            else
            {
                BufferHealthModifier(-chestHealth);
            }

            return(true);
        }

        if (bodyPartToSet == BodypartInfo.BodyPart.Head && (!hasHead || !isAdd))
        {
            hasHead = isAdd;

            if (isAdd)
            {
                equippedItem = ItemInfo.ItemType.None;

                audioSource.PlayOneShot(soundRepo.gainBodyPart);

                DropEquippedItem();
            }

            return(true);
        }

        if (bodyPartToSet == BodypartInfo.BodyPart.Heart && (!hasHeart || !isAdd))
        {
            //If adding heart check if the player has all the other parts. If not, return false.
            if (isAdd)
            {
                if (!hasChest || !hasHands || !hasLegs || !hasHead)
                {
                    return(false);
                }
            }

            hasHeart = isAdd;
            return(true);
        }

        return(false);
    }