private static void SetupClients(World world, List <Client> clients, Stopwatch t) { for (int x = (int)(world.Area.Min.X + (world.TileDimensions.X / 2)); x < world.Area.Max.X; x += (int)world.TileDimensions.X) { for (int y = (int)(world.Area.Min.Y + (world.TileDimensions.Y / 2)); y < world.Area.Max.Y; y += (int)world.TileDimensions.Y) { string name = string.Format("MyUsername{0}/{1}", x, y); var client = new Client(name, new Vector(x / 100f, y / 100f)); client.BeginConnect(); clients.Add(client); clientCount++; } for (int y = (int)(world.Area.Min.Y + (world.TileDimensions.Y / 2)) + 1; y < world.Area.Max.Y; y += (int)world.TileDimensions.Y) { string name = string.Format("MyUsername{0}/{1}", x + 1, y); var client = new Client(name, new Vector((x + 1) / 100f, y / 100f)); client.BeginConnect(); clients.Add(client); clientCount++; } } clients.ForEach(c => Assert.IsTrue(c.EndConnect())); log.InfoFormat("connect completed, {0} clients", clientCount); clients.ForEach(c => EnterWorldBegin(c, world)); clients.ForEach(EnterWorldEnd); clients.ForEach(c => BeginReceiveEvent(c, EventCode.ItemSubscribed, d => (string)d[(byte)ParameterCode.ItemId] != c.Username, 500)); clients.ForEach(c => EndReceiveEvent(c, EventCode.ItemSubscribed)); PrintStats(t); Client.ResetStats(); Assert.AreEqual(0, Client.Exceptions, "Exceptions occured at start"); log.Info("enter completed"); }
/// <summary> /// The setup clients. /// </summary> /// <param name = "world"> /// The world. /// </param> /// <param name = "clients"> /// The clients. /// </param> /// <param name = "t"> /// The stopwatch. /// </param> private static void SetupClients(MmoWorld world, List<Client> clients, Stopwatch t) { for (int x = world.Area.Min.X + (world.TileDimensions.X / 2); x < world.Area.Max.X; x += world.TileDimensions.X) { for (int y = world.Area.Min.Y + (world.TileDimensions.Y / 2); y < world.Area.Max.Y; y += world.TileDimensions.Y) { string name = string.Format("MyUsername{0}/{1}", x, y); var client = new Client(name, new[] { x / 100f, y / 100f }); client.BeginConnect(); clients.Add(client); clientCount++; } for (int y = world.Area.Min.Y + (world.TileDimensions.Y / 2) + 1; y < world.Area.Max.Y; y += world.TileDimensions.Y) { string name = string.Format("MyUsername{0}/{1}", x + 1, y); var client = new Client(name, new[] { (x + 1) / 100f, y / 100f }); client.BeginConnect(); clients.Add(client); clientCount++; } } clients.ForEach(c => Assert.IsTrue(c.EndConnect())); log.InfoFormat("connect completed, {0} clients", clientCount); clients.ForEach(c => EnterWorldBegin(c, world)); clients.ForEach(EnterWorldEnd); clients.ForEach(c => BeginReceiveEvent(c, EventCode.ItemSubscribed, d => (string)d[(byte)ParameterCode.ItemId] != c.Username, 500)); clients.ForEach(c => EndReceiveEvent(c, EventCode.ItemSubscribed)); PrintStats(t); Client.ResetStats(); Assert.AreEqual(0, Client.Exceptions, "Exceptions occured at start"); log.Info("enter completed"); }