示例#1
0
        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());
        }
示例#2
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());
        }
示例#3
0
        public Food Create(Vector2 pos)
        {
            var id   = foodIDPool.Next();
            var food = new Food(id, pos);

            foods.Add(food);
            return(food);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }