private void doAttack() { if (!wantsToTarget) { return; } if (!wantsToAttack) { return; } if (target == null) { return; } if (!canSeeThing(target)) { return; } if (coolDownShoot > 0) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.takeDamage(20); sound.Play(); } coolDownShoot = 1 / roundsPerSecond; // attack camOrbit.Shake(.75f); if (isArmLeftTimeToFire) { if (handL) { Instantiate(muzzleFlashPreafab, handL.position, handL.rotation); } armL.localEulerAngles += new Vector3(-20, 0, 0); armL.position += -armL.forward * .1f; flipHands(); } else if (isArmRightTimeToFire) { if (handR) { Instantiate(muzzleFlashPreafab, handR.position, handR.rotation); } armR.localEulerAngles += new Vector3(-20, 0, 0); armR.position += -armR.forward * .1f; flipHands(); } }
private void DoAttack() { // Check if player should attack if (cooldownShoot > 0) { return; // still on cooldown } if (!wantsToTarget) { return; // not targeting } if (!wantsToAttack) { return; // not shooting } if (target == null) { return; // no target } if (!CanSeeThing(target)) { return; // no target in range } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.TakeDamage(20); // Deal damage to target's health } cooldownShoot = 1 / roundsPerSecond; // Attack if (handL) { Instantiate(prefabMuzzleFlash, handL.position, handL.rotation); } if (handR) { Instantiate(prefabMuzzleFlash, handR.position, handR.rotation); } // Instantiate bullet on hands //Instantiate(bullet, handL.transform.position, Quaternion.identity); //Instantiate(bullet, handR.transform.position, Quaternion.identity); Instantiate(bullet, handL.transform.position, handL.transform.rotation); Instantiate(bullet, handR.transform.position, handR.transform.rotation); // Trigger arm animation armL.localEulerAngles += new Vector3(-20, 0, 0); // LArm recoil on shoot armR.localEulerAngles += new Vector3(-20, 0, 0); // RArm recoil on shoot armL.position += -armL.forward * .1f; // LArm pushback on shoot armR.position += -armR.forward * .1f; // RArm pushback on shoot camOrbit.Shake(.5f); // Shakes camera with an intensity of 1 Soundboard.PlayShoot(); }
private void doAttack() { if (!wantsToTarget) { return; } if (!wantsToAttack) { return; } if (target == null) { return; } if (!canSeeThing(target)) { return; } if (coolDownShoot > 0) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.takeDamage(damage, .5f); sound.PlayOneShot(cannon); } coolDownShoot = 1 / roundsPerSecond; // attack camOrbit.Shake(1); if (isCannonBottomTimeToFire) { if (turretTop) { Instantiate(muzzleFlashPreafab, turretTop.position, turretTop.rotation); } cannonTop.localEulerAngles += new Vector3(-5, 0, 0); cannonTop.position += -cannonTop.forward * .5f; flipHands(); } else if (isCannonTopTimeToFire) { if (turretBottom) { Instantiate(muzzleFlashPreafab, turretBottom.position, turretBottom.rotation); } cannonBottom.localEulerAngles += new Vector3(-5, 0, 0); cannonBottom.position += -cannonBottom.forward * .1f; flipHands(); } }
private void DoAttack() { Projectile projectile; if (cooldownShoot > 0) { return; } if (!wantsToTarget) { return; } if (!wantsToAttack) { return; } if (target == null) { return; } if (!CanSeeThing(target)) { return; } cooldownShoot = 1 / RPS; // Attack camOrbit.Shake(.5f); // Where to spawn the particle system if (handRight) { Instantiate(prefabMuzzleFlash, handRight.position, handRight.rotation); } if (handLeft) { Instantiate(prefabMuzzleFlash, handLeft.position, handLeft.rotation); } if (handRight) { projectile = Instantiate(prefabProjectile, handRight.position, handRight.rotation); projectile.target = target; } if (handLeft) { projectile = Instantiate(prefabProjectile, handLeft.position, handLeft.rotation); projectile.target = target; } // Trigger arm anim // Rotate the arms up armLeft.localEulerAngles += new Vector3(-20, 0, 0); armRight.localEulerAngles += new Vector3(-20, 0, 0); // Move the arms backwards armLeft.position += -armLeft.forward * .1f; armRight.position += -armRight.forward * .1f; }
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(); }
/// <summary> /// Does attack when player has a target and wants to attack /// </summary> private void DoAttack() { if (cooldownShoot > 0) { return; // too soon! } if (!wantsToTarget) { return; // player not targeting } if (!wantsToAttack) { return; // player not shooting } if (target == null) { return; // no target } if (!CanSeeThing(target)) { return; // target can't be seen } // spawns bullets on left and right hand Instantiate(bullets, handL.position, handL.rotation); Instantiate(bullets, handR.position, handR.rotation); cooldownShoot = 1 / roundsPerSecond; // rounds per second SoundBoard.PlayGun(); // plays gun sound // attack! camOrbit.Shake(.5f); // shakes camera slightly when shooting // spawns muzzle particles to look like the player is shooting a gun if (handL) { Instantiate(prefavMuzzleFlash, handL.position, handL.rotation); } if (handR) { Instantiate(prefavMuzzleFlash, handR.position, handR.rotation); } // trigger arm animation // rotates the arms up: armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); // moves the arms backwards: armL.position += -armL.forward * .1f; armR.position += -armR.forward * .1f; }
private void DoAttack() { if (cooldownShoot > 0) { return; } if (!wantsToTarget) { return; } if (!wantsToAttack) { return; } if (target == null) { return; } if (!CanSeeThing(target)) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); print("PEW"); cooldownShoot = 1 / roundsPerSecond; // attack! camOrbit.Shake(.5f); if (handL) { Instantiate(prefabMuzzleFlash, handL.position, handL.rotation); } if (handR) { Instantiate(prefabMuzzleFlash, handR.position, handR.rotation); } // trigger arm animation armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); armL.position += -armL.forward * .1f; armR.position += -armR.forward * .1f; }
private void DoAttack() { if (cooldownShoot > 0) { return; // too soon! } if (!wantsToTarget) { return; //player not targeting } if (!wantsToAttack) { return; // p not shooting } if (!target) { return; // no target } //doing damage to target sentry HealthSystem health = target.GetComponent <HealthSystem>(); if (health) { health.TakeDamage(20); Instantiate(parts, target.position, target.rotation); } if (!CanSeeThing(target)) { return; } camOrbit.Shake(1); AudioP.Play(); cooldownShoot = 1 / roundsPerSecond; // attack! Instantiate(flash, handL.position, handL.rotation); Instantiate(flash, handR.position, handR.rotation); //trigger arm animation //rotates arms up: armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); //moves the arms backward armL.position += -armL.transform.forward * 0.1f; armR.position += -armR.transform.forward * 0.1f; }
private void DoAttack() { if (cooldownShoot > 0) { return; } if (!wantsToTarget) { return; // not targeting } if (!wantsToAttack) { return; // not shooting } if (target == null) { return; // no target } if (!CanSeeThing(target)) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.TakeDamage(20); } cooldownShoot = 1 / roundsPerSecond; soundPlayer.Play(); // attack camOrbit.Shake(.5f); Instantiate(prefabMuzzleFlash, handL.position, handL.rotation); Instantiate(prefabMuzzleFlash, handR.position, handR.rotation); // trigger/arm animation //this rotates the arms up/recoil effect 1 armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); // moves the arms backwards/ recoil effect 2 armL.position += -armL.forward * .1f; armR.position += -armR.forward * .1f; }
private void DoAttack() { if (!wantsToTarget) { return; } if (coolDownShoot > 0) { return; } if (!wantsToAttack) { return; } if (target == null) { return; } if (!CanSeeThing(target)) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.TakeDamage(20); } camOrbit.Shake(.5f); coolDownShoot = 1 / roundsPerSec; armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); armL.position += -armL.forward * .1f; armR.position += -armR.forward * .1f; Instantiate(prefabMuzzleFlash, handL.position, handL.rotation); Instantiate(prefabMuzzleFlash, handR.position, handR.rotation); }
// Update is called once per frame void Update() { print(transform.rotation.x); Vector3 targetDir = target.position - transform.position; float singleStep = speed * Time.deltaTime; Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDir, singleStep, 0f); if (Mathf.Abs(targetDir.x) < 15 && Mathf.Abs(targetDir.z) < 15) { newDirection = new Vector3(newDirection.x, newDirection.y + 90, newDirection.z); transform.rotation = Quaternion.LookRotation(newDirection); isLookingDown = false; } else { if (!isLookingDown) { isLookingDown = true; transform.rotation = new Quaternion(transform.rotation.x, 1.00f, transform.rotation.z, transform.rotation.w);// * lookDown; } } if (Mathf.Abs(targetDir.x) < 10 && Mathf.Abs(targetDir.z) < 10) { if (bulletDelay) { Vector3 cannonOffset = new Vector3(0, 0, 10); self.localPosition = AnimMath.Slide(startPosSelf, cannonOffset, .6f); camOrbit.Shake(2.5f); Vector3 spawnOffset = new Vector3(0, 1.2f, 0); Instantiate(bullet, transform.position + spawnOffset, transform.rotation); bulletDelay = false; Invoke("delayReset", 1.5f); } } }
private void DoAttack() { if (shootCooldown > 0) { return; } if (!wantsToTarget) { return; } if (!wantsToAttack) { return; } if (target == null) { return; } if (bullets <= 0) { return; } if (reloadTimer > 0) { return; } if (!canSeeThing(target)) { return; } HealthSystem targetHealth = target.GetComponent <HealthSystem>(); if (targetHealth) { targetHealth.TakeDamage(20); } // resets cooldown: shootCooldown = 1 / roundsPerSecond; bullets -= 2; camOrbit.Shake(.25f); if (handL) { Instantiate(prefabMuzzleFlash, handL.position, handL.rotation); } if (handR) { Instantiate(prefabMuzzleFlash, handR.position, handR.rotation); } // rotates the arm up: armL.localEulerAngles += new Vector3(-20, 0, 0); armR.localEulerAngles += new Vector3(-20, 0, 0); // moves the arms backward: armL.position += -armL.forward * 0.1f; armR.position += -armR.forward * 0.1f; }