コード例 #1
0
    public void SetHp(int hp)
    {
        this.hp = Mathf.Max(0, Mathf.Min(characterStatus.GetMaxHp(), hp));

        if (this.hp <= 0)
        {
            Dead();
        }
    }
コード例 #2
0
 // データの更新
 public void UpdateStatus(CharacterStatus characterStatus, Status status, int destinationValue)
 {
     if (status == Status.HP)
     {
         characterStatusDictionary[characterStatus].Find("HPSlider").GetComponent <Slider>().value = (float)destinationValue / characterStatus.GetMaxHp();
         characterStatusDictionary[characterStatus].Find("HPText").GetComponent <Text>().text      = "HP: " + destinationValue.ToString() + "/" + characterStatus.GetMaxHp().ToString();
     }
     else if (status == Status.MP)
     {
         characterStatusDictionary[characterStatus].Find("MPSlider").GetComponent <Slider>().value = (float)destinationValue / characterStatus.GetMaxMp();
         characterStatusDictionary[characterStatus].Find("MPText").GetComponent <Text>().text      = "HP: " + destinationValue.ToString() + "/" + characterStatus.GetMaxMp().ToString();
     }
 }