Example #1
0
    private void Start()
    {
        mapDataList = JsonUtility.FromJson <MapDataList>(textJSON.text);

        foreach (var map in mapDataList.List)
        {
            for (int i = 0; i < sprite.Length; i++)
            {
                for (int j = 0; j < maps.Count; j++)
                {
                    maps[i].GetComponent <SpriteRenderer>().sprite = sprite[i];

                    if (sprite[i].name == map.Id)
                    {
                        map.Texture = sprite[i];

                        Vector2 pos   = new Vector2(map.X, map.Y);
                        Vector2 scale = new Vector2(map.Width, map.Height);
                        maps[i].transform.localPosition = pos * 5.12f;
                        maps[i].transform.localScale    = scale;
                    }
                }
            }
        }
    }
Example #2
0
    public static MapDataList LoadMapDataJson(string name)
    {
        TextAsset   jsonText = GeneraMethod.LoadTextAsset(m_JsonPath + name);
        MapDataList jsonTemp = new MapDataList();

        jsonTemp = JsonUtility.FromJson <MapDataList>(jsonText.text);
        return(jsonTemp);
    }
Example #3
0
 public MapManager(GameObject gameObject)
 {
     this.gameObject = gameObject;
     allMaps         = new List <MapBase>();
     gridMap         = new GridMap();
     mapDataList     = MapMassageFromJson.LoadMapDataJson("MapData");
     GameManager.instance.rootMassageNode.AttachEventListener(MassageList.loadMap, this);
     gridParent = GameObject.Find("Grid");
 }
Example #4
0
        public void DataLoadProcess(string filePath)
        {
            MapDataList mapDataList = MapDataList.Instance;

            mapDataList.MapData.Nodes.Clear();
            mapDataList.MapData.Edges.Clear();
            MainViewModel.WorkSpaceVM.NodePixels.Clear();
            MainViewModel.WorkSpaceVM.EdgePixels.Clear();
            mapDataList.Load(filePath);

            if (mapDataList != null && mapDataList.MapData.Nodes != null && mapDataList.MapData.Edges != null)
            {
                foreach (Node nodeData in mapDataList.MapData.Nodes)
                {
                    NodeDotViewModel t = new NodeDotViewModel()
                    {
                        X      = nodeData.NOD_X,
                        Y      = nodeData.NOD_Y,
                        ID     = nodeData.NOD_ID,
                        Text   = nodeData.NOD_ID,
                        Margin = new Thickness(nodeData.NOD_X, nodeData.NOD_Y, 0, 0),
                        Floor  = nodeData.NOD_FLOOR,
                        IsUse  = nodeData.NOD_ISUSE == true ? "1" : "0",
                        Map    = nodeData.MAP_ID
                    };

                    if (nodeData.NOD_CATEGORY != null)
                    {
                        try
                        {
                            t.Type = (NodeType)Enum.Parse(typeof(NodeType), nodeData.NOD_CATEGORY, true);
                        }
                        catch
                        {
                            t.Type = NodeType.Normal;
                        }
                    }
                    else
                    {
                        t.Type = NodeType.Normal;
                    }


                    MainViewModel.WorkSpaceVM.NodePixels.Add(t);
                }

                foreach (Edge edgeData in mapDataList.MapData.Edges)
                {
                    MainViewModel.WorkSpaceVM.NodePixels.Where(x => x.ID == edgeData.EDG_NODE1).Single().ConnectedNodes.Add(MainViewModel.WorkSpaceVM.NodePixels.Where(y => y.ID == edgeData.EDG_NODE2).Single());
                }
            }
            else
            {
                MessageBox.Show("파일을 읽는중 오류가 발생하였습니다.");
            }
        }
Example #5
0
        public void ButtonDataLoadExecute()
        {
            string filePath = ShowDialog((int)FileType.json);

            if (filePath != string.Empty)
            {
                MapDataList mapDataList = MapDataList.Instance;
                if (mapDataList.MapData.Nodes.Count() != 0 || mapDataList.MapData.Edges.Count() != 0)
                {
                    if (MessageBox.Show("작업중인 데이터가 있습니다. 저장되지 않은 데이터는 유실 될 수 있습니다\r\n계속 진행하시겠습니까?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        DataLoadProcess(filePath);
                    }
                }
                else
                {
                    DataLoadProcess(filePath);
                }
            }
        }