private void DoAttack() { if (cooldownShoot > 0) { return; // too soon } if (!wantsToTarget) { return; // player not targeting } if (!wantsToAttack) { return; // player not attacking } if (target == null) { return; // no target } if (!CanSeeThing(target)) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.TakeDamage(20); } cooldownShoot = 1 / roundsPerSecond; // attack! camOrbit.Shake(.5f); if (handL) { Instantiate(prefabMuzzleFlash, handL.position, handL.rotation); } if (handR) { Instantiate(prefabMuzzleFlash, handR.position, handR.rotation); } // moves arms up armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); //moves arms backwards armL.position += -armL.forward * .1f; armR.position += -armR.forward * .1f; SoundEffectBoard.PlayPlayerShot(); }
void Start() { if (main == null) { main = this; player = GetComponent <AudioSource>(); } else { Destroy(this.gameObject); } }
private void DoAttack() { if (cooldownShoot > 0) { return; // too soon } if (!wantsToTarget) { return; // player not targeting } if (!wantsToAttack) { return; // player not attacking } if (target == null) { return; // no target } if (!CanSeeThing(target)) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.TakeDamage(0); } cooldownShoot = 2 / roundsPerSecond; // attack! if (sentryMuzzle) { Instantiate(prefabSentryMuzzleFlash, sentryMuzzle.position, sentryMuzzle.rotation); // particle effect } Transform newBullet = Instantiate(prefabBullet, startPosBullet, Quaternion.identity); newBullet.localPosition += AnimMath.Slide(startPosBullet, target.localPosition, 0.5f); // moves neck up sentryNeck.localEulerAngles += new Vector3(-5, 0, 0); SoundEffectBoard.PlaySentryShot(); }