i wrote script about Shooting game so i want to stop 2 auio if (CurAmmoCound ==0&InventoryAmmoCount == 0). but when i wrote audio.Stop (Reload); and audio.Stop(Fire); it shows error like this: No overload for method Stop' takes
1’ arguments.
so there is my script and pls help me:
using UnityEngine;
using System.Collections;
public class Shooting : MonoBehaviour {
public Transform bullet; //ტყვიის პრეფაბი
public GameObject AK;
public GUISkin MySkin; //გუისკინის ასარჩევი
public Texture2D AimTexture; //მიზნის ტექსტურა
public int BulletForce = 5000; //ტყვიის სიჩქარე
public int CurAmmoCount = 30; //ახლანდელი ტყვიების რაოდენობის ცვლადი
public int MaxAmmoCount = 10; //მაქსიმალური ტყვიების რაოდენობა აბოიმაში
public int CurCatrige = 9; //ახლანდელი აბოიმის რაოდენობის ცვლადი
public int MaxCatrige = 9; //მაქსიმალური აბოიმის რაოდენობა
public AudioClip Fire; //სროლის ხმა
public AudioClip Reload; //გადატენვის ხმა
public AudioClip NoAmmo;
public int AmmoBoxWidth = 200; //ტყვიების ბოქსის სიგრძე
public int AmmoBoxHeight = 100; //ტყვიების ბოქსის სიგანე
public float ReloadTimer = 0.0f; //გადატენვის დრო
public int OffsetAimX; //მიზნის მდებარეობა x ღერძზე
public int OffsetAimY; //მიზნის მდებარეობა y ღერძზე
public int inventoryAmmoCount = 200; //მაქსიმალური ტყვიების რაოდენობა მოთამაშისთვის
private int RaznicaAmmo;
public float bulletTimeout = 0.1f;
float lastBullet = 0f;
public float maxReloadTime = 3.4F;
// ფუნქციები
void Update (){
if(inventoryAmmoCount == 0&CurAmmoCount == 0 ) {
AK.animation.Stop ("Reloading");
AK.animation.Stop ("Shooting");
audio.Stop (Reload);
audio.Stop (Fire);
}
if(Input.GetMouseButton(0)&CurAmmoCount==0&inventoryAmmoCount ==0){
audio.PlayOneShot (NoAmmo);
}
if(Input.GetMouseButton(0)&CurAmmoCount>0&ReloadTimer<=0){ //თუ დაეჭირება მაუსს ისროლოს
AK.animation.Play ("Shooting", PlayMode.StopAll);
float t = Time.time;
if( ( t - lastBullet ) >= bulletTimeout ) {
Shoot ();
lastBullet = t;
}
}
RaznicaAmmo = MaxAmmoCount - CurAmmoCount;
if(Input.GetButtonDown("Reload Weapon")&ReloadTimer<=0){
AK.animation.Play("Reloading", PlayMode.StopAll);
ReloadTimer = 3.4f;
if(inventoryAmmoCount >= RaznicaAmmo) {
CurAmmoCount += RaznicaAmmo;
inventoryAmmoCount -= RaznicaAmmo;
} else {
CurAmmoCount += inventoryAmmoCount;
inventoryAmmoCount = 0;
}
audio.PlayOneShot (Reload);
}
if(CurAmmoCount <=0) {
AK.animation.Play("Reloading", PlayMode.StopAll);
ReloadTimer = 3.4f;
if(inventoryAmmoCount >= RaznicaAmmo) {
CurAmmoCount += RaznicaAmmo;
inventoryAmmoCount -= RaznicaAmmo;
} else {
CurAmmoCount += inventoryAmmoCount;
inventoryAmmoCount = 0;
}
audio.PlayOneShot (Reload);
}
if (ReloadTimer> 0)
{
ReloadTimer -= Time.deltaTime;
}
}
void Shoot() {
Transform BulletInstance = (Transform) Instantiate(bullet, GameObject.Find("BulletSpawnPoint").transform.position, Quaternion.identity);
BulletInstance.rigidbody.AddForce(transform.forward * BulletForce);
CurAmmoCount = CurAmmoCount - 1;
audio.PlayOneShot(Fire);
}
void OnGUI() {
GUI.DrawTexture(new Rect((Screen.width-AimTexture.width)/2-OffsetAimX,(Screen.height-AimTexture.height)/2-OffsetAimY,AimTexture.width,AimTexture.height), AimTexture);
GUI.skin = MySkin;
GUI.Box(new Rect(Screen.width/15,Screen.height-AmmoBoxHeight,AmmoBoxWidth,AmmoBoxHeight), "Ammo:"+CurAmmoCount+"/"+inventoryAmmoCount);
}
}