Пример #1
0
        public void InitStart(UnitBasic _unit)
        {
            theUnit = _unit;

            uiRootRect = GetComponent <RectTransform>();
            //Debug.Log(transform.position);
        }
Пример #2
0
 public void Add(UnitBasic _unit)
 {
     if (!unitList.Contains(_unit))
     {
         unitList.Add(_unit);
         InvokeListEvent(addUnitEventListeners, _unit);
     }
 }
Пример #3
0
        public UnitBasic GetRandomUnit()
        {
            UnitBasic instance = null;

            if (unitList.Count > 0)
            {
                int index = Random.Range(0, unitList.Count);
                instance = unitList[index];
            }

            return(instance);
        }
Пример #4
0
 private void InvokeListEvent(List <UnitListEvent> _eventListeners, UnitBasic _unit)
 {
     for (int i = (_eventListeners.Count - 1); i >= 0; i--)
     {
         if (!_eventListeners[i].Equals(null))
         {
             _eventListeners[i](_unit);
         }
         else
         {
             _eventListeners.RemoveAt(i);
         }
     }
 }
Пример #5
0
        public void Remove(UnitBasic _unit, bool _recycle)
        {
            if (unitList.Contains(_unit))
            {
                unitList.Remove(_unit);
                InvokeListEvent(removeUnitEventListeners, _unit);
            }

            if (_recycle)
            {
                _unit.RecycleSelf();
            }
            else
            {
                Destroy(_unit.gameObject);
            }
        }