/// <summary> /// Update score public method to be invoked by Asteroid collider upon their destruction /// </summary> /// <param name="health"></param> public void UpdateScore(int health) { if (health > 0) { scoreKeeper.AddScore(20f); } else { scoreKeeper.AddScore(50f); } }
private void Hit(Collider2D collision, Laser laser) { float damage = laser.Damage; playerScore.AddScore(hitScore); health -= damage; laser.Hit(); if (health <= 0) { Die(); } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Enemy") || other.CompareTag("Shooting Enemy")) { other.gameObject.tag = "DeadEnemy"; gameController.AddScore(enemyPoints); GameObject.Destroy(gameObject); } else if (other.CompareTag("Asteroid")) { other.gameObject.tag = "DeadAsteroid"; gameController.AddScore(asteroidPoints); GameObject.Destroy(gameObject); } }
public void Process(Pickup pickup) { pickupProperty = pickup.GetPickupProperty(); pickupValue = pickup.GetPickupValue(); analyticsManager.AddPickupsTaken(); switch (pickupProperty) { case "Health": playerController.AddHealth((int)pickupValue); healthDisplay.SetHealth(playerController.GetHealth()); analyticsManager.AddHealthPickups(); break; case "Points": scoreKeeper.AddScore((int)pickupValue); analyticsManager.AddPointPickups(); break; case "Damage": playerController.SetProjectileDamage(pickupValue); analyticsManager.AddDamagePickups(); break; case "ShotSpeed": playerController.IncreaseFiringRate(pickupValue); analyticsManager.AddSpeedPickups(); break; default: Debug.Log("Incorrect Pickup Property!"); break; } pickup.Pick(); }
void Die() { AudioSource.PlayClipAtPoint(deathSound, transform.position); Destroy(gameObject); //could be also FindObjectOfType<ScoreKeeper>().AddScore(points); moze byc wolniejsze od przydzielenia obiektu w Start(), bo musi szukac za kazdym razem obiektu ScoreKeeper. scoreKeeper.AddScore(points); }
} // Update is called once per frame void Update() { //update the time to lose one second each second timeLeft -= Time.deltaTime; if (timeLeft < 0) { timeLeft = 0; modalWindow.SetActive(true); scoreKeep.AddScore(0); scoreKeep.printScore(); } //update the time left text text.text = "Time left: " + Mathf.Round(timeLeft); }
void Boom() { AudioSource.PlayClipAtPoint(deathSound, transform.position); Destroy(gameObject); ScoreKeeper.AddScore(score); }
//----------------------------------------------------------------------------- public void Score(Goal goal) { if (scoreKeeper.AddScore(goal)) { ball.Restart(goal); } }
//----------------------------------------------------------------------------- public void Score(Goal goal) { scoreKeeper.AddScore(goal); ball.Restart(); powerUp.ResetPowerUp(); ball.resetSize(); Time.timeScale = 1f; }
public void TakeDamage(float damage) { this.m_health -= damage; if (!(this.m_owner.GetControl() is HumanAI)) { ScoreKeeper.AddScore((int)damage); } }
void OnCollisionStay2D(Collision2D collision) { if (collision.gameObject.GetComponent(typeof(Player)) != null) { scoreKeeper.AddScore(); } Destroy(gameObject); }
private void Die() { GameObject sparkles = Instantiate(blockSparklesVFX, transform.position, transform.rotation); AudioClip clip = enemyDeath[0]; AudioSource.PlayClipAtPoint(clip, transform.position); Destroy(gameObject); Destroy(sparkles, 1f); scoreKeeper.AddScore(); }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.name == "Snowball" || collision.gameObject.name == "Snowball(Clone)") { // make noise audioSource.Play(); //add pointValue to score scoreKeeper.AddScore(pointValue); } }
//function to check for collisions private void OnTriggerEnter2D(Collider2D collision) { //checks if the collision was a object with the tag lock if (collision.gameObject.tag == "lock") { isCollidedwithLock = true; } //checks if the collision was a object with the tag cell if (collision.gameObject.tag == "cell") { isCollidedwithCell = true; } //checks if it collided with a cell and did not collide with a lock - ie a cell without a lock if ((isCollidedwithCell == true) && (isCollidedwithLock == false)) { //add 5 points to score scoreKeeper.AddScore(scoreValue); //wait coroutine so lock does not reactivate StartCoroutine("wait"); } //checks if it collided with a cell with a lock - ie a cell with a lock still on it if ((isCollidedwithCell == true) && (isCollidedwithLock == true)) { //gets the two rigidbody components Rigidbody2D thisBody = GetComponentInParent<Rigidbody2D>(); Rigidbody2D thatBody = collision.GetComponentInParent<Rigidbody2D>(); //creates a relative direction var rel = new Vector2(thisBody.position.x, 0) - new Vector2(thatBody.position.x, 0); //normalize this value rel.Normalize(); //multiply it by the force variable thisBody.AddForce(rel * force); } } //checks for the trigger being deactivated private void OnTriggerExit2D(Collider2D collision) {
void HandleDamage(float damageAmount) { Health -= damageAmount; if (Health <= 0) { scoreKeeper.AddScore(ScoreValue); AudioSource.PlayClipAtPoint(DestroySound, transform.position); Destroy(gameObject); return; } }
void OnTriggerEnter(Collider other) { string tag = other.gameObject.tag; if (tag == "Wall" || tag == "Body") { KillSnake(); } else if (other.gameObject.tag == "Pickup") { ScoreKeeper.AddScore(other.gameObject.GetComponent <Pickup>().points); Destroy(other.gameObject); GrowSnake(); } }
void OnTriggerEnter2D(Collider2D collider) { Projectile missile = collider.gameObject.GetComponent <Projectile>(); if (missile) { health -= missile.getDamage(); missile.Hit(); if (health <= 0) { Destroy(gameObject); scoreKeeper.AddScore(scoreValue); AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathSoundVolume); } } }
void DragonPowerUp(DragonType.eDragonType dragonType) { if (ManaAdded != null) { ManaAdded(dragonType); sk = FindObjectOfType <ScoreKeeper>(); if (sk != null) { sk.AddScore(); } else { Debug.LogWarning("Scorekeeper object missing, cannot add score."); } } }
void OnTriggerEnter(Collider other) { //Check that it was the ball that collided if (other.GetComponent <BallController>() != null && other.GetComponent <BallData>() != null) { //Get the balldata BallData data = other.GetComponent <BallData>(); //Set the score for this hole ScoreKeeper.AddScore(holeManager.HoleNumber, data.Shots); //Trigger ball potted event if (BallPotted != null) { BallPotted(); } } }
void OnTriggerEnter2D(Collider2D collider) { PlayerLaser projectile = collider.gameObject.GetComponent <PlayerLaser>(); if (projectile) { if ((Health -= projectile.Damage) <= 0) { if (DeathSound != null) { AudioSource.PlayClipAtPoint(DeathSound, Camera.main.transform.position, 1f); } _scoreKeeper.AddScore(ScoreValue); Destroy(gameObject); } projectile.Destroy(); } }
void onHit() { if (enemyHealth <= 1) { scoreKeeper.AddScore(); } enemyHealth--; if (enemyHealth == 2) { this.gameObject.GetComponent <SpriteRenderer> ().color = new Color32(255, 126, 21, 255); } if (enemyHealth == 1) { this.gameObject.GetComponent <SpriteRenderer> ().color = new Color32(255, 145, 63, 255); } }
void OnTriggerEnter(Collider other) { if (other.tag.Equals(gameObject.tag) && gameObject.tag.Equals("Enemy")) { return; } if (other.tag.Equals("Boundry")) { return; } if (other.tag.Equals("Player")) { levelManager.GameOver(); } if (other.tag.Equals("PlayerProjectile")) { scoreKeeper.AddScore(scoreValue); } Instantiate(objectExplosion, transform.position, transform.rotation); Destroy(other.gameObject); Destroy(gameObject); }
void Die() { AudioSource.PlayClipAtPoint(audioClip, transform.position); Destroy(gameObject); scoreKeeper.AddScore(scoreValue); }
public void GetPoint() { // when the ball collides with this goal, give the player a point scorekeeper.AddScore(Player); }
public void Score(Goal goal) { scoreKeeper.AddScore(goal); ball.Restart(); }
private void OnDestroy() { scoreKeeper.AddScore(pointsAwarded); }
public void TakeDamage(float damage) { this.m_health -= damage; ScoreKeeper.AddScore((int)damage); }
void OnCollisionEnter2D(Collision2D collision) { scoreKeeper.AddScore(scoreToAdd); Destroy(gameObject, 1); }
public void Score(Goal goal) { Debug.Log("Manage"); scoreKeeper.AddScore(goal); ball.Restart(goal); }
private void Die() { AudioSource.PlayClipAtPoint(DeathSound, transform.position); _scoreKeeper.AddScore(ScoreValue); Destroy(gameObject); }