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

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