public static Map2D Load(string fileName) { TextAsset asset = Resources.Load("Maps/" + fileName) as TextAsset; Stream s = new MemoryStream(asset.bytes); BinaryFormatter bf = new BinaryFormatter(); Map2D m = (Map2D)bf.Deserialize(s); m.UpdateCategories(); // Debug.Log(m.sizeX); return(m); }
public void Initialize() { // Test(); map = Map2D.Load(sz.mapName); dMap.Initialize(map, 30, 20, 1, 1); GameObject ec = GameObject.Find("EffectsCamera"); if (ec != null) { crtScreen = ec.GetComponent <CRTScreen>(); crtScreen.settings = SerializedScenes.szScenes.getCRTSettings(sz.crtSettings_id); } }
public void Initialize(Map2D m, int x, int y, float sx, float sy) { map = m; sizeX = x; sizeY = y; dx = sx; dy = sy; parent = new GameObject("Map"); mapItems = new DisplayMapCompositeItem[sizeX, sizeY]; for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { mapItems[i, j] = Initialize(i, j); } } }
public void CreateNew() { SerializedGameLevel gl = new SerializedGameLevel(); gl.crtSettings_id = "crt"; gl.mapName = GameObject.Find("inpMapName").GetComponent <InputField>().text; gl.name = GameObject.Find("inpNewName").GetComponent <InputField>().text; Map2D map = new Map2D(); int x = int.Parse(GameObject.Find("inpX").GetComponent <InputField>().text); int y = int.Parse(GameObject.Find("inpY").GetComponent <InputField>().text); map.Create(x, y); Map2D.Save(map, gl.mapName); SerializedGameLevels.gameLevels.levels.Add(gl); SaveAll(); currentLevel.Destroy(); currentLevel = SerializedGameLevels.getLevel(gl.name); }
private void Test() { map = new Map2D(); map.Create(32, 20); Map2D.Save(map, "test_map1"); }