Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
 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)
         });
     }
 }