Ejemplo n.º 1
0
 void RemoveListeners()
 {
     if (CurrentUnit != null)
     {
         CurrentUnit.GetComponent <DestructableComponent>().OnDamageTaken.RemoveListener(SelectedOnDamageTaken);
     }
 }
Ejemplo n.º 2
0
        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);
            }
        }