public void UpdateUnit(int i, Unit u) { UnitUI ui = _units[i]; ui.SetKO(u.IsKO()); ui.SetDefending(u.IsDefending()); ui.SetPrisoner(u.IsPrisoner()); ui.SetUpgrade(u.HasUpgrade()); if (u.IsKO()) { UnitOverview.transform.GetChild(i).GetComponent <Image>().color = Color.clear; } else if (u.IsDefending()) { UnitOverview.transform.GetChild(i).GetComponent <Image>().color = DefendingColour; } else { UnitOverview.transform.GetChild(i).GetComponent <Image>().color = OverviewColour; } }
public void AddUnit(Unit u) { GameObject obj = Instantiate(UnitPrefab); obj.transform.SetParent(UnitList.transform); obj.transform.localScale = Vector3.one; UnitUI ui = obj.GetComponent <UnitUI> (); ui.SetImage(getSprite(u.Type)); ui.SetKO(u.IsKO()); ui.SetIndex(_units.Count); ui.SetUpgrade(u.HasUpgrade()); ui.SetDefending(u.IsDefending()); ui.SetPrisoner(u.IsPrisoner()); ui.OnClick += _clickUnit; if (_selectMode) { ui.EnableSelection(); } _units.Add(ui); GameObject g = new GameObject(); Image image = g.AddComponent <Image> (); g.transform.SetParent(UnitOverview.transform); g.transform.localScale = Vector3.one; if (u.IsKO()) { image.color = Color.clear; } else if (u.IsDefending()) { image.color = DefendingColour; } else { image.color = OverviewColour; } }