public static TorpedoView GetInstance(Ammunition torpedo, LevelView levelViewRef) { TorpedoView rv = torpedoAvailablePool.Pop(); rv.ammunition = torpedo; rv.postInitOnScene(); rv.levelViewRef = levelViewRef; torpedoUsedPool.Add(torpedo, rv); return(rv); }
public static void InitPool(int poolSize, IFrameWork framework) { torpedoAvailablePool = new Stack <TorpedoView>(poolSize); torpedoUsedPool = new Dictionary <Ammunition, TorpedoView>(poolSize); for (int i = 0; i < poolSize; i++) { TorpedoView dummyView = new TorpedoView(framework); torpedoAvailablePool.Push(dummyView); } }
public static void FreeInstance(Ammunition torpedo) { try { TorpedoView rv = torpedoUsedPool[torpedo]; torpedoUsedPool.Remove(torpedo); torpedoAvailablePool.Push(rv); } catch (Exception) { throw; } }