|
@@ -5,9 +5,9 @@ using UnityEngine;
|
|
|
|
|
|
public class Room : MonoBehaviour
|
|
|
{
|
|
|
- public float Height = 1f;
|
|
|
+ public float Height = 0.5f;
|
|
|
public int Rounding = 1;
|
|
|
- public bool move = false;
|
|
|
+ public bool move = true;
|
|
|
public bool BoxColliderEnabled = true;
|
|
|
//GameObject cursor_end;
|
|
|
|
|
@@ -15,6 +15,7 @@ public class Room : MonoBehaviour
|
|
|
private Vector3 offset;
|
|
|
private Vector3 curScreenPoint;
|
|
|
private Vector3 curPosition;
|
|
|
+ private Vector3 start_pos = Vector3.zero;
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
void Start()
|
|
@@ -27,6 +28,7 @@ public class Room : MonoBehaviour
|
|
|
void Update()
|
|
|
{
|
|
|
if (gameObject.GetComponent<BoxCollider>().enabled != BoxColliderEnabled) gameObject.GetComponent<BoxCollider>().enabled = BoxColliderEnabled;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void OnMouseDown()
|
|
@@ -44,10 +46,29 @@ public class Room : MonoBehaviour
|
|
|
curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
|
|
|
curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
|
|
|
var x = (float)Math.Round(curPosition.x, Rounding);
|
|
|
- var z = (float)Math.Round(curPosition.z, Rounding);
|
|
|
- //transform.position = new Vector3(x, Height, z);
|
|
|
- gameObject.GetComponent<BoxCollider>().size = new Vector3(x, Height, z);
|
|
|
+ var z = (float)Math.Round(curPosition.z, Rounding);
|
|
|
+ var boxCollider = gameObject.GetComponent<BoxCollider>();
|
|
|
+ if (!move)
|
|
|
+ {
|
|
|
+
|
|
|
+ //transform.position = new Vector3(x, Height, z);
|
|
|
+
|
|
|
+ boxCollider.size = new Vector3(x, Height, z);
|
|
|
+
|
|
|
+ LocationController.Cube(gameObject, new Vector3(x, z, Height), new Vector2(start_pos.x, start_pos.z));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ start_pos = new Vector3(x, Height, z);
|
|
|
+ transform.position = start_pos;
|
|
|
+ var size = boxCollider.size;
|
|
|
+ start_pos = new Vector3(x - size.x/2, Height, z - size.z / 2);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- LocationController.Cube(gameObject, new Vector3(x, z, Height));
|
|
|
+ private void OnMouseUp()
|
|
|
+ {
|
|
|
+ if (move) move = false;
|
|
|
}
|
|
|
}
|