void _Shoot() { GameObject bulletClone; if (Input.GetButton("Fire1")) { if (!reloading) { if (Time.time > shootCD + lastShot) { if (currentClip <= maxClip && currentClip != 0) { currentClip--; bulletClone = BetterPool.Spawn(bullet, shootPosition.transform.position); bulletClone.transform.rotation = Quaternion.LookRotation(transform.forward, transform.up); bulletClone.transform.Rotate(new Vector3(90, 0, 0)); Debug.Log("Shot Bullet"); } else { reloading = true; } lastShot = Time.time; } } } }
void OnCollisionEnter2D(Collision2D other) { if (!other.gameObject.CompareTag("Player")) { BetterPool.Despawn(this.gameObject); } }
private IEnumerator _ShootBullet() { for (int i = 0; i < burstClipCount; i++) { BetterPool.Spawn(bulletPrefab, transform.position + offset); yield return(new WaitForSeconds(burstFireRate)); } }
void Update() { if (Time.time > spawnTime) { spawnTime = Time.time + spawnRate; BetterPool.Spawn(spawnObject, spawnPositionList[index++].transform.position); index = index % spawnPositionList.Count; } }
void OnCollisionEnter2D(Collision2D other) { Health targetHealth = other.transform.root.GetComponent <Health>(); if (targetHealth != null) { targetHealth.Damage(damage); } BetterPool.Despawn(this.gameObject); }
private void OnTriggerEnter(Collider other) { if (!other.gameObject.CompareTag("Player") || !other.gameObject.CompareTag("Bullet")) { Health targetHealth = other.transform.root.GetComponent <Health>(); if (targetHealth != null) { targetHealth.Damage(damage); } BetterPool.Despawn(this.gameObject); } }
void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("EnemyBullet") || other.gameObject.CompareTag("Enemy") || other.gameObject.CompareTag("Wall")) { Health targetHealth = other.transform.root.GetComponent <Health>(); if (targetHealth != null) { targetHealth.Damage(damage); } BetterPool.Despawn(this.gameObject); } }
void OnCollisionEnter2D(Collision2D other) { Health targetHealth = null; if (other.collider.gameObject.CompareTag("Enemy")) { targetHealth = other.transform.root.GetComponentInChildren <Health>(); } if (targetHealth != null) { targetHealth.Damage(damage); } BetterPool.Despawn(this.gameObject); PlayerShoot.bulletsOnScreen--; }
void _PhaseOne() { if (Time.time > phase1StartTime) { phase1StartTime = Time.time + phase1FireStart; if (phase1BulletCount > 0) { foreach (Transform spawn in bulletSpawnPos) { BetterPool.Spawn(bulletPrefab, spawn.position); } phase1BulletCount--; } else { phase1BulletCount = phase1MaxBulletCount; } } }