void OnCollisionEnter2D(Collision2D collision) { RatMove RatAraña = collision.collider.GetComponent <RatMove>(); Engrane Engranes = collision.collider.GetComponent <Engrane>(); Flamas FireDamage = collision.collider.GetComponent <Flamas>(); if (Engranes != null) { HealthSlider.value -= 50; currentHealth = HealthSlider.value; anim.SetTrigger("Hurt"); // Activa el Trigger en el Animator GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } if (FireDamage != null) { HealthSlider.value -= 50; currentHealth = HealthSlider.value; anim.SetTrigger("Hurt"); // Activa el Trigger en el Animator GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } }
void OnCollisionEnter2D(Collision2D collision) { RatMove RatAraña = collision.collider.GetComponent <RatMove>(); Engrane Engranes = collision.collider.GetComponent <Engrane>(); Flamas FireDamage = collision.collider.GetComponent <Flamas>(); if (collision.gameObject.CompareTag("Engranes")) { HealthSlider.value -= 5; currentHealth = HealthSlider.value; //HurtTimer(TimeAfterHurt); // Activa el Trigger en el Animator anim.SetBool("isHurt", true); GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } if (collision.gameObject.CompareTag("Rata")) { HealthSlider.value -= 5; currentHealth = HealthSlider.value; //HurtTimer(TimeAfterHurt); // Activa el Trigger en el Animator anim.SetBool("isHurt", true); GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } if (collision.gameObject.CompareTag("Vida")) { HealthSlider.value += 15; currentHealth = HealthSlider.value; //HurtTimer(TimeAfterHurt); // Activa el Trigger en el Animator GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca //Hurt(); } if (FireDamage != null) { HealthSlider.value -= 5; currentHealth = HealthSlider.value; //HurtTimer(TimeAfterHurt); // Activa el Trigger en el Animator anim.SetBool("isHurt", true); GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } if (collision.gameObject.CompareTag("proyecty")) { HealthSlider.value -= 5; currentHealth = HealthSlider.value; //HurtTimer(TimeAfterHurt); // Activa el Trigger en el Animator anim.SetBool("isHurt", true); GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } }
private void OnTriggerEnter2D(CapsuleCollider2D other) { RatMove RatAraña = gameObject.GetComponent <RatMove>(); if (gameObject.tag == "Deadly") { HealthSlider.value -= 35f; currentHealth = HealthSlider.value; anim.SetTrigger("Hurt"); // Activa el Trigger en el Animator GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } }
private void OnTriggerEnter2D(Collider2D other) { RatMove RatAraña = gameObject.GetComponent <RatMove>(); if (gameObject.tag == "Deadly") { HealthSlider.value -= 15; currentHealth = HealthSlider.value; //HurtTimer(TimeAfterHurt); // Activa el Trigger en el Animator anim.SetBool("isHurt", true); GetComponent <Rigidbody2D>().AddForce(new Vector2(-25, 1200)); //Resetea la velocidad del personaje para que no avance mientras ataca Hurt(); } }
// Start is called before the first frame update void Start() { rb.GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); playerHP = GetComponent <PlayerHealth>(); batMove = GetComponent <BatMove>(); catMove = GetComponent <CatMove>(); ratMove = GetComponent <RatMove>(); animals[0].SetActive(false); animals[1].SetActive(true); animals[2].SetActive(false); upperLength = groundLength; }
// Use this for initialization void Start() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } if (LevelEnd == null) { LevelEnd = new UnityEvent(); } if (GameOver == null) { GameOver = new UnityEvent(); } if (uiManager == null) { uiManager = GetComponent <UIManager>(); } LevelEnd.AddListener(uiManager.OnLevelEnd); LevelEnd.AddListener(AddLevelCount); player = GameObject.FindGameObjectWithTag("Player"); endLight = GameObject.Find("End Light"); GameObject[] monsterObjects = GameObject.FindGameObjectsWithTag("Monster"); for (int i = 0; i < monsterObjects.Length; i++) { WanderingAI aiScript = monsterObjects[i].GetComponent <WanderingAI>(); MonsterAttack attackScript = monsterObjects[i].GetComponent <MonsterAttack>(); GameOver.AddListener(aiScript.PlayerIsDead); GameOver.AddListener(attackScript.PlayerIsDead); LevelEnd.AddListener(aiScript.PlayerIsDead); LevelEnd.AddListener(attackScript.PlayerIsDead); } GameObject[] skullObjects = GameObject.FindGameObjectsWithTag("Skull"); for (int i = 0; i < skullObjects.Length; i++) { SkullMove aiScript = skullObjects[i].GetComponent <SkullMove>(); SkullAttack attackScript = skullObjects[i].GetComponent <SkullAttack>(); GameOver.AddListener(aiScript.PlayerIsDead); GameOver.AddListener(attackScript.PlayerIsDead); LevelEnd.AddListener(aiScript.PlayerIsDead); LevelEnd.AddListener(attackScript.PlayerIsDead); } GameObject[] ratObjects = GameObject.FindGameObjectsWithTag("Rat"); for (int i = 0; i < ratObjects.Length; i++) { RatMove aiScript = ratObjects[i].GetComponent <RatMove>(); RatAttack attackScript = ratObjects[i].GetComponent <RatAttack>(); GameOver.AddListener(aiScript.PlayerIsDead); GameOver.AddListener(attackScript.PlayerIsDead); LevelEnd.AddListener(aiScript.PlayerIsDead); LevelEnd.AddListener(attackScript.PlayerIsDead); } GameOver.AddListener(uiManager.OnGameOver); GameOver.AddListener(GetComponent <ScreenFader>().OnGameOver); }