예제 #1
0
        public void TestRelease()
        {
            var pool = new IDPool(10, 10, 1);

            Assert.Equal(10, pool.Next());
            Assert.Equal(11, pool.Next());

            pool.Release(10);
            pool.Release(11);

            Assert.Equal(11, pool.Next());
            Assert.Equal(10, pool.Next());
        }
예제 #2
0
 void RemoveSession(Session s)
 {
     Debug.Assert(sessionIDSessionTable.ContainsKey(s.ID) == true);
     Debug.Assert(transportIDSessionIDTable.ContainsKey(s.TransportID) == true);
     sessionIDPool.Release(s.ID);
     sessionIDSessionTable.Remove(s.ID);
     transportIDSessionIDTable.Remove(s.TransportID);
 }
예제 #3
0
        public void Update(float dt)
        {
            foreach (var p in projectiles)
            {
                p.Update(dt);
            }
            RefreshGrid();

            var deadList = projectiles
                           .Select((p, idx) => new { projectile = p, idx = idx })
                           .Where(pair => pair.projectile.Alive == false)
                           .OrderByDescending(pair => pair.idx);

            foreach (var pair in deadList)
            {
                projectiles.RemoveAt(pair.idx);
                projectileIDPool.Release(pair.projectile.ID);
            }
            if (deadList.Count() > 0)
            {
                RefreshGrid();
            }
        }
예제 #4
0
        public void Remove(IEnumerable <int> ids)
        {
            if (ids.Count() < 0)
            {
                return;
            }

            var removeFoods = from food in foods
                              where ids.Contains(food.ID)
                              select food;

            foreach (var food in removeFoods)
            {
                foodIDPool.Release(food.ID);
                BroadcastFoodRemove(food);
            }

            var existFoods = from food in foods
                             where ids.Contains(food.ID) == false
                             select food;

            foods = existFoods.ToList();
            RefreshGrid();
        }