/** * <summary> * Select a unit * </summary> * * <returns> * void * </returns> */ public static void Select(GameObject unit) { if (unit.GetComponent <UnitBehaviour>() == null) { throw new Exception(unit.name + " " + "is not a unit type"); } // Clear previous units UnitsManagerBehaviour.UnselectGameObjects(); // Unselect resource if (ResourcesManagerBehaviour.SelectedResource != null) { ResourcesManagerBehaviour.UnselectResource(); } UnitBehaviour unitBehaviour = unit.GetComponent <UnitBehaviour>(); if (unitBehaviour is ISelectableUnit) { UnitsManagerBehaviour.SelectedUnits.Add(unit); unitBehaviour.SetSelect(true); Self.infoComponentPanel.SetActive(true); // Show info component panel Self.infoComponentPanel .transform .Find("Single") .gameObject .SetActive(true); // Hide multiple Self.infoComponentPanel .transform .Find("Multiple") .gameObject .SetActive(false); UnitUI unitUI = unitBehaviour.GetUI().GetComponent <UnitUI>(); InfoComponentPanelUI infoComponentPanelUI = Self.infoComponentPanel.GetComponent <InfoComponentPanelUI>(); infoComponentPanelUI.SetName(unit.name); infoComponentPanelUI.SetHealth(unitBehaviour.GetHealth(), unitBehaviour.GetMaxHealth()); infoComponentPanelUI.SetIcon(unitUI.GetIcon()); // Show action component panel Self.actionComponentPanel.SetActive(true); } }