private void FixedUpdate() { RotateWheels(350); if (lives < 15 && !damaged) { damaged = true; agent.speed = damagedSpeed; AudioFW.Play("TruckDamaged"); } if (lives < 1) { EnemyManager.enemiesLeft--; GunShoot gun = GameObject.Find("BulletSpawn").GetComponent <GunShoot>(); gun.kills++; Clipboard.instance.ChangeKills(gun.kills.ToString()); Destroy(gameObject); GameObject deadTruck = Instantiate(truckDeath, transform.position, transform.rotation); Destroy(deadTruck, 5f); CameraShaker.GetInstance("Main Camera").ShakeOnce(6f, 5f, 0.0f, 2.5f); AudioFW.Play("TruckDie"); } if (damaged) { flames.SetActive(true); } }
private void State(float bossSpeed, float multiplier, float shake1, float shake2) { Debug.Log("I'm HERE!!!!!!!!!!!!!"); if (i % 2 == 1) { bossSpeed = speed * multiplier; } else { bossSpeed = speed; } transform.position = Vector2.MoveTowards(transform.position, waypoints[i].position, bossSpeed * Time.deltaTime); if (Vector2.Distance(transform.position, waypoints[i].position) < 0.2f) { if (waitTime <= 0) { i++; if (i > waypoints.Length - 1) { i = 0; } waitTime = startWaitTime; } else { if (i % 2 == 1) { CameraShaker.GetInstance("BossFightCam").ShakeOnce(shake1, shake2, 0.1f, 1f); } waitTime -= Time.deltaTime; } } }
void Shoot() { CameraShaker.GetInstance("Main Camera").ShakeOnce(1.5f, 2f, 0, 0.5f); //Bullet spread calculations Vector3 deviation3D = Random.insideUnitCircle * accuracy; Quaternion rot = Quaternion.LookRotation(Vector3.forward + deviation3D); Vector3 fwd = transform.rotation * rot * Vector3.forward; bool enemyHit = false; RaycastHit hit; if (Physics.Raycast(trans.position, fwd, out hit)) { if (hit.transform.CompareTag("Enemy")) { Destroy(hit.transform.gameObject, 0.5f); hit.transform.GetComponent <Enemy>().dying = true; enemyHit = true; StartCoroutine(ShowHitMark(false)); //blood splatter effect GameObject impact = Instantiate(bodyImpact, hit.transform.position, bodyImpact.transform.rotation); float randScale = Random.Range(2f, 3f); impact.transform.localScale = (new Vector3(randScale, randScale, randScale)); Destroy(impact, 1f); } else if (hit.transform.CompareTag("Truck")) { hit.transform.GetComponent <Truck>().lives--; StartCoroutine(ShowHitMark(true)); float randHitSound = Random.Range(0f, 1f); if (randHitSound > 0.65f) { AudioFW.PlayRandomPitch("MetalHit"); } } } GameObject newShot = Instantiate(mGShot, trans.position, trans.parent.rotation); newShot.GetComponent <Rigidbody>().AddForce(fwd * shootForce, ForceMode.Impulse); if (enemyHit) { Destroy(newShot, 0.1f); EnemyManager.enemiesLeft--; kills++; Clipboard.instance.ChangeKills(kills.ToString()); } else { Destroy(newShot, 1f); } GameObject flash = Instantiate(mFlash, trans.GetChild(0).position, Quaternion.identity); Destroy(flash, 0.02f); }
// Update is called once per frame void Update() { Debug.Log("Player 1 Mutation is at: " + Mutation); if (Mutation == 1 && dnaChain1.winner != true) { cam1.backgroundColor = color1; if (shakeOnlyOnce == false) { CameraShaker.GetInstance("Main Camera").ShakeOnce(5f, 5f, .1f, 1); shakeOnlyOnce = true; } } if (Mutation == 2 && dnaChain1.winner != true) { cam1.backgroundColor = color2; if (shakeOnlyOnce == true) { CameraShaker.GetInstance("Main Camera").ShakeOnce(5f, 5f, .1f, 1); FindObjectOfType <AudioManager>().Play("Wrong"); shakeOnlyOnce = false; } } if (Mutation == 3 && dnaChain1.winner != true) { cam1.backgroundColor = color3; gameOverText.SetActive(true); cameraParent.transform.position = Vector3.Lerp(cameraParent.transform.position, player.transform.position, 2f * Time.deltaTime); if (cam1.transform.position.y <= 1f) { FindObjectOfType <AudioManager>().Play("Fatal"); cam1.backgroundColor = default1; gameOverText.SetActive(false); Mutation = 0; } if (shakeOnlyOnce == true) { CameraShaker.GetInstance("Main Camera").ShakeOnce(5f, 5f, .1f, 1); shakeOnlyOnce = false; } } }
// Update is called once per frame void Update() { if (Mutation == 1 && dnaChain3.winner2 != true) { cam2.backgroundColor = color1; if (shakeOnlyOnce == false) { CameraShaker.GetInstance("Main Camerap2").ShakeOnce(5f, 5f, .1f, 1); FindObjectOfType <AudioManager>().Play("Wrong"); shakeOnlyOnce = true; } } if (Mutation == 2 && dnaChain3.winner2 != true) { cam2.backgroundColor = color2; if (shakeOnlyOnce == true) { CameraShaker.GetInstance("Main Camerap2").ShakeOnce(5f, 5f, .1f, 1); FindObjectOfType <AudioManager>().Play("Wrong"); shakeOnlyOnce = false; } } if (Mutation == 3 && dnaChain3.winner2 != true) { cam2.backgroundColor = color3; gameOverText.SetActive(true); cameraParent2.transform.position = Vector3.Lerp(cameraParent2.transform.position, player.transform.position, 2f * Time.deltaTime); if (cam2.transform.position.y <= 1f) { cam2.backgroundColor = color4; gameOverText.SetActive(false); Mutation = 0; } if (shakeOnlyOnce == true) { CameraShaker.GetInstance("Main Camerap2").ShakeOnce(5f, 5f, .1f, 1); shakeOnlyOnce = false; } } }
// Update is called once per frame void Update() { //player 1 inputs/controller if ((Input.GetKeyDown(KeyCode.A) || Input.GetButtonDown("P1 Left")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabA, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; StartCoroutine(ResetBool2()); progressBar.fillAmount += 0.02f; pressCount += 1; inputMade2 = true; //player1ShakeChange CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 1f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.W) || Input.GetButtonDown("P1 Up")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabG, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; pressCount += 1; inputMade2 = true; CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.S) || Input.GetButtonDown("P1 Down")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabC, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; pressCount += 1; StartCoroutine(ResetBool2()); inputMade2 = true; CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.D) || Input.GetButtonDown("P1 Right")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabT, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; pressCount += 1; StartCoroutine(ResetBool2()); inputMade2 = true; CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 2f, .1f, 1); } //Helicase Mechanic for Player 2 end if (Input.GetKeyDown(KeyCode.Y) || Input.GetButtonDown("P2 Heliocase") && p2Progress.fillAmount == 1f) { helicase.text = "HELICASE"; FindObjectOfType <AudioManager>().Play("Mechanic1"); deleteThree = true; p2Progress.fillAmount = 0f; CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 2f, .1f, 1); } if (deleteThree == true && deleteCounter < 3) { float myMaxDistance2 = 2000f; RaycastHit downHit; Ray checkRay2 = new Ray(transform.position, -transform.up); time -= Time.deltaTime; if (time <= 0) { StartCoroutine(MoveDown2()); cameraParent.GetComponent <Transform>().Translate(new Vector3(0, -2f)); Physics.Raycast(checkRay2, out downHit, myMaxDistance2); Destroy(downHit.transform.gameObject); ScoreText1.Score -= 1; time = 0.2f; // deleteThree = false; deleteCounter++; } } else { helicase.text = null; } if (Mutation1.Mutation == 3 && deleteCounter2 < pressCount) { resetPower = true; progressBar.fillAmount = 0f; p1Progress.fillAmount = 0f; float myMaxDistance2 = 2000f; RaycastHit downHit; Ray checkRay2 = new Ray(transform.position, -transform.up); time -= Time.deltaTime; if (time <= 0) { StartCoroutine(MoveDown2()); Physics.Raycast(checkRay2, out downHit, myMaxDistance2); Destroy(downHit.transform.gameObject); ScoreText1.Score = 0; time = 0.02f; deleteCounter2++; } } //Code that resets the progress bar when fatal mutation occurs if (progressBar.fillAmount >= 1f) { winner = true; SceneManager.LoadScene(2); } if (p1Progress.fillAmount < 1.0f) { p1Progress.color = new Color(1, 1, 1, 1); } if (p1Progress.fillAmount >= 1.0f) { p1Progress.color = new Color(0, 1, 1, 1); p1Progress.fillAmount = 1.0f; } IEnumerator ResetBool2() { yield return(new WaitForSeconds(1f)); inputMade2 = false; } IEnumerator MoveUp2() { yield return(new WaitForSeconds(0.1f)); this.GetComponent <Transform>().Translate(new Vector3(0, 2f)); cameraParent.GetComponent <Transform>().Translate(new Vector3(0, 2f)); } IEnumerator MoveDown2() { yield return(new WaitForSeconds(0.1f)); this.GetComponent <Transform>().Translate(new Vector3(0, -2f)); } }
// Update is called once per frame void Update() { if (cameraCinematic.startCinematic == false && pressCount == 0) { tutorialText.SetActive(true); } if ((Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetButtonDown("P2 Left")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false && winner2 != true) { tutorialText.SetActive(false); Instantiate(prefabA, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); //screenshakep2 change CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 1f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.UpArrow) || Input.GetButtonDown("P2 Up")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false && winner2 != true) { tutorialText.SetActive(false); Instantiate(prefabG, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.DownArrow) || Input.GetButtonDown("P2 Down")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false && winner2 != true) { tutorialText.SetActive(false); Instantiate(prefabC, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.RightArrow) || Input.GetButtonDown("P2 Right")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false && winner2 != true) { tutorialText.SetActive(false); Instantiate(prefabT, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 2f, .1f, 1); } score.text = (ScoreText2.Score2).ToString(); if (score.text == "5") { winner2 = true; tutorialText.SetActive(true); tutorialText.GetComponent <TextMeshProUGUI>().text = "Ready!"; cam1.backgroundColor = color1; //SceneManager.LoadScene (2); } if (winner2 == true && dnaChain1.winner == true) { start.SetActive(true); tutorialText.SetActive(false); tutorialText2.SetActive(false); if (Input.anyKeyDown) { SceneManager.LoadScene(1); } } if (Mutation2.Mutation == 3 && deleteCounter2 < pressCount) { Debug.Log("oop"); progressBar.fillAmount = 0f; float myMaxDistance2 = 2000f; RaycastHit downHit; Ray checkRay2 = new Ray(transform.position, -transform.up); time -= Time.deltaTime; if (time <= 0) { StartCoroutine(MoveDown()); Physics.Raycast(checkRay2, out downHit, myMaxDistance2); Destroy(downHit.transform.gameObject); ScoreText2.Score2 = 0; time = 0.02f; deleteCounter2++; } } }
/// <summary> /// Play the attack AudioClip. /// </summary> public void SFXPlayAttack() { SoundManager.GetInstance().Play(attackClip); CameraShaker.GetInstance().AddForce(1); }
public void ShakeCurrentCam(float mag, float rough, float fadeIn, float fadeOut) { CameraShaker.GetInstance(currentCamera.name).ShakeOnce(mag, rough, fadeIn, fadeOut); }
// Update is called once per frame void Update() { if ((Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetButtonDown("P2 Left")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabA, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); //screenshakep2 change CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 1f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.UpArrow) || Input.GetButtonDown("P2 Up")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabG, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.DownArrow) || Input.GetButtonDown("P2 Down")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabC, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.RightArrow) || Input.GetButtonDown("P2 Right")) && Mutation2.Mutation < 3 && cameraCinematic.startCinematic == false) { Instantiate(prefabT, transform.position, transform.rotation); StartCoroutine(MoveUp()); p2Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; inputMade = true; pressCount += 1; StartCoroutine(ResetBool()); CameraShaker.GetInstance("Main Camerap2").ShakeOnce(2f, 2f, .1f, 1); } if (progressBar.fillAmount >= 1f) { winner2 = true; SceneManager.LoadScene(2); } //Helicase Mechanic for Player 1's End if (Input.GetKeyDown(KeyCode.R) || Input.GetButtonDown("P1 Heliocase") && p1Progress.fillAmount >= 1f) { helicase.text = "HELICASE"; FindObjectOfType <AudioManager>().Play("Mechanic1"); deleteThree = true; p1Progress.fillAmount = 0f; } if (deleteThree == true && deleteCounter < 3) { float myMaxDistance2 = 2000f; RaycastHit downHit; Ray checkRay2 = new Ray(transform.position, -transform.up); time -= Time.deltaTime; if (time <= 0) { StartCoroutine(MoveDown()); cameraParent2.GetComponent <Transform>().Translate(new Vector3(0, -2f)); Physics.Raycast(checkRay2, out downHit, myMaxDistance2); Destroy(downHit.transform.gameObject); ScoreText2.Score2 -= 1; time = 0.2f; //deleteThree = false; deleteCounter++; } } else { helicase.text = null; } if (Mutation2.Mutation == 3 && deleteCounter2 < pressCount) { progressBar.fillAmount = 0f; p2Progress.fillAmount = 0f; float myMaxDistance2 = 2000f; RaycastHit downHit; Ray checkRay2 = new Ray(transform.position, -transform.up); time -= Time.deltaTime; if (time <= 0) { StartCoroutine(MoveDown()); Physics.Raycast(checkRay2, out downHit, myMaxDistance2); Destroy(downHit.transform.gameObject); ScoreText2.Score2 = 0; time = 0.02f; deleteCounter2++; } } if (p2Progress.fillAmount < 1.0f) { p2Progress.color = new Color(1, 1, 1, 1); } if (p2Progress.fillAmount >= 1.0f) { p2Progress.color = new Color(0, 1, 1, 1); p2Progress.fillAmount = 1.0f; } //This code will check when Mutation has been reached, and will then reset/subtract the power up bar by a bit. }
// Update is called once per frame void Update() { if (cameraCinematic.startCinematic == false && pressCount == 0) { tutorialText.SetActive(true); } //player 1 inputs/controller if ((Input.GetKeyDown(KeyCode.A) || Input.GetButtonDown("P1 Left")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false && winner != true) { tutorialText.SetActive(false); Instantiate(prefabA, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; StartCoroutine(ResetBool2()); progressBar.fillAmount += 0.02f; pressCount += 1; inputMade2 = true; //player1ShakeChange CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 1f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.W) || Input.GetButtonDown("P1 Up")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false && winner != true) { tutorialText.SetActive(false); Instantiate(prefabG, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; pressCount += 1; inputMade2 = true; CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.S) || Input.GetButtonDown("P1 Down")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false && winner != true) { tutorialText.SetActive(false); Instantiate(prefabC, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; pressCount += 1; StartCoroutine(ResetBool2()); inputMade2 = true; CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 2f, .1f, 1); } if ((Input.GetKeyDown(KeyCode.D) || Input.GetButtonDown("P1 Right")) && Mutation1.Mutation < 3 && cameraCinematic.startCinematic == false && winner != true) { tutorialText.SetActive(false); Instantiate(prefabT, transform.position, transform.rotation); StartCoroutine(MoveUp2()); p1Progress.fillAmount += 0.05f; progressBar.fillAmount += 0.02f; pressCount += 1; StartCoroutine(ResetBool2()); inputMade2 = true; CameraShaker.GetInstance("Main Camera").ShakeOnce(2f, 2f, .1f, 1); } if (Mutation1.Mutation == 3 && deleteCounter2 < pressCount) { Debug.Log("oopyy"); progressBar.fillAmount = 0f; float myMaxDistance2 = 2000f; RaycastHit downHit; Ray checkRay2 = new Ray(transform.position, -transform.up); time -= Time.deltaTime; if (time <= 0) { StartCoroutine(MoveDown2()); Physics.Raycast(checkRay2, out downHit, myMaxDistance2); Destroy(downHit.transform.gameObject); ScoreText1.Score = 0; time = 0.02f; deleteCounter2++; } } score.text = (ScoreText1.Score).ToString(); if (score.text == "5") { winner = true; tutorialText.SetActive(true); tutorialText.GetComponent <TextMeshProUGUI>().text = "Ready!"; cam1.backgroundColor = color1; //SceneManager.LoadScene (2); } if (winner == true && dnaChain3.winner2 == true) { start.SetActive(true); tutorialText.SetActive(false); tutorialText2.SetActive(false); if (Input.anyKeyDown) { SceneManager.LoadScene(1); } } IEnumerator ResetBool2() { yield return(new WaitForSeconds(1f)); inputMade2 = false; } IEnumerator MoveUp2() { yield return(new WaitForSeconds(0.1f)); this.GetComponent <Transform>().Translate(new Vector3(0, 2f)); cameraParent.GetComponent <Transform>().Translate(new Vector3(0, 2f)); } IEnumerator MoveDown2() { yield return(new WaitForSeconds(0.1f)); this.GetComponent <Transform>().Translate(new Vector3(0, -2f)); } }