public void AddUsedUnit(int key, IBattlePoolUnit unit) { if (!battlePools.ContainsKey(key)) { battlePools.Add(key, new BattlePool()); } battlePools[key].AddUsedUnit(unit); }
public void Recycle(IBattlePoolUnit unit) { if (usedUnits.Remove(unit)) { unusedUnits.Enqueue(unit); } else { DebugUtils.Assert(false, "Battle Pool: can't recycle a battle unit " + unit.ToString()); } }
public IBattlePoolUnit GetUnit() { if (unusedUnits.Count > 0) { IBattlePoolUnit unit = unusedUnits.Dequeue(); usedUnits.Add(unit); return(unit); } else { return(null); } }
public void AddUsedUnit(IBattlePoolUnit unit) { unit.pool = this; usedUnits.Add(unit); }