public void TestNext() { var pool = new IDPool(10, 10, 1); Assert.Equal(10, pool.Next()); Assert.Equal(11, pool.Next()); Assert.Equal(12, pool.Next()); Assert.Equal(13, pool.Next()); }
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()); }
public Food Create(Vector2 pos) { var id = foodIDPool.Next(); var food = new Food(id, pos); foods.Add(food); return(food); }
Session CreateSession(ITransport <string> transport) { // 플레이어에게는 고유번호 붙인다 // 어떤 방에 들어가든 id는 유지된다 var sessionID = sessionIDPool.Next(); var session = new Session(sessionID, transport); // register Debug.Assert(sessionIDSessionTable.ContainsKey(sessionID) == false); Debug.Assert(transportIDSessionIDTable.ContainsKey(transport.ID) == false); sessionIDSessionTable[sessionID] = session; transportIDSessionIDTable[transport.ID] = sessionID; return(session); }
public Projectile Create(Player player) { log.Info($"projectile create"); var pos = player.Position; var dir = player.Direction; var id = projectileIDPool.Next(); var ownerID = player.ID; var projectile = new Projectile(id, ownerID, pos, dir); projectiles.Add(projectile); RefreshGrid(); return(projectile); }