public void setChar(Damagable character, GameObject background) { Char = character; backdrop = background; HealthBar = Instantiate(healthBar, new Vector3(0, 0, 0), Quaternion.identity); HealthBar.transform.SetParent(this.gameObject.transform, false); HealthBar.SetHealthBar(Char); this.gameObject.GetComponent <Image>().sprite = Char.getImages()[0]; this.gameObject.transform.SetParent(backdrop.transform, false); }
public override void DoImmediateAnimation(VEntity entity) { VEntity targetEntity = ecsManager.GetVEntityByIdIncludingRemoved(entity.GetVComponent <EntityAppearEvent>().entityId); HealthDisplayComponent healthDisplay = ecsManager.GetVEntityById(entity.GetVComponent <EntityAppearEvent>().entityId).GetVComponent <HealthDisplayComponent>(); healthDisplay.healthBarDisplay = HealthBarDisplay.Instantiate(healthBarDisplayPrefab); HealthComponent h = targetEntity.GetVComponent <HealthComponent>(); Assert.IsNotNull(h); healthDisplay.healthBarDisplay.Init(h.maxHealth); healthDisplay.healthBarDisplay.SetValue(h.currHealth); var positionDisplay = targetEntity.GetVComponent <PositionDisplayComponent>(); healthDisplay.healthBarDisplay.transform.position = positionDisplay.mainTransform.position; healthDisplay.healthBarDisplay.transform.SetParent(positionDisplay.mainTransform); }