Пример #1
0
        public void Add(Snake snake, Canvas canvas)
        {
            Canvas = canvas;

            if (Snakes == null)
            {
                Snakes = new ConcurrentDictionary<string, Snake>();
                Timer = new Timer(onMove, null, 0, 1000/30);
                AddFood();
            }

            if (Snakes.ContainsKey(snake.id))
            {
                return;
            }

            Snakes.TryAdd(snake.id, snake);
            SendSnakes();
        }