override protected bool TakeWeapon(WeaponItem item) { if (coins >= item.price) { int i = 0; int emptySlot = weapons.Count; foreach (WeaponItem player_weapon in weapons) { if (player_weapon != null) { if (player_weapon.itemName == item.itemName) //Если такое оружие уже есть у игрока { player_weapon.GetComponentInChildren <Weapon>().ammo += item.GetComponentInChildren <Weapon>().ammo; Destroy(item.gameObject); return(false); } } else { emptySlot = i; break; } i++; } if (emptySlot == weapons.Count) { weapons.Add(item); } else { weapons[emptySlot] = item; } if (emptySlot == weaponIndex) { item.GetComponentInChildren <Weapon>().Show(); weapon = weapons[weaponIndex].GetComponent <WeaponItem>().weapon; } else { item.GetComponentInChildren <Weapon>().Hide(); } coins -= item.price; if (FacingRight == false) { item.Flip(); } actionBar.RefreshWeapon(); actionBar.DisplayInfoText(item.description); return(true); } actionBar.RefreshWeapon(); return(false); }