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