// Start is called before the first frame update void Start() { equippedItem = ItemInfo.ItemType.None; audioSource = this.gameObject.GetComponent <AudioSource>(); soundRepo = GameObject.FindObjectOfType <SoundRepo>(); }
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); } }
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); }
public bool EquipItem(ItemInfo.ItemType item) { if (!hasHands || hasHead) { return(false); } if (equippedItem == item) { return(false); } else { equippedItem = item; DropEquippedItem(); return(true); } }
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); }