void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>(); if (shot != null && !immuneToDamage && !dead) { // Avoid friendly fire, apply ranged immunity if ((!(immuneToShots && !shot.isMelee)) && shot.team != team) { Damage(shot.damage); shot.onImpact(gameObject.transform); } } else { //Is this the activator object? ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null && !manualActivation && !active) { if (activator.isActivator) { active = true; } } } }
void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>(); if (shot != null && !immuneToShots) { // Avoid friendly fire if (shot.isEnemyShot != isEnemy) { Damage(shot.damage); shot.onImpact(gameObject.transform); } } else { //Is this the activator object? ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null && !manualActivation && !active) { if (activator.isActivator) { active = true; } } } }
void OnTriggerEnter2D(Collider2D otherCollider) { // Is this a shot? ShotScript shot = otherCollider.gameObject.GetComponent <ShotScript>(); if (shot != null) { // Avoid friendly fire if (shot.isEnemyShot != isEnemy) { Damage(shot.damage); shot.onImpact(gameObject.transform); } } // Is this the activator object? ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null) { if (activator.isActivator && !manualActivation) { active = true; } else if (!manualActivation) // If it has an activator script but not isActivator, it's a deactivator { active = false; } } }
void OnTriggerExit2D(Collider2D otherCollider) { ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null && !manualActivation && active && (lifeTimer > minLifeTime)) { active = false; Invoke("fadeAway", fadeLifetime); // Vanish without explosion after a short time } }
// Update is called once per frame void Update() { if (Time.time - startTime > 230) { SceneManager.LoadScene(0); } if (!ended && Time.time - startTime > endTime) { foreach (Note obj in GameObject.FindObjectsOfType <Note>()) { Destroy(obj.gameObject); } GameObject.Find("outer_ring").GetComponent <SpriteRenderer>().enabled = false; ActivatorScript activator = FindObjectOfType <ActivatorScript>().GetComponent <ActivatorScript>(); GameObject.Find("Score").SetActive(false); int finalscore = activator.getScore(); GameObject.Find("Score Label").GetComponent <Text>().enabled = true; GameObject.Find("Finalscore").GetComponent <Text>().enabled = true; GameObject.Find("Finalscore").GetComponent <Text>().text = "" + finalscore; GameObject.Find("HighscoreLabel").GetComponent <Text>().enabled = true; GameObject.Find("Highscore").GetComponent <Text>().enabled = true; if (finalscore > PlayerPrefs.GetInt("highscore", 0)) { PlayerPrefs.SetInt("highscore", finalscore); } else { finalscore = PlayerPrefs.GetInt("highscore", 0); } GameObject.Find("Highscore").GetComponent <Text>().text = "" + finalscore; ended = true; activator.enabled = false; } if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(2); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
void OnTriggerExit2D(Collider2D otherCollider) { ActivatorScript activator = otherCollider.gameObject.GetComponent <ActivatorScript>(); if (activator != null && !manualActivation && active && (lifeTimer > minLifeTime)) { active = false; Invoke("fadeAway", fadeLifetime); // Vanish without explosion after a short time if (fadeScore > 0 && hp == maxHp) { ScoreKeeperScript.Instance.AddPoints(fadeScore); } if (damagedFadeScore > 0 && hp < maxHp) { ScoreKeeperScript.Instance.AddPoints(damagedFadeScore); } } }