// Update is called once per frame private void UpdateFromModel() { PanelManaCrystal.GetComponentInChildren <Text>().text = _HeroModel.ActualMana + "/" + _HeroModel.MaxMana; if (PanelHand.GetComponent <ScrollableList>() != null) { List <GameObject> gos = PanelHand.GetComponent <ScrollableList>().ElementsToPut; for (int i = 0; i < gos.Count; i++) { gos[i].SetActive(_HeroModel.Hand.Count > i); if (_HeroModel.Hand.Count > i && gos[i].GetComponent <PanelTile>() != null) { gos[i].GetComponent <PanelTile>().PanelAvatar.GetComponent <PanelAvatar>().PanelAvatarCard.GetComponent <PanelAvatarCard>().PreviewCardHand(_HeroModel, _HeroModel.Hand[i], WhereAmI.Hand); } } } else if (PanelHand.GetComponent <PanelHand>() != null) { PanelHand.GetComponent <PanelHand>().UpdateWith(_HeroModel, _HeroModel.Hand); } Deck.GetComponentInChildren <Text>().text = "" + _HeroModel.Deck.Count; PanelSpecialPower.SetActive(false); if (_HeroModel.Card.Effects.ContainsKey(Effect.HerosSpecialPower)) { PanelSpecialPower.SetActive(true); PanelSpecialPower.GetComponentInChildren <PanelAvatarCard>().PreviewCardHand(_HeroModel, _HeroModel.Card.Effects[Effect.HerosSpecialPower][0], WhereAmI.SpecialPower); } }
void Awake() { GameObject newItem = Instantiate(AvatarCardPrefab) as GameObject; newItem.name = "Special power"; newItem.GetComponent <PanelAvatarCard>().WhereAmI = WhereAmI.SpecialPower; newItem.transform.parent = PanelSpecialPower.transform; //move and size the new item RectTransform rectTransform = newItem.GetComponent <RectTransform>(); rectTransform.offsetMin = new Vector2(0, 0); rectTransform.offsetMax = new Vector2(0, 0); rectTransform.rotation = PanelSpecialPower.GetComponent <RectTransform>().rotation; }