@@ -66,13 +66,11 @@ public class BoardManager : MonoBehaviour, IInitializable
6666
6767 private static Transform boardHolder ;
6868
69- [ Inject ]
70- BoardTranslator translator ;
71-
7269 [ Inject ]
7370 Installer . Settings . MapSettings mapDimensions ;
7471
7572 public static HashSet < Coordinate > roadCoordinates = new HashSet < Coordinate > ( ) ;
73+ private const float BackgroundLeftBoundaryPadding = - 0.5f ;
7674
7775 [ PostInject ]
7876 public void Initialize ( ) {
@@ -102,16 +100,18 @@ private void SetupLevel(int levelNumber)
102100
103101 private void SetupBoard ( )
104102 {
103+ GameObject backgroundTileParent = new GameObject ( "BackgroundTiles" ) ;
105104 for ( int x = 0 ; x < columns ; x ++ )
106105 {
107106 for ( int y = 0 ; y < rows ; y ++ )
108107 {
109- SetStaticWithBoardAsParent (
110- Instantiate ( floorTiles . grassTile ,
111- new Vector3 ( translator . translateToSceneRow ( x , true ) , translator . translateToSceneColumn ( y , true ) , 0f ) ,
112- Quaternion . identity ) as GameObject ) ;
108+ GameObject tile = Instantiate ( floorTiles . grassTile , new Vector3 ( x , y , 0f ) , Quaternion . identity ) as GameObject ;
109+ SetStatic ( tile ) ;
110+ tile . transform . SetParent ( backgroundTileParent . transform ) ;
113111 }
114112 }
113+ backgroundTileParent . transform . position = new Vector3 ( BackgroundLeftBoundaryPadding , 0f , 0f ) ;
114+ SetBoardAsParent ( backgroundTileParent ) ;
115115 }
116116
117117 private void SetupRoute ( )
@@ -120,7 +120,7 @@ private void SetupRoute()
120120 RoadSegment [ ] roadSegments = roadBuilder . CreateRoadSegments ( currentLevel . path ) ;
121121 GameObject [ ] roadObjects = roadDrawer . DrawRoad ( roadSegments ) ;
122122 foreach ( GameObject roadObject in roadObjects ) {
123- Coordinate currCoord = new Coordinate ( roadObject . transform . position ) ;
123+ Coordinate currCoord = new Coordinate ( roadObject . transform . localPosition ) ;
124124 roadCoordinates . Add ( currCoord ) ;
125125 }
126126
@@ -138,7 +138,7 @@ private GameObject SetupOrigin(OriginNode origin)
138138 {
139139 Direction direction = RoadDrawer . StringToDirection ( origin . direction ) ;
140140 Coordinate coords = origin . coords ;
141- return Instantiate ( roadTiles . cfcTile , new Vector3 ( translator . translateToSceneRow ( coords . x ) , translator . translateToSceneColumn ( coords . y ) , 0f ) ,
141+ return Instantiate ( roadTiles . cfcTile , new Vector3 ( coords . x , coords . y , 0f ) ,
142142 Quaternion . Euler ( 0 , 0 , ( float ) direction ) ) as GameObject ;
143143 }
144144
@@ -157,29 +157,32 @@ private void SetupDecorations() {
157157 private void SetupVan ( )
158158 {
159159 GameObject van = GameObject . Find ( "Van" ) ;
160- van . transform . position = translator . translateToSceneVector ( currentLevel . origin . coords . vector ) ;
160+ van . transform . localPosition = currentLevel . origin . coords . vector ;
161161 int direction = ( int ) RoadDrawer . StringToDirection ( currentLevel . origin . direction ) ;
162162
163163 van . transform . rotation = Quaternion . identity ;
164164 van . transform . Rotate ( new Vector3 ( 0 , 0 , direction ) ) ;
165165 van . transform . localScale = new Vector3 ( 0.5f , 0.5f , 0.5f ) ;
166- van . transform . position += VehicleMover . ForwardABit ( van . transform , 0.5f ) ;
166+ van . transform . localPosition += VehicleMover . ForwardABit ( van . transform , 0.5f ) ;
167167 DOTween . defaultEaseOvershootOrAmplitude = 0 ;
168168 van . GetComponent < SpriteRenderer > ( ) . color = Color . white ;
169169
170170 BoardManager . SetBoardAsParent ( van ) ;
171171 }
172172
173- private static void SetStaticWithBoardAsParent ( GameObject childObject ) {
173+ private static void SetStaticWithBoardAsParent ( GameObject childObject )
174+ {
174175 SetStatic ( childObject ) ;
175176 SetBoardAsParent ( childObject ) ;
176177 }
177178
178- private static void SetStatic ( GameObject staticObject ) {
179+ private static void SetStatic ( GameObject staticObject )
180+ {
179181 staticObject . isStatic = true ;
180182 }
181183
182- public static void SetBoardAsParent ( GameObject childObject ) {
184+ public static void SetBoardAsParent ( GameObject childObject )
185+ {
183186 childObject . transform . SetParent ( boardHolder ) ;
184187 }
185188}
0 commit comments