//Get more cogs public void MoreCogs() { //Give the player 20 more cogs ruby.cogs += 20; ruby.cogCounter.text = "Cogs: " + ruby.cogs.ToString(); //COST: Lower the player health by 2 ruby.ChangeHealth(-2); ruby.choices = false; //Close the buttons ruby.canbuy = false; //Stop from overbuying ruby.defaultLoss = true; //Display default message when the player has no more chances }
// collission checker private void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); RubyPlatformerControl controller2 = other.GetComponent <RubyPlatformerControl>(); if (controller != null) { if (controller.health < controller.maxHealth) { // breytir health, eyðir objectinu, synir effect og spilar hljoðið controller.ChangeHealth(1); Destroy(gameObject); HealthCollisionEffect = Instantiate(HealthEffect, transform.position, Quaternion.identity) as ParticleSystem; HealthCollisionEffect.Play(); controller.PlaySound(collectedClip); } } if (controller2 != null) { if (controller2.health < controller2.maxHealth) { // breytir health, eyðir objectinu, synir effect og spilar hljoðið controller2.ChangeHealth(1); Destroy(gameObject); HealthCollisionEffect = Instantiate(HealthEffect, transform.position, Quaternion.identity) as ParticleSystem; HealthCollisionEffect.Play(); controller2.PlaySound(collectedClip); } } }
// Update is called once per frame void Update() { timer -= Time.deltaTime; if (timer < 0) { direction = -direction; timer = changeTime; } Vector2 position = rigidbody2D.position; if (vertical) { position.y = position.y + Time.deltaTime * speed * direction; } else { position.x = position.x + Time.deltaTime * speed; } rigidbody2D.MovePosition(position); void OnCollisionEnter2D(Collision2D other) { RubyController player = other.gameObject.GetComponent <RubyController>(); if (player != null) { player.ChangeHealth(-1); } } }
void OnTriggerStay2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if ((controller != null) && (controller.CurrentHealth > 0)) { controller.ChangeHealth(-amount); } }
void OnCollisionEnter2D(Collision2D other) { RubyController ruby = other.gameObject.GetComponent <RubyController>(); if (ruby) { ruby.ChangeHealth(-damage); } }
void OnTriggerEnter2D(Collider2D collision) { RubyController controller = collision.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(-25f); } }
void attck(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(-1); } }
void OnTriggerStay2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(areaDamage); } }
private void OnTriggerStay2D(Collider2D collision) { RubyController controller = collision.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(healthChangeAmount); } }
private void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(-1); } }
//触发检测 private void OnCollisionEnter2D(Collision2D collision) { RubyController rubyController = collision.gameObject.GetComponent <RubyController>();//注意这里跟trigger的不太相同。 if (rubyController != null) { rubyController.ChangeHealth(-1); } }
void OnCollisionStay2D(Collision2D collision) { RubyController rc = collision.gameObject.GetComponent <RubyController>(); if (rc) { rc.ChangeHealth(-1); } }
private void OnTriggerStay2D(Collider2D collision) { RubyController rb = collision.GetComponent <RubyController>(); if (rb != null) { rb.ChangeHealth(-1); } }
private void OnTriggerEnter2D(Collider2D collision) { RubyController player = collision.gameObject.GetComponent <RubyController>(); if (player != null) { player.ChangeHealth(-1); } }
private void OnCollisionEnter2D(Collision2D other) { RubyController player = other.gameObject.GetComponent <RubyController>(); // get the script from the player if (player != null) // if is not empty the variable { player.ChangeHealth(-1); // damages the player } }
private void OnCollisionExit2D(Collision2D collision) { RubyController rubyController = collision.gameObject.GetComponent <RubyController>(); if (rubyController != null) { rubyController.ChangeHealth(-1); } }
void OnCollisionEnter2D(Collision2D other) { RubyController player = other.gameObject.GetComponent <RubyController>(); if (player != null) { player.ChangeHealth(-1); } }
void Trigger(GameObject other) { RubyController ruby = other.GetComponent <RubyController>(); if (ruby) { ruby.ChangeHealth(-damage); } }
void OnTriggerStay2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null && controller.health >= 0) { controller.ChangeHealth(-1); } }
// Start is called before the first frame update void OnTriggerStay2D(Collider2D other) { RubyController ruby = other.GetComponent <RubyController>(); if (ruby != null) { ruby.ChangeHealth(-1); } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(1); Destroy(gameObject); } }
void OnTriggerStay2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController> (); if (controller != null) { controller.ChangeHealth(-1); audioSource.PlayOneShot(clip, volume); } }
void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(-10); controller.PlaySound(collectedClip); } }
private void OnTriggerEnter2D(Collider2D collision) { RubyController controller = collision.GetComponent <RubyController>(); if (controller != null && controller.health < controller.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); } }
// For every second on the damage zone, the player takes 1 private void OnTriggerStay2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); // controller handles if invincibility is active if (controller != null) { controller.ChangeHealth(-1); } }
private void OnTriggerStay2D(Collider2D collision) { RubyController rubyController = collision.GetComponent <RubyController>(); if (rubyController != null) { rubyController.ChangeHealth(-1); Debug.Log("ruby's health:" + rubyController.health); } }
void OnTriggerStay2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null) { controller.ChangeHealth(-1); controller.PlaySound(hitFromDamageZoneClip); } }
void OnTriggerStay2D(Collider2D iOther) { RubyController gController = iOther.GetComponent <RubyController>(); if (gController != null) { gController.ChangeHealth(-1); Debug.Log(gController.gHealth); } }
// Start is called before the first frame update void OnTriggerEnter2D(Collider2D other) { RubyController controller = other.GetComponent <RubyController>(); if (controller != null && controller.ChangeHealth(1, false)) { Destroy(gameObject); controller.PlaySound(collectedClip); } }
void OnCollisionEnter2D(Collision2D other) { RubyController player = other.gameObject.GetComponent <RubyController> (); if (player != null) { player.ChangeHealth(-1); player.PlaySound(collectedClip); //ruby getting hurt } }