public void MoveSnake(Move move) { SnakeIsOnEndCube = move.ToMapCube.IsEnd; Apple theApple = Game._.LevelController.MapMaker.Apples .FirstOrDefault(a => a.Pos.x == move.ToMapCube.Pos.x && a.Pos.y == move.ToMapCube.Pos.y); MoveCopy moveCopy = MoveBodyPart(move, SnakeHead); Game._.EnergyController.UseEnergy(); foreach (var bodyPart in BodyParts) { if (moveCopy != null) { if (bodyPart.gameObject.activeSelf == false) { bodyPart.gameObject.SetActive(true); } moveCopy = CopyMove(moveCopy, bodyPart); } } if (theApple != null) { theApple.Consume(); Game._.EnergyController.ConsumeApple(); AddBodyPart(); if (SnakeHeadIndex > 1) { if (BodyParts[BodyParts.Count - 1].gameObject.activeSelf == false) { BodyParts[BodyParts.Count - 1].gameObject.SetActive(true); } moveCopy = CopyMove(moveCopy, BodyParts[BodyParts.Count - 1], isAddingNewBodyPart: true); } } bool canWeSeeTail = !(SnakeHeadIndex == 0); if (canWeSeeTail == false) { return; } if (moveCopy != null) { if (SnakeTail.gameObject.activeSelf == false) { SnakeTail.gameObject.SetActive(true); } if (_newBodyPartEntries != null) { _newBodyPartEntries.RemoveAt(_newBodyPartEntries.Count - 1); if (_newBodyPartEntries.Count == 0) { _newBodyPartEntries = null; } return; } CopyMove(moveCopy, SnakeTail); } }