private bool RenderHeadAt(GameGrid.Cell cell) { var head = BodyPart.CreateHead(this, cell); var rendered = head.Render(); if (rendered) { this.head = head; } return(rendered); }
private bool RenderBodyBlockAt(GameGrid.Cell cell) { var bodyBlock = BodyPart.CreateBodyBlock(this, cell); var rendered = bodyBlock.Render(); if (rendered) { bodyBlocks.Add(bodyBlock); } return(rendered); }
private BodyPart(Snake snake, Brush color, Brush borderColor, GameGrid.Cell gridCell) { Shape = new Rectangle() { Height = snake.partSize, Width = snake.partSize, Fill = color, Stroke = borderColor }; Cell = gridCell; this.snake = snake; }
public Food(FoodSpawner spawner, GameGrid.Cell gridCell) { Shape = new Ellipse() { Height = spawner.foodSize, Width = spawner.foodSize, Fill = Brushes.Crimson, Stroke = Brushes.PeachPuff }; Cell = gridCell; this.spawner = spawner; }
public bool IsFood(GameGrid.Cell cell) { if (!spawnedFood.ContainsKey(cell)) { return(false); } var food = spawnedFood[cell]; spawnedFood.Remove(food.Cell); food.Remove(); return(true); }
public void SpawnFood() { if (spawnedFood.Count >= simultaneousFood) { return; } GameGrid.Cell spawnPoint = gameGrid.ClaimRandomCell(); if (spawnPoint == GameGrid.TheVoid) { return; } var food = new Food(this, spawnPoint); food.Render(); spawnedFood.Add(food.Cell, food); }
public static BodyPart CreateBodyBlock(Snake snake, GameGrid.Cell gridCell) { return(new BodyPart(snake, bodyBlockColor, bodyBlockBorderColor, gridCell)); }
public static BodyPart CreateHead(Snake snake, GameGrid.Cell gridCell) { return(new BodyPart(snake, headColor, headBorderColor, gridCell)); }