Example #1
0
 private int removeTail(SerpentTailSegment tail)
 {
     _pendingEatenSegments = SegmentEatTreshold - 1;
     if (tail != _tail && tail != null)
     {
         var length = 1;
         for (var test = _tail; test != null; test = test.Next, length++)
             if (test.Next == tail)
             {
                 test.Next = null;
                 var removedSegments = _serpentLength - length;
                 _serpentLength = length;
                 return removedSegments;
             }
     }
     throw new Exception("No tail to remove");
 }
Example #2
0
 public void Restart(PlayingField playingField, Whereabouts whereabouts)
 {
     PlayingField = playingField;
     _whereabouts = whereabouts;
     HeadDirection = _whereabouts.Direction;
     _tail = new SerpentTailSegment(PlayingField, _whereabouts);
     _serpentLength = 1;
     _ascendToHeaven = 0;
     _layingEgg = -1;
     _pendingEatenSegments = 6;
 }