/*void OnCollisionEnter2D(Collision2D other) * { * if (other.gameObject.tag == "enemy") * { * if (transform.position.x <= other.transform.position.x) * m_Rigidbody.AddForce(new Vector2(-1, 1) * knockForce); * else * m_Rigidbody.AddForce(new Vector2(1, 1) * knockForce); * * LoseWater(damageTaken); * * GetComponent<Animator>().SetTrigger("Hit"); * isHit = true; * } * }*/ void OnTriggerExit2D(Collider2D other) { switch (other.gameObject.tag) { case "CloudZone": if (zone != null) { if (zone.path != null) { zone.path.Deactivate(); } } insideCloudeZone = false; zone = null; break; case "HealingCloud": other.gameObject.GetComponent <HealingCloudController>().StopRain(); break; case "Drop": waterCost = 0; insideDropZone = false; Dropzone = null; break; case "HotZone": currentWaterLose = WATER_LOSS; break; default: break; } if (other.gameObject.tag == "DropZone") { waterCost = 0; insideDropZone = false; Dropzone = null; } }
void OnTriggerEnter2D(Collider2D other) { switch (other.gameObject.tag) { case "CloudZone": insideCloudeZone = true; zone = other.gameObject.GetComponent <CloudZoneController>(); if (zone != null) { if (zone.path != null) { zone.path.Activate(); } } break; case "HealingCloud": other.gameObject.GetComponent <HealingCloudController>().StartRain(); break; case "Drop": if (other.GetComponent <DropZoneController>() != null) { insideDropZone = true; waterCost = other.GetComponent <DropZoneController>().Cost; } break; case "HotZone": HotZone hotZone = other.gameObject.GetComponent <HotZone>(); currentWaterLose = hotZone.WaterLoss; break; case "MagmaZone": SceneManager.LoadScene("GameOver"); break; case "enemy": if (!isHit) { if (transform.position.x <= other.transform.position.x) { m_Rigidbody.AddForce(new Vector2(-1, 1) * knockForce); } else { m_Rigidbody.AddForce(new Vector2(1, 1) * knockForce); } LoseWater(damageTaken); transform.Find("Container").GetComponent <Animator>().SetTrigger("Hit"); isHit = true; StartCoroutine(PreventHit()); } break; default: break; if (other.tag == "DropZone") { insideDropZone = true; waterCost = other.GetComponent <DropZoneController>().Cost; } } if (other.gameObject.tag == "CheckPoint") { CheckPoint checkPoint = other.gameObject.GetComponent <CheckPoint>(); if (!checkPoint.IsChecked) { LevelManager.instance.CheckPoint = checkPoint.Index; checkPoint.IsChecked = true; } } }