public static void saveTable(BoardConnectivityJson board) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/board.fun"; FileStream stream = new FileStream(path, FileMode.Create); formatter.Serialize(stream, board); stream.Close(); }
// Update is called once per frame void Update() { Text txt = FindTextFiel.find(); BoardConnectivityJson board = ReceiveBoardScript.ReceivedBoard; if (done == false) { if (ReceiveBoardScript.ReceivedBoard.board[0] != null) { string str = ""; str = board.board[nr].number.ToString(); text.text = str; string resource = board.board[nr].resource; txt.text = resource; Debug.Log(resource); switch (resource) { case "lumber": Instantiate(objForest, SpawnForestOre.position, SpawnForestOre.rotation); break; case "wool": Instantiate(objPasture, SpawnPasture.position, SpawnPasture.rotation); break; case "ore": Instantiate(objOre, SpawnForestOre.position, SpawnForestOre.rotation); break; case "grain": Instantiate(objGrain, SpawnPasture.position, SpawnPasture.rotation); break; case "desert": tataLaRobberi.SetActive(true); Instantiate(objDesert, SpawnDesertField.position, SpawnDesertField.rotation); Instantiate(robbler, robber.position, robber.rotation); tataLaRobberi.SetActive(false); break; case "brick": Instantiate(objBrick, SpawnHills.position, SpawnHills.rotation); break; } done = true; } // else // Debug.Log("Null"); } }
// Update is called once per frame void Update() { BoardConnectivityJson board = ReceiveBoardScript.ReceivedBoard; if (done == false) { if (ReceiveBoardScript.ReceivedBoard.board[0] != null) { done = true; string str = ""; str = board.board[nr].number.ToString(); text.text = str; string resource = board.board[nr].resource; Debug.Log(resource); switch (resource) { case "lumber": Instantiate(objForest, SpawnForestOre.position, SpawnForestOre.rotation); break; case "wool": Instantiate(objPasture, SpawnPasture.position, SpawnPasture.rotation); break; case "ore": Instantiate(objOre, SpawnForestOre.position, SpawnForestOre.rotation); break; case "grain": Instantiate(objGrain, SpawnPasture.position, SpawnPasture.rotation); break; case "desert": Instantiate(objDesert, SpawnDesertField.position, SpawnDesertField.rotation); break; case "brick": Instantiate(objBrick, SpawnHills.position, SpawnHills.rotation); break; } } else { Debug.Log("Null"); } } }
// Update is called once per frame void Update() { BoardConnectivityJson board = ReceiveBoardScript.ReceivedBoard; if (done == false) { if (ReceiveBoardScript.ReceivedBoard.board[0] != null) { done = true; string str = ""; str = board.ports[nr]; print(str); switch (str) { case "ThreeForOne": Instantiate(port1, Spawn.position, Spawn.rotation); break; case "Brick": Instantiate(port2, Spawn.position, Spawn.rotation); break; case "Ore": Instantiate(port3, Spawn.position, Spawn.rotation); break; case "Wool": Instantiate(port4, Spawn.position, Spawn.rotation); break; case "Lumber": Instantiate(port5, Spawn.position, Spawn.rotation); break; case "Grain": Instantiate(port6, Spawn.position, Spawn.rotation); break; } } // else // Debug.Log("Null"); } }
public static BoardConnectivityJson LoadTable() { string path = Application.persistentDataPath + "/board.fun"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); BoardConnectivityJson board = formatter.Deserialize(stream) as BoardConnectivityJson; stream.Close(); return(board); } else { Debug.Log("No file"); } return(null); }