public void Bind(SnakePiece tail) { if (!HasTail) { Tail = tail; } else { Tail.Bind(tail); } }
public LevelContext(SnakePiece snakeHead, LevelSettings settings, Spawner<SnakePiece> tailSpawner, Direction initialDirection, Action restart, Action nextLevel, Predicate<Vector2> cellIsEmpty, int lives) { this.cellIsEmpty = cellIsEmpty; this.settings = settings; this.nextLevel = nextLevel; this.tailSpawner = tailSpawner; this.snakeHead = snakeHead; this.restart = restart; Direction = initialDirection; Lives = lives; }
private void CheckBodyCollision(SnakePiece piece, LevelContext context, Point locationToTest) { if (piece != null) { if (locationToTest == piece.location) { if (piece.hasMoved) { context.AddState(new DeathState()); } } CheckBodyCollision(piece.Tail,context, locationToTest); } }