コード例 #1
0
    private void HPSystem_OnDamaged(object sender, System.EventArgs e)
    {
        List <HPSystem.HP> hpList = hpSystem.GetHPList();

        for (int i = 0; i < hpImageList.Count; i++)
        {
            HPImage     hpImage = hpImageList[i];
            HPSystem.HP hp      = hpList[i];
            hpImage.SetHPFragments(hp.GetFragmentAmount());
        }
    }
コード例 #2
0
    private HPImage CreateHPImage(Vector2 anchoredPosition)
    {
        GameObject hpGameObject = new GameObject("HP", typeof(Image));

        hpGameObject.transform.parent        = transform;
        hpGameObject.transform.localPosition = Vector3.zero;

        hpGameObject.GetComponent <RectTransform>().anchoredPosition = anchoredPosition;
        hpGameObject.GetComponent <RectTransform>().sizeDelta        = new Vector2(200, 200);

        Image hpImageUI = hpGameObject.GetComponent <Image>();

        hpImageUI.sprite = hp4Sprite;


        HPImage hpImage = new HPImage(this, hpImageUI);

        hpImageList.Add(hpImage);

        return(hpImage);
    }