示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        equippedItem = ItemInfo.ItemType.None;

        audioSource = this.gameObject.GetComponent <AudioSource>();

        soundRepo = GameObject.FindObjectOfType <SoundRepo>();
    }
示例#2
0
    public void UseWeapon(ItemInfo.ItemType item, Vector2 origin, Vector2 direction)
    {
        if (item == ItemInfo.ItemType.Sword && !swordCD)
        {
            UseSword(origin, direction);
        }

        if (item == ItemInfo.ItemType.Gun && !gunCD)
        {
            UseGun(origin, direction);
        }
    }
示例#3
0
    IEnumerator WeaponCD_CR(ItemInfo.ItemType item)
    {
        if (item == ItemInfo.ItemType.Sword)
        {
            yield return(new WaitForSeconds(swordCDTime));

            swordCD = false;
        }

        if (item == ItemInfo.ItemType.Gun)
        {
            yield return(new WaitForSeconds(gunCDTime));

            gunCD = false;
        }

        yield return(null);
    }
示例#4
0
    public bool EquipItem(ItemInfo.ItemType item)
    {
        if (!hasHands || hasHead)
        {
            return(false);
        }

        if (equippedItem == item)
        {
            return(false);
        }
        else
        {
            equippedItem = item;
            DropEquippedItem();

            return(true);
        }
    }
示例#5
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);
    }