public PlayerUnit FindGroupMainUnitByGroupId(string groupId) { PlayerUnit unit; try { unit = GameUnits.Find(delegate(PlayerUnit p) { return(p.Info.GroupId == groupId && p.Info.IsGroupMainUnit); }); } catch (Exception) { return(null); } return(unit); }
public PlayerUnit FindUnitById(string id) { //~ if(_GameUnits == null) //~ { //~ _GameUnits = new List<PlayerUnit>(); //~ return null; //~ } PlayerUnit unit = null; try { unit = GameUnits.Find(delegate(PlayerUnit p) { return(p.Info.Id == id); }); } catch (NullReferenceException ex) { Debug.Log("Cannot find unit in UnitManager.FindUnitById. Error: " + ex.Message); return(null); } return(unit); }