public void OnSelectionChanged() { var go = Selection.GetPriorityUnit(); if (go != null) { trainComponent = go.GetComponent <TrainComponent>(); } else { trainComponent = null; Toggle(false); } }
public void GenerateGrid() { try { ActionGridComponent comp = Selection.GetPriorityUnit().GetComponent <ActionGridComponent>(); if (comp != null) { foreach (var item in comp.list) { var ob = GameObject.Instantiate(CellPrefab, this.transform); ob.GetComponent <ActionCellComponent>().Action = item; } } } catch (Exception) { } }
public void OnSelectionChanged() { RemoveListeners(); CurrentUnit = Selection.GetPriorityUnit(); if (CurrentUnit != null) { transform.GetChild(0).gameObject.SetActive(true); var attackController = CurrentUnit.GetComponent <AttackController>(); if (attackController == null) { AttackText.transform.parent.gameObject.SetActive(false); } else { AttackText.transform.parent.gameObject.SetActive(true); AttackText.text = CurrentUnit.GetEnabledComponent <AttackController>().AttackPower.ToString(); } UnitLabelName.text = CurrentUnit.GetComponent <UnitComponent>().Model.name; Thumbnail.texture = CurrentUnit.GetComponent <UnitComponent>().Model.Thumbnail; var des = CurrentUnit.GetComponent <DestructableComponent>(); if (des != null) { CurrentUnit.GetComponent <DestructableComponent>().OnDamageTaken.AddListener(SelectedOnDamageTaken); SelectedOnDamageTaken(); } } else { //nothing selected transform.GetChild(0).gameObject.SetActive(false); } }