//private void Update() //{ // if (Input.GetKeyDown(KeyCode.Mouse0)) // { // ShootEvent(ShootingType.Primary); // } //} public void ShootEvent(ShootingType shootingType) { if (shootingType == ShootingType.Primary) { if (!Data.PrimaryObjectShooting) { RayCastShooting(Data.PrimaryBulletCount, Data.PrimaryShootCost, Data.PrimaryDamage, Data.PrimaryDispersion, Data.RayCastDecal, Data.PrimaryShootSound); } else { ObjectShooting(Data.PrimaryBulletCount, Data.PrimaryShootCost, Data.PrimaryDamage, Data.PrimaryBulletSpeed, Data.PrimaryDispersion, Data.PrimaryBulletPrefab, Data.PrimaryShootSound); } if (Data.PrimaryShootSound != null) { shootSource.pitch = Random.Range(0.7f, 1.3f); shootSource.PlayOneShot(Data.PrimaryShootSound); } } else { if (!Data.SecondaryObjectShooting) { RayCastShooting(Data.SecondaryBulletCount, Data.SecondaryShootCost, Data.SecondaryDamage, Data.SecondaryDispersion, Data.RayCastDecal, Data.SecondaryShootSound); } else { ObjectShooting(Data.SecondaryBulletCount, Data.SecondaryShootCost, Data.SecondaryDamage, Data.SecondaryBulletSpeed, Data.SecondaryDispersion, Data.SecondaryBulletPrefab, Data.SecondaryShootSound); } shootSource.pitch = Random.Range(0.7f, 1.3f); if (Data.SecondaryShootSound != null) { shootSource.PlayOneShot(Data.SecondaryShootSound); } } }
public void Execute(ShootingType shootingType) { _shootingType = shootingType; _timer = 1 / shootingType.fireRate; _isExecuting = true; }
public static ShootController StartChecking(GameObject addComponentAt, ShootingType shootingType) { if (addComponentAt.GetComponent <ShootController>()) { return(null); } ShootController shootController = addComponentAt.AddComponent <ShootController>(); shootController.Execute(shootingType); return(shootController); }
private void CreateShootingType() { typeInstance = Instantiate(type); typeInstance.Init(this); }