public void InitStart(UnitBasic _unit) { theUnit = _unit; uiRootRect = GetComponent <RectTransform>(); //Debug.Log(transform.position); }
public void Add(UnitBasic _unit) { if (!unitList.Contains(_unit)) { unitList.Add(_unit); InvokeListEvent(addUnitEventListeners, _unit); } }
public UnitBasic GetRandomUnit() { UnitBasic instance = null; if (unitList.Count > 0) { int index = Random.Range(0, unitList.Count); instance = unitList[index]; } return(instance); }
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); } } }
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); } }