Esempio n. 1
0
        public static void InitPool(int poolSize, IFrameWork framework)
        {
            soldierAvailablePool = new Stack <SoldierView>(poolSize);
            soldierUsedPool      = new Dictionary <Soldier, SoldierView>(poolSize);

            for (int i = 0; i < poolSize; i++)
            {
                SoldierView dummyView = new SoldierView(framework);
                soldierAvailablePool.Push(dummyView);
            }
        }
Esempio n. 2
0
        public static SoldierView GetInstance(Soldier soldier)
        {
            if (soldierAvailablePool.Count == 0)
            {
                return(null);
            }
            SoldierView sv = soldierAvailablePool.Pop();

            sv.soldier = soldier;
            sv.postInitOnScene();
            soldierUsedPool.Add(soldier, sv);
            return(sv);
        }
Esempio n. 3
0
        public static void FreeInstance(Soldier soldier, bool hide)
        {
            SoldierView sv = soldierUsedPool[soldier];

            sv.soldierNode.SetVisible(!hide);

            sv.StopBlood();

            if (EngineConfig.DisplayingMinimap)
            {
                if (sv.minimapItem != null)
                {
                    sv.minimapItem.Hide();
                }
            }

            soldierUsedPool.Remove(soldier);
            soldierAvailablePool.Push(sv);
        }