public void CollisionEffect(SnakeBody sb) { if (sb.mySnake != this.mySnake) { this.mySnake.addScore(5); } sb.mySnake.isAlive = false; }
//Checks the snake head against the collision matrix to see if it is colliding with anything and then adds is public void SnakeHeadCollisions(SnakeBody snakeHead) { if (SnakeOutOfBounds(snakeHead)) { snakeHead.mySnake.isAlive = false; } else if (collidables[snakeHead.position.X, snakeHead.position.Y] != null) { collidables[snakeHead.position.X, snakeHead.position.Y].CollisionEffect(snakeHead); } }
//Checks that the snake is not out of bounds public bool SnakeOutOfBounds(SnakeBody snakeHead) { if (snakeHead.position.X < 0 || snakeHead.position.X >= XSize) { return(true); } if (snakeHead.position.Y < 0 || snakeHead.position.Y >= YSize) { return(true); } return(false); }
public override void CollisionEffect(SnakeBody sb) { base.CollisionEffect(sb); playField.GiveRandomSnakeSpeedUpEffect(); AmountOfSpeedyFood--; }
public override void CollisionEffect(SnakeBody sb) { base.CollisionEffect(sb); AmountOfStandardFood--; }
public override void CollisionEffect(SnakeBody sb) { base.CollisionEffect(sb); AmountOfValuableFood--; }
public void MoveTo(SnakeBody sb) { this.position = sb.position; }