public void AddPlayer(UserSession session) { lock (Players) { Players.Add(session.ConnectionId, session); var someFood = JsonConvert.SerializeObject(SomeFood); var data = Players.Select(t => new DataForInitialCreate() { PosX = t.Value.Monster.PosX, PosY = t.Value.Monster.PosY, SizeX = t.Value.Monster.SizeX, SizeY = t.Value.Monster.SizeY, Color = t.Value.Monster.Color }); var users = JsonConvert.SerializeObject(data); UserSession CurrentClient = session; ResultPosition newCoord = RandomExt.GetRandomPosition((int)SizeX, (int)SizeY, CurrentClient.Monster.SizeX, CurrentClient.Monster.SizeY); CurrentClient.Monster.PosX = newCoord.x; CurrentClient.Monster.PosY = newCoord.y; CurrentClient.Client.initialSettings(SizeX, SizeY, someFood); foreach (var item in Players) { item.Value.Client.addMoreMembers(SizeX, SizeY, users); } } }
public Monster() { PosX = 0; PosY = 0; PosZ = 0; SpeedX = 0; SpeedY = 0; SizeX = 10; SizeY = 20; Speed = 20; Color = RandomExt.GetRandomColor(0, 3); }
private void SetSomeFood() { for (var i = 0; i < CountOfFood; i++) { ResultPosition coord = RandomExt.GetRandomPosition((int)SizeX, (int)SizeY, Food.MaxSize, Food.MaxSize); SomeFood.Add(new Food() { Size = RandomExt.GetRandomSize(Food.MinSize, Food.MaxSize), Weight = RandomExt.GetRandomWeight(Food.MinWeight, Food.MaxWeight), PosX = coord.x, PosY = coord.y, Color = RandomExt.GetRandomColor(3, 7) }); } }