@@ -18,6 +18,7 @@ public class CameraScript : MonoBehaviour
1818 public bool canEdit = true ;
1919 public bool isOnTile = false ;
2020 public int playerNumber = 1 ;
21+
2122 void Start ( )
2223 {
2324 transform . position = new Vector3 ( 4.6f , 3.3f , - 5 ) ;
@@ -42,7 +43,6 @@ void Update()
4243
4344 GameObject target = gameControlScript . ClosestTile ( player ) ;
4445
45-
4646 if ( target == null ) return ;
4747 if ( ! target . name . Contains ( "Tile" ) ) return ;
4848
@@ -80,8 +80,6 @@ void Update()
8080
8181 ps . storage . Add ( childItemName ) ;
8282
83- Debug . Log ( itemPlate ) ;
84- Debug . Log ( "Added " + childItemName + "To Pluh" ) ;
8583 Destroy ( target . transform . GetChild ( 0 ) . gameObject ) ;
8684 return ;
8785 }
@@ -108,13 +106,8 @@ void Update()
108106 if ( item . name . Contains ( "Plate" ) )
109107 indexFood = item . name ;
110108
111- Debug . Log ( indexFood ) ;
112- Debug . Log ( item . name ) ;
113109 GameObject prefab = Resources . Load < GameObject > ( indexFood ) ;
114- if ( prefab == null )
115- {
116- Debug . LogError ( "This isnt working: " + indexFood + " " + item . name ) ;
117- }
110+
118111
119112 GameObject clone = Instantiate ( prefab , target . transform ) ;
120113 clone . name = item . name ;
@@ -128,7 +121,6 @@ void Update()
128121 Destroy ( item . gameObject ) ;
129122 invScript . equippedItem = invScript . inventory . Count == 0 ? 1 : Mathf . Clamp ( invScript . equippedItem , 1 , invScript . inventory . Count ) ;
130123 invScript . UpdatePlayerChildren ( ) ;
131- Debug . Log ( "Placed down " + clone . name ) ;
132124 return ;
133125 }
134126
@@ -168,7 +160,6 @@ void Update()
168160 if ( ps . foodCount ( "Bun" ) > 2 ) return ;
169161
170162 ps . storage . Add ( childItemName ) ;
171- Debug . Log ( "Added " + childItemName + "To Food" ) ;
172163 }
173164 /*
174165 if(itemPlate.name.Contains("Plate"))
@@ -182,46 +173,24 @@ void Update()
182173 }
183174 if ( keyboard . eKey . wasPressedThisFrame && target . transform . childCount == 0 && invScript . inventory . Count == 0 )
184175 {
185- Debug . Log ( "Tried calling" ) ;
186176 if ( tileScript . typeOfFood != "" )
187177 {
188- Debug . Log ( "Called food creation" ) ;
189178 invScript . AddItem ( tileScript . typeOfFood , null ) ;
190179 }
191180 return ;
192181 }
193- /*
194- if(keyboard.eKey.wasPressedThisFrame && target.transform.childCount > 0)
195- {
196- string childItemName = target.transform.GetChild(0).name;
197-
198- if(tileScript.typeOfTile == 2 && !childItemName.Contains("Chopped") && !childItemName.Contains("Plate"))
199- {
200- Debug.Log("USING CHOPPER");
201- tileScript.StartCooking(1);
202- //target.transform.GetChild(0).name = childItemName.Replace("(Clone)", "") + "Chopped";
203- }
204-
205- if(tileScript.typeOfTile == 3 && !childItemName.Contains("Cooked") && !childItemName.Contains("Plate"))
206- {
207- Debug.Log("Coming from camerascript: " + childItemName);
208- if(gameControlScript.canBeCooked(childItemName))
209- tileScript.StartCooking(5);
210- }
211-
212- if(tileScript.typeOfTile == 20 && childItemName.Contains("Plate"))
213- {
214- Debug.Log("This food is being checked");
215- gameControlScript.CheckFood(target.GetComponentInChildren<ItemScript>().storage);
216- Destroy(target.transform.GetChild(0).gameObject);
217- }
218-
219- return;
220- }
221- */
222182 }
223183
224-
225184 }
226-
185+ public GameObject Build ( GameObject parent , GameObject prefab , Vector3 position )
186+ {
187+ if ( parent . name . Contains ( "Tile" ) )
188+ parent . GetComponent < TileScript > ( ) . isFull = true ;
189+
190+ GameObject obj = Instantiate ( prefab , position , Quaternion . identity ) ;
191+ obj . transform . SetParent ( parent . transform , false ) ;
192+ obj . transform . localPosition = position ;
193+ obj . name = prefab . name ;
194+ return obj ;
195+ }
227196}
0 commit comments