Пример #1
0
 public void Bind(SnakePiece tail)
 {
     if (!HasTail)
     {
         Tail = tail;
     }
     else
     {
         Tail.Bind(tail);
     }
 }
Пример #2
0
 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;
 }
Пример #3
0
 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);
     }
 }