コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
 ///Ajout seb
 public void SetBoatCharacterReference(BoatCharacter currentBoat)
 {
     _boatCharacter = currentBoat;
 }