Exemple #1
0
        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);
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 public static void FreeInstance(Ammunition torpedo)
 {
     try
     {
         TorpedoView rv = torpedoUsedPool[torpedo];
         torpedoUsedPool.Remove(torpedo);
         torpedoAvailablePool.Push(rv);
     }
     catch (Exception)
     {
         throw;
     }
 }