public void UpdateLifeBar() { if (_player != null) { BoatCharacter boatChar = _player.GetComponentInChildren <BoatCharacter>(); if (boatChar == null) { Debug.LogError("Boatchar is null"); } //if (boatChar.getCurrentLife() == null) //{ // Debug.LogError("Boatchar is null"); //} //if (boatChar.getMaxLife() == null) //{ // Debug.LogError("Boatchar is null"); //} if (boatChar.getCurrentLife() >= 0 && boatChar.getCurrentLife() <= boatChar.getMaxLife()) { //Debug.LogError("Life : " + boatChar.getCurrentLife()); //Debug.LogError("before : " + lifeBar.GetComponent<RectTransform>().sizeDelta); lifeBar.GetComponent <RectTransform>().sizeDelta = new Vector2((maxLifeBarSize / boatChar.getMaxLife()) * boatChar.getCurrentLife(), lifeBar.GetComponent <RectTransform>().sizeDelta.y); //Debug.LogError("after : " + lifeBar.GetComponent<RectTransform>().sizeDelta); } } else { if (hp >= 0 && hp <= maxhp) { lifeBar.GetComponent <RectTransform>().sizeDelta = new Vector2((maxLifeBarSize / maxhp) * hp, lifeBar.GetComponent <RectTransform>().sizeDelta.y); } } }
///Ajout seb public void SetBoatCharacterReference(BoatCharacter currentBoat) { _boatCharacter = currentBoat; }