void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("sea")) { // harpoonID myPlayer.GetComponent <Inventory>().AddWeapon(wpdb.FetchItemByID(4)); // do some visual feedback PhotonNetwork.Destroy(gameObject); } }
//Choses 4 random weapons for the player to use. void GetRandomWeapons() { int[] IDs = { 999, 999, 999, 999 }; for (int i = 0; i < IDs.Length; i++) { int newID = 0; bool IDfoundIsValid = false; //Generate new weapon ID while weapon ID is not valid. while (!IDfoundIsValid) { newID = Random.Range(0, 6); IDfoundIsValid = WeaponIDValid(newID, IDs); } IDs[i] = newID; inventory.guns.Add(weaponDatabase.FetchItemByID(newID)); } }
public void AddWeapon(Item weaponToAdd) { if (guns.Count < 4) { // if item is throwable and inventory doesnt contain squid, // or if item is not throwable if ((weaponToAdd.Slug == "throwable" && !guns.Contains(weapons.FetchItemByID(2))) || weaponToAdd.Slug != "throwable") { guns.Add(weaponToAdd); // we could force auto switch here 'autoswitch, auto-switch' } else { // else if inventory contains squid, add to squid's ammo // squidgun.currentammo ++; foreach (Item gun in guns) { if (gun.Slug == "squid") { gun.CurrentAmmo++; } } } } }