Beispiel #1
0
 public bool IsFoodEaten(Snakee snake)
 {
     if (food.Posx == snake.GetBlock(0).Posx&& food.Posy == snake.GetBlock(0).Posy)
     {
         Points += 100;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #2
0
        public void addBlockUI(object sender, EventArgs e)
        {
            BlockUI blockUI = new BlockUI(snake.GetBlock(snake.NumOfBlocks - 1), snake.Multi);

            canvas.Children.Add(blockUI.Rect);
            blocksUI.Add(blockUI);
        }
Beispiel #3
0
        public SnakeUI(Canvas canvas, Snakee snake)
        {
            this.snake = snake;

            for (int i = 0; i < snake.NumOfBlocks; i++)
            {
                this.canvas = canvas;
                BlockUI blockUI = new BlockUI(snake.GetBlock(i), snake.Multi);
                canvas.Children.Add(blockUI.Rect);
                blocksUI.Add(blockUI);
                snake.BlockAdded += addBlockUI;
            }
        }
Beispiel #4
0
        public bool GameOver(Snakee snake, Snakee snakeM)
        {
            for (int i = 4; i < snake.NumOfBlocks - 1; i++)
            {
                Block tempBlock = snake.GetBlock(0);
                if (tempBlock.Posx == snake.GetBlock(i).Posx&& tempBlock.Posy == snake.GetBlock(i).Posy)

                {
                    return(true);
                }
            }

            for (int i = 0; i < snakeM.NumOfBlocks - 1; i++)
            {
                Block tempBlock = snake.GetBlock(0);
                if (tempBlock.Posx == snakeM.GetBlock(i).Posx&& tempBlock.Posy == snakeM.GetBlock(i).Posy)
                {
                    return(true);
                }
            }
            return(false);
        }