// This method rotates the body parts correctly, but since we are using sprites // that occupy the whole "grid" and are square, we don't need this method. // If the sprites change to something non-rectangular, uncomment the switch - case portion public void SetSnakeMovPos(SnakeMovePos snakeMovePos) { this.snakeMovePos = snakeMovePos; transform.position = new Vector3(snakeMovePos.GetGridPos().x, snakeMovePos.GetGridPos().y); /* ----- UNCOMMENT IF THE SPRITE YOU USE IS NON-RECTANGULAR ----- * float angle; * switch (snakeMovePos.GetDir()) * { * default: * case Dir.Up: * switch (snakeMovePos.GetPrevDir()) * { * default: * angle = 0; break; * case Dir.Left: * angle = 45; break; * case Dir.Right: * angle = -45; break; * } * break; * case Dir.Down: * switch (snakeMovePos.GetPrevDir()) * { * default: * angle = 180; break; * case Dir.Down: * angle = 180 + 45; break; * case Dir.Up: * angle = 180 - 45; break; * } * break; * case Dir.Left: * switch (snakeMovePos.GetPrevDir()) * { * default: * angle = -90; break; * case Dir.Down: * angle = -45; break; * case Dir.Up: * angle = 45; break; * } * break; * case Dir.Right: * switch (snakeMovePos.GetPrevDir()) * { * default: * angle = 90; break; * case Dir.Down: * angle = 45; break; * case Dir.Up: * angle = -45; break; * } * break; * } * transform.eulerAngles = new Vector3(0, 0, angle); */ }
public Vector2Int GetGridPosInSnakeMove() { return(snakeMovePos.GetGridPos()); }