Advertisement
jwow22

Clean - Slicing bodies

Jan 5th, 2022
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1.         // Collision with another snake
  2.         // Collision with body:
  3.         if (otherBody.linked && otherBody != otherBody.snake.head)
  4.         {
  5.             Snake otherSnake = otherBody.snake;
  6.             if (_snake.size > otherBody.snake.size)
  7.             {
  8.                 int index = otherSnake.bodyParts.IndexOf(otherBody);
  9.                 otherSnake.RemoveBodiesUntil(index);
  10.                 _spawner.DestroyObject(otherBody.gridObject);
  11.                 _snake.AddBody();  
  12.             }
  13.             else
  14.             {
  15.                 _spawner.DestroyObject(headBody.gridObject);
  16.                 _snake.DeathBehaviour();
  17.             }
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement