public void OnRec_ChangeData(INotification noti) { CardRole hero = noti.Body as CardRole; fightrolehppanel_item itemUI = CardRoleHPDic[hero]; UpdateData(itemUI, hero.SerData); }
private void UpdateData(fightrolehppanel_item itm, FightHeroMsg data) { if (data.hp < 0) { data.hp = 0; } if (data.shield < 0) { data.shield = 0; } itm.curHpLab.text = data.hp.ToString(); itm.dieLab.gameObject.SetActive(data.hp <= 0); itm.shieldLab.text = data.shield.ToString(); itm.maxHpLab.text = data.maxHp.ToString(); }
private void OnRec_AddMyHP(INotification noti) { CardRole cdRole = noti.Body as CardRole; GameObject obj; obj = GameObject.Instantiate(m_Panel.roleHP.gameObject) as GameObject; fightrolehppanel_item itm = ScriptHelper.BindField(obj.transform, "fightrolehppanel_item") as fightrolehppanel_item; obj.SetActive(true); obj.transform.SetParent(m_Panel.transform); obj.transform.localScale = Vector3.one; CardRoleHPDic[cdRole] = itm; if (cdRole.SerData != null) { itm.nameLab.text = HeroConfig.GetItem(cdRole.SerData.heroId).name; UpdateData(itm, cdRole.SerData); } }