public void HandleCollisions(Collider2D c) { Debug.Log("hit"); var o = c.GetComponent <Obstacle>(); if (canTakeDamage && o != null) { if (!o.isBroken) { handleObstacleHit(); var scripts = c.gameObject.GetComponentsInChildren <Obstacle>(); for (int i = 0; i < scripts.Length; i++) { scripts[i].breakSelf(); } } } if (c.gameObject.name == "shotgunPickup") { //TODO: add pickup sound effect heldPowerup = powerup.Shotgun; armRenderer.sprite = armShotgun; Destroy(c.gameObject); } else if (c.gameObject.name == "forcePickup") { //TODO: add pickup sound effect heldPowerup = powerup.ForceBlast; armRenderer.sprite = armForce; Destroy(c.gameObject); } }
void StartingPowerupConditions() { // Start powerup conditions. CurrentPowerup = powerup.RegularShot; BeamShot.SetActive(false); HorizontalBeam.SetActive(false); HelixObject.SetActive(false); }
private void MakeLoot() { //drops loot if (thisLoot != null) { powerup current = thisLoot.LootPowerup(); if (current != null) { Instantiate(current.gameObject, transform.position, Quaternion.identity); } } }
public GameObject spawnPowerup(powerup powerup, Vector3 position) { GameObject powerupGameObject = Instantiate(powerupPrefab); var powerupBehavior = powerupGameObject.GetComponent <powerupBehavior>(); powerupBehavior.controller = this; powerupBehavior.setPowerup(powerup); powerupGameObject.transform.position = position; return(powerupGameObject); }
public void activatePowerup(powerup powerup) { if (!activePowerups.ContainsKey(powerup)) { powerup.start(); activePowerups.Add(powerup, Player.GetComponent <playerStats>().energy); } else { activePowerups[powerup] += Player.GetComponent <playerStats>().energy; } keys = new List <powerup>(activePowerups.Keys); }
public void OnCollisionEnter2D(Collision2D collision) { GameObject canvas = GameObject.Find("Canvas"); powerup powerupsound = canvas.GetComponent <powerup>(); GameObject laserobj = GameObject.Find("Canvas"); laser laserscript = laserobj.GetComponent <laser>(); if (collision.gameObject.tag == "ship") { GameObject particles = GameObject.Find("powerup"); ParticleSystem power = particles.GetComponent <ParticleSystem>(); power.Play(); powerupsound.powersound.volume = PlayerPrefs.GetFloat("sfxvolume"); powerupsound.powersound.PlayOneShot(powerupsound.powerclip); Destroy(this.gameObject); laserscript.spawnlaser(); } }
public void AddPowerDown(powerup skull) { CollectedPowerUps.Add(skull); UpdatePlayerEffects(); }
public void AddPowerUp(powerup power) { CollectedPowerUps.Add(power); UpdatePlayerEffects(); }
private void UpdatePowerUps() { // No powerup. if (CurrentPowerup == powerup.RegularShot) { fireRate = 0.25f; GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<Camera>().enabled = true; MainCanvas.worldCamera = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<Camera> (); shot = RegularShot; if (GameObject.Find ("Clone(Clone)") != null) { Destroy (GameObject.Find ("Clone(Clone)")); } BeamShot.SetActive (false); // Turns off the vertical beam. //Shield.SetActive (false); // Turns off the shield. HorizontalBeam.SetActive (false); // Turns off the horizontal beam. HelixObject.SetActive (false); gameControllerScript.PowerupText.text = "" + ""; // Shows how much each bullet costs as the powerup text. BeamShot.SetActive (false); // Turns off the beam shot. HorizontalBeam.SetActive (false); // Turns off the horizontal beam shot. LensScript.enabled = true; // if the lens script radius is greater than 0. if (LensScript.radius > 0 && Health > 25) { LensScript.radius -= Time.unscaledDeltaTime; } // if the lens script radius is less than 0. if (LensScript.radius < 0) { LensScript.radius = 0; // Make it equal to exactly 0. } } // Double shot. if (CurrentPowerup == powerup.DoubleShot) { shot = DoubleShot; // Assigns free double shot powerup. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "DOUBLE SHOT!"; // UI displays double shot text. } // WIFI shot. if (CurrentPowerup == powerup.wifi) { fireRate = 0.5f; shot = WifiShot; // Assigns free wifi shot powerup. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "RIPPLE!"; // UI displays double shot text. } // Tri shot. if (CurrentPowerup == powerup.TriShot) { shot = TriShot; // Assigns free triple shot powerup. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "TRIPLE SHOT"; // UI displays triple shot text. } // Beam shot. if (CurrentPowerup == powerup.BeamShot) { BeamShot.SetActive (true); // Turns on vertical beam. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "ULTRA BEAM!"; // UI displays vertical beam text. // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Shield. if (CurrentPowerup == powerup.shield) { //Shield.GetComponent<LensController> ().enabled = true; if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "GIGA SHIELD!"; // UI text to display shield. collisionCooldown = 3; PlayerCollider.enabled = false; // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Horizontal beam. if (CurrentPowerup == powerup.horizontalBeam) { HorizontalBeam.SetActive (true); // Turns on the horizontal beam. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "TERROR BEAM!"; // UI display for powerup text. // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Clone player. if (CurrentPowerup == powerup.Clone) { if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "CLONE!"; // UI display clones. // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Helix bullets. if (CurrentPowerup == powerup.helix) { HelixObject.SetActive (true); if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "MEGA HELIX!"; // UI display clones. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Warning powerup time. if (powerupTime < 3.0f && powerupTime > 2.8f) { ActivePowerupParticles.Stop (); // Turns off main powerup particles. powerupTimeRunningOut.Play (); // Turns on running out particles. TimeRunningOutParticles.Play (); // Plays running out sound. } // When powerup runs out. if (powerupTime < 0) { powerupTime = 0; // Reset powerup time. CurrentPowerup = powerup.RegularShot; // Powerup type is now regular. BeamShot.SetActive (false); // Turns off the beam. if (AbilityActive == abilityActive.no) { PlayerCollider.enabled = true; } if (GameObject.Find ("Clone(Clone)") != null) { Destroy (GameObject.Find ("Clone(Clone)")); } if (Shield.GetComponent<Animator> ().GetCurrentAnimatorStateInfo (0).IsName ("ShieldSustain")) { Shield.GetComponent<Animator> ().Play ("ShieldExit"); PlayerCollider.enabled = true; } HorizontalBeam.SetActive (false); // Turns off the horizontal beam. shot = RegularShot; // Assigns shot to cost points. } // Powerup ran out. if (powerupTime > 0 && powerupTime < 0.05f && !powerupDeactivateAudio.GetComponent<AudioSource> ().isPlaying) { powerupDeactivateAudio.Play (); // Plays powerup ran out sound. } if (powerupTime > 40) { powerupTime = 40; } }
void StartingPowerupConditions() { // Start powerup conditions. CurrentPowerup = powerup.RegularShot; BeamShot.SetActive (false); HorizontalBeam.SetActive (false); HelixObject.SetActive (false); }
public void setPowerup(powerup powerup) { this.powerup = powerup; gameObject.name = powerup.name; }
private void UpdatePowerUps() { // No powerup. if (CurrentPowerup == powerup.RegularShot) { fireRate = 0.25f; GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>().enabled = true; MainCanvas.worldCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera> (); shot = RegularShot; if (GameObject.Find("Clone(Clone)") != null) { Destroy(GameObject.Find("Clone(Clone)")); } BeamShot.SetActive(false); // Turns off the vertical beam. //Shield.SetActive (false); // Turns off the shield. HorizontalBeam.SetActive(false); // Turns off the horizontal beam. HelixObject.SetActive(false); gameControllerScript.PowerupText.text = "" + ""; // Shows how much each bullet costs as the powerup text. BeamShot.SetActive(false); // Turns off the beam shot. HorizontalBeam.SetActive(false); // Turns off the horizontal beam shot. LensScript.enabled = true; // if the lens script radius is greater than 0. if (LensScript.radius > 0 && Health > 25) { LensScript.radius -= Time.unscaledDeltaTime; } // if the lens script radius is less than 0. if (LensScript.radius < 0) { LensScript.radius = 0; // Make it equal to exactly 0. } } // Double shot. if (CurrentPowerup == powerup.DoubleShot) { shot = DoubleShot; // Assigns free double shot powerup. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "DOUBLE SHOT!"; // UI displays double shot text. } // WIFI shot. if (CurrentPowerup == powerup.wifi) { fireRate = 0.5f; shot = WifiShot; // Assigns free wifi shot powerup. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "RIPPLE!"; // UI displays double shot text. } // Tri shot. if (CurrentPowerup == powerup.TriShot) { shot = TriShot; // Assigns free triple shot powerup. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "TRIPLE SHOT"; // UI displays triple shot text. } // Beam shot. if (CurrentPowerup == powerup.BeamShot) { BeamShot.SetActive(true); // Turns on vertical beam. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "ULTRA BEAM!"; // UI displays vertical beam text. // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Shield. if (CurrentPowerup == powerup.shield) { //Shield.GetComponent<LensController> ().enabled = true; if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "GIGA SHIELD!"; // UI text to display shield. collisionCooldown = 3; PlayerCollider.enabled = false; // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Horizontal beam. if (CurrentPowerup == powerup.horizontalBeam) { HorizontalBeam.SetActive(true); // Turns on the horizontal beam. if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "TERROR BEAM!"; // UI display for powerup text. // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Clone player. if (CurrentPowerup == powerup.Clone) { if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "CLONE!"; // UI display clones. // If shot is the regular shot. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Helix bullets. if (CurrentPowerup == powerup.helix) { HelixObject.SetActive(true); if (Time.timeScale > 0) { powerupTime -= Time.unscaledDeltaTime; // Decreases powerup time linearly. } gameControllerScript.PowerupText.text = "MEGA HELIX!"; // UI display clones. if (shot == RegularShot) { shot = RegularShotNoCost; // Make it the free version. } } // Warning powerup time. if (powerupTime < 3.0f && powerupTime > 2.8f) { ActivePowerupParticles.Stop(); // Turns off main powerup particles. powerupTimeRunningOut.Play(); // Turns on running out particles. TimeRunningOutParticles.Play(); // Plays running out sound. } // When powerup runs out. if (powerupTime < 0) { powerupTime = 0; // Reset powerup time. CurrentPowerup = powerup.RegularShot; // Powerup type is now regular. BeamShot.SetActive(false); // Turns off the beam. if (AbilityActive == abilityActive.no) { PlayerCollider.enabled = true; } if (GameObject.Find("Clone(Clone)") != null) { Destroy(GameObject.Find("Clone(Clone)")); } if (Shield.GetComponent <Animator> ().GetCurrentAnimatorStateInfo(0).IsName("ShieldSustain")) { Shield.GetComponent <Animator> ().Play("ShieldExit"); PlayerCollider.enabled = true; } HorizontalBeam.SetActive(false); // Turns off the horizontal beam. shot = RegularShot; // Assigns shot to cost points. } // Powerup ran out. if (powerupTime > 0 && powerupTime < 0.05f && !powerupDeactivateAudio.GetComponent <AudioSource> ().isPlaying) { powerupDeactivateAudio.Play(); // Plays powerup ran out sound. } if (powerupTime > 40) { powerupTime = 40; } }
public static powerup instance; // creates a new instance of the powerup class, we make this static so that it can be used without needing a reference to this class #endregion #region Setup public powerup() { instance = this; // initialises instance and sets it to this class }