mirror of
https://github.com/DerTyp7/traffic-unity.git
synced 2025-10-30 13:17:08 +01:00
dfg
This commit is contained in:
@@ -13,12 +13,10 @@ public class NodePlacer : MonoBehaviour
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
Debug.Log("H2213123IT");
|
||||
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
||||
|
||||
if (hit.collider != null)
|
||||
{
|
||||
Debug.Log("HIT");
|
||||
selectedPlacedNode = hit.collider.transform.gameObject.GetComponent<TrafficNode>();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3,14 +3,15 @@ using UnityEngine;
|
||||
public class StreetBuilding : MonoBehaviour
|
||||
{
|
||||
|
||||
GameObject currentStreetPO;
|
||||
GameObject currentStreetPSO;
|
||||
Vector3 startPosition;
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.H))
|
||||
{
|
||||
if (currentStreetPO == null)
|
||||
if (currentStreetPSO == null)
|
||||
{
|
||||
StartBuilding();
|
||||
}
|
||||
@@ -20,36 +21,41 @@ public class StreetBuilding : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
if (currentStreetPO != null && Input.GetKeyDown(KeyCode.J))
|
||||
if (currentStreetPSO != null)
|
||||
{
|
||||
if (currentStreetPO.GetComponent<PlaceableObject>().placeable)
|
||||
if (Input.GetKeyDown(KeyCode.J))
|
||||
{
|
||||
PlaceBuilding();
|
||||
if (currentStreetPSO.GetComponent<PlaceableStreetObject>().placeable)
|
||||
{
|
||||
PlaceBuilding();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void StartBuilding()
|
||||
{
|
||||
startPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
startPosition.z = 0;
|
||||
|
||||
currentStreetPO = Instantiate(PrefabDictionary.instance.oneWayStreetPO, startPosition, Quaternion.identity);
|
||||
currentStreetPSO = Instantiate(PrefabDictionary.instance.oneWayStreetPSO, startPosition, Quaternion.identity);
|
||||
}
|
||||
|
||||
private void StopBuilding()
|
||||
{
|
||||
Destroy(currentStreetPO);
|
||||
currentStreetPO = null;
|
||||
Destroy(currentStreetPSO);
|
||||
currentStreetPSO = null;
|
||||
startPosition = Vector3.zero;
|
||||
}
|
||||
|
||||
private void PlaceBuilding()
|
||||
{
|
||||
Transform placedTransform = currentStreetPO.transform;
|
||||
Transform placedTransform = currentStreetPSO.transform;
|
||||
|
||||
Instantiate(PrefabDictionary.instance.oneWayStreet, placedTransform.position, placedTransform.rotation).transform.localScale = placedTransform.localScale;
|
||||
GameObject newStreet = Instantiate(PrefabDictionary.instance.oneWayStreet, placedTransform.position, placedTransform.rotation);
|
||||
newStreet.transform.localScale = placedTransform.localScale;
|
||||
newStreet.GetComponent<StreetContainer>().Place();
|
||||
|
||||
StopBuilding();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user