diff --git a/interface/Assets/Scripts/MapManager.cs b/interface/Assets/Scripts/MapManager.cs index d6d46b5..7c8d4db 100644 --- a/interface/Assets/Scripts/MapManager.cs +++ b/interface/Assets/Scripts/MapManager.cs @@ -8,6 +8,14 @@ public class MapManager : MonoBehaviour // Start is called before the first frame update private bool mapFinished; private MessageOfMap map; + private int rowCount = 50; + private int colCount = 50; + + public GameObject wall; + public GameObject grass; + public GameObject land; + public GameObject door; + public GameObject window; void Start() { mapFinished = false; @@ -19,8 +27,46 @@ public class MapManager : MonoBehaviour if (!mapFinished && MessageReceiver.map != null) { map = MessageReceiver.map; + Debug.Log("valid map"); //Debug.Log("valid map"); mapFinished = true; + ShowMap(map); + } + } + + private void ShowMap(MessageOfMap map) + { + var position = new Vector3(-24.5f, 12.25f, 12.25f); + var block = new GameObject(); + for (int i = 0; i < rowCount; i++) + { + for (int j = 0; j < colCount; j++) + { + position.x = position.x + 1; + block = ShowBlock(map.Row[i].Col[j]); + if (block != null) + { + Instantiate(block, position, new Quaternion(0, 0, 0, 0)); + } + } + position.x = -24.5f; + position.z=position.y = position.y - 0.5f; + } + + } + + private GameObject ShowBlock(PlaceType obj) + { + switch(obj) + { + case PlaceType.Land:return land; + case PlaceType.Grass:return grass; + case PlaceType.Wall:return wall; + case PlaceType.Door3: return door; + case PlaceType.Door5: return door; + case PlaceType.Door6: return door; + case PlaceType.Window: return window; + default:return null; } } } diff --git a/interface/Assets/Scripts/MessageReceiver.cs b/interface/Assets/Scripts/MessageReceiver.cs index daf7ac2..d4caffc 100644 --- a/interface/Assets/Scripts/MessageReceiver.cs +++ b/interface/Assets/Scripts/MessageReceiver.cs @@ -5,7 +5,7 @@ using Grpc.Core; using Google.Protobuf; using Protobuf; using System.Data; -using UnityEditor.U2D.Path; +//using UnityEditor.U2D.Path; public class MessageReceiver : MonoBehaviour { @@ -27,6 +27,7 @@ public class MessageReceiver : MonoBehaviour if (isMap) { map = responseVal.ObjMessage[0].MapMessage; + //Debug.Log(map.ToString()); isMap = false; } }