public void AddToScore(int newValue = 0) { if (scoreKeeper == null) { GameObject gameController = GameObject.Find("GameController"); scoreKeeper = (ScoreKeeper)gameController.GetComponent(typeof(ScoreKeeper)); } if (newValue == 0) { scoreKeeper.AddToScore(Value); } else { scoreKeeper.AddToScore(newValue); } }
private void Scored() { SpriteRenderer sr = this.GetComponent <SpriteRenderer>(); Rigidbody2D r = this.GetComponent <Rigidbody2D>(); ScoreKeeper.AddToScore(r.mass); sr.color = Color.green; }
void OnCollisionEnter(Collision coll) { if (coll.transform.tag == "Bolt" && !hit) { sk.AddToScore(10); hit = true; } }
/// <summary> /// change the color of the target box; add score; /// </summary> private void Scored() { this.gameObject.GetComponent <SpriteRenderer> ().color = Color.green; if (!ScoreAdded) { ScoreKeeper.AddToScore(this.gameObject.GetComponent <Rigidbody2D>().mass); ScoreAdded = true; } }
private void Scored() { // FILL ME IN gameObject.GetComponent <SpriteRenderer>().color = Color.green; if (this.first == false) { ScoreKeeper.AddToScore(this.GetComponent <Rigidbody2D>().mass); first = true; } }
private void Scored() { GetComponent <SpriteRenderer>().color = Color.green; float mas = GetComponent <Rigidbody2D>().mass; if (gameObject.tag != "Scored") { ScoreKeeper.AddToScore(mas); gameObject.tag = "Scored"; // Make sure each box only scores once } }
private void Scored() { SpriteRenderer render = gameObject.GetComponent <SpriteRenderer>(); float mass = gameObject.GetComponent <Rigidbody2D>().mass; if (render.color != Color.green) { ScoreKeeper.AddToScore(mass); render.color = Color.green; } }
// Check for collisions with player void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { // Destroy coin Destroy(gameObject); // Add to score scorekeeper.AddToScore(100); } }
private void Scored() { TargetBox t = this.gameObject.GetComponent <TargetBox>(); float mass = t.GetComponent <Rigidbody2D>().mass; SpriteRenderer s = t.gameObject.GetComponent <SpriteRenderer>(); if (s.color != Color.green) { ScoreKeeper.AddToScore(mass); s.color = Color.green; } }
void TakeDamageFrom(Projectile projectile) { hp -= projectile.damage; if (hp <= 0) { scoreKeeper.AddToScore(this.scoreWorth, projectile.playerNumber); print("destroyed adding " + scoreWorth.ToString()); Destroy(gameObject); AudioSource.PlayClipAtPoint(destroyedSound, transform.position); } projectile.OnHit(); }
internal void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Enemy")) { Destroy(gameObject); Destroy(other.gameObject); ScoreKeeper.AddToScore(10.0f); } else if (other.gameObject.CompareTag("Base")) { Destroy(gameObject); } }
private void Scored() { SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.color = Color.green; Rigidbody2D rigidBody = GetComponent <Rigidbody2D>(); if (!scoreCounted) { ScoreKeeper.AddToScore(rigidBody.mass); scoreCounted = true; } }
/// <summary> /// Kills enemy /// </summary> private void Die() { //Decrease enemy count by 1 on EnemySpawner gameObject.transform.parent.parent.GetChild(0).GetComponent <EnemySpawner>().EnemyKilled(); //IncreaseScore ScoreKeeperGO.AddToScore((int)TotalHealth); AudioSource.PlayClipAtPoint(deathSound, transform.position); GetExplosionGO(); GameObject ex = Instantiate(explosion, this.transform.position, Quaternion.identity) as GameObject; ex.SetActive(true); //Invokes explosion on awake with self destruct //Destroy enemy game object Destroy(gameObject); }
// Update is called once per frame void Update() { var currentNum = baseTrans.childCount; if (currentNum != _childNum) { GetComponent <AudioSource>().PlayOneShot(destroySound); ScoreKeeper.AddToScore(-20.0f); } _childNum = currentNum; if (_childNum == 0) { GameOver.isGameOver = true; Destroy(gameObject); } }
public void SpawnObject(GameObject spawningObject) { Debug.Log("Spawning Boulder and adding to score"); theScore.AddToScore(1); BallScript thisBallScript = spawningObject.GetComponent <BallScript>(); ScaleShifter scaleShift = GameObject.FindObjectOfType <ScaleShifter>().GetComponent <ScaleShifter>(); scaleShift.ShiftObjectScale(spawningObject); int i = Random.Range(0, objectSpawner.Length); spawningObject.transform.position = objectSpawner[i].transform.position; spawningObject.SetActive(true); thisBallScript.LaunchBall(-1f); }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { if (anim.GetBool("coinBoxDisabled") == false) { // Set animation vaiable to trigger hit animation anim.SetBool("coinBoxHit", true); // Set animation variable to transition to disabled anim.SetBool("coinBoxDisabled", true); scorekeeper.AddToScore(100); } } }
private void Scored() { // FILL ME IN Color green = new Color(0f, 255f, 0f); if (gameObject.GetComponent <SpriteRenderer>().color != green) { gameObject.GetComponent <SpriteRenderer>().color = green; ScoreKeeper.AddToScore(gameObject.GetComponent <Rigidbody2D>().mass); //Checking if Robot scene if (SceneManager.GetActiveScene().name == "Robot" && GameObject.FindGameObjectWithTag("Bomb")) { RobotTalk.ChangeText(); } } }