//private void OnCollisionEnter2D(Collision2D other) //{ // GameObject enemy = other.gameObject; // if (enemy.GetComponent<SpriteRenderer>().renderingLayerMask == enemyMask.value) // { // if (DecreaseLife(enemy.GetComponent<FlyController>().damage) <= 0) // { //murió // this.OnDeathEvent.Invoke(); // } // } //} public float DecreaseLife(float value) { //print("verga " + value); this.lifeActual -= value; //this.healthBar.value = Mathf.Clamp(this.lifeActual, this.healthBar.minValue, this.healthBar.maxValue); if (loadHud) { ConfigHUD(); } /// check if enemy or boss if (lifeActual <= 0) { //murió this.OnDeathEvent.Invoke(); } StartCoroutine(cameraShake.CinemachineShake(0.3f, 10)); return(this.lifeActual); }