Example #1
0
        private bool RenderHeadAt(GameGrid.Cell cell)
        {
            var head     = BodyPart.CreateHead(this, cell);
            var rendered = head.Render();

            if (rendered)
            {
                this.head = head;
            }
            return(rendered);
        }
Example #2
0
        private bool RenderBodyBlockAt(GameGrid.Cell cell)
        {
            var bodyBlock = BodyPart.CreateBodyBlock(this, cell);
            var rendered  = bodyBlock.Render();

            if (rendered)
            {
                bodyBlocks.Add(bodyBlock);
            }
            return(rendered);
        }
Example #3
0
 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;
 }
Example #4
0
 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;
 }
Example #5
0
        public bool IsFood(GameGrid.Cell cell)
        {
            if (!spawnedFood.ContainsKey(cell))
            {
                return(false);
            }
            var food = spawnedFood[cell];

            spawnedFood.Remove(food.Cell);
            food.Remove();
            return(true);
        }
Example #6
0
        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);
        }
Example #7
0
 public static BodyPart CreateBodyBlock(Snake snake, GameGrid.Cell gridCell)
 {
     return(new BodyPart(snake, bodyBlockColor, bodyBlockBorderColor, gridCell));
 }
Example #8
0
 public static BodyPart CreateHead(Snake snake, GameGrid.Cell gridCell)
 {
     return(new BodyPart(snake, headColor, headBorderColor, gridCell));
 }