Esempio n. 1
0
 private void UpdateSnake(SnakeChangedEventArgs e)
 {
     if (!e.Killed)
     {
         var snakePart = e.SnakeUpdated;
         if (!_snakeBodies.ContainsKey(snakePart))
         {
             FrameworkElement snakeControl = CanvasHelper.SnakeControlFactory(snakePart,
                                                                              _scale);
             _snakeBodies[snakePart] = snakeControl;
             _sprites.Add(snakeControl);
         }
         else
         {
             FrameworkElement snakeControl = _snakeBodies[snakePart];
             CanvasHelper.ResizeElement(snakeControl, snakePart.Size.Width * _scale, snakePart.Size.Height * _scale);
             CanvasHelper.MoveElementOnCanvas(snakeControl, snakePart.Location.X * _scale, snakePart.Location.Y * _scale);
         }
     }
 }
Esempio n. 2
0
 private void _model_SnakeChanged(object sender, SnakeChangedEventArgs e)
 {
     UpdateSnakeAction?.Invoke(e);
 }