public void SetUp(Scripts.GameData gameData) { EnableDisableView(true); Rect rowRect = rowList.GetComponent <RectTransform>().rect; Rect colRect = columnList.GetComponent <RectTransform>().rect; float heightRow = rowRect.height / gameData.matrix.GetLength(0); float widthCol = colRect.width / gameData.matrix.GetLength(1); rowGrid.cellSize = new Vector2(rowRect.width, heightRow); colGrid.cellSize = new Vector2(widthCol, colRect.height); InputField inputField; for (int i = 0; i < gameData.matrix.GetLength(0); i++) { inputField = Instantiate(valFieldPrefab, rowList).GetComponent <InputField>(); inputField.text = "0"; } for (int i = 0; i < gameData.matrix.GetLength(1); i++) { inputField = Instantiate(valFieldPrefab, columnList).GetComponent <InputField>(); inputField.text = "0"; } }
public void btn_LoadGame(string xmlFileName) { LogsManager.ins.ClearLogs(); LogsManager.ins.AddLog("Gra została załadowana."); Scripts.GameData gD = XMLManager.ins.LoadData2(xmlFileName); gameAnalysis = new GameAnalysis(gD); }
public void btn_LoadGame(ScriptableGameData gameData) { LogsManager.ins.ClearLogs(); LogsManager.ins.AddLog("Gra została załadowana."); Scripts.GameData gD = new Scripts.GameData(gameData); gameAnalysis = new GameAnalysis(gD); }
private void InsertValues(Scripts.GameData gD) { GameObject newGO; for (int i = 0; i < gD.matrix.GetLength(0); i++) { newGO = Instantiate(fieldStrategyPrefab, rowPlayerStrategies); newGO.GetComponent <InputField>().text = gD.rowStrategies[i].ToString(); } for (int i = 0; i < gD.matrix.GetLength(1); i++) { newGO = Instantiate(fieldStrategyPrefab, columnPlayerStrategies); newGO.GetComponent <InputField>().text = gD.colStrategies[i].ToString(); } int id = 0; for (int i = 0; i < gD.matrix.GetLength(0); i++) { for (int j = 0; j < gD.matrix.GetLength(1); j++) { newGO = Instantiate(fieldValuePrefab, mainTable); newGO.name = "Value_" + id++; if (gD.matrix.GetLength(0) > i && gD.matrix.GetLength(1) > j) { newGO.GetComponent <InputField>().text = gD.matrix[i, j].ToString(); } } } }
public void SetUp(Scripts.GameData gD) { minsList.parent.gameObject.SetActive(true); maxsList.parent.gameObject.SetActive(true); byte rows = (byte)gD.matrix.GetLength(0); byte cols = (byte)gD.matrix.GetLength(1); float heighRow = minsList.GetComponent <RectTransform>().rect.height / rows; float widthCol = maxGrid.GetComponent <RectTransform>().rect.width / cols; minGrid.cellSize = new Vector2(90, heighRow); maxGrid.cellSize = new Vector2(widthCol, 90); InputField inputField; for (byte i = 0; i < rows; i++) { inputField = Instantiate(valFieldPrefab, minsList).GetComponent <InputField>(); } for (byte i = 0; i < cols; i++) { inputField = Instantiate(valFieldPrefab, maxsList).GetComponent <InputField>(); } }
public void SaveData(Scripts.GameData gD, string fileName) { XmlSerializer serializer = new XmlSerializer(typeof(Scripts.GameData)); FileStream stream = new FileStream(string.Format("{0}/StreamingAssets/XML/{1}.xml", Application.dataPath, fileName), FileMode.Create); serializer.Serialize(stream, gD); stream.Close(); Debug.Log("XML saved!"); }
public Scripts.GameData LoadData2(string fileName) { XmlSerializer serializer = new XmlSerializer(typeof(Scripts.GameData)); FileStream stream = new FileStream(string.Format("{0}/XML/{1}.xml", Application.streamingAssetsPath, fileName), FileMode.Open); Scripts.GameData gD = (Scripts.GameData)serializer.Deserialize(stream); stream.Close(); Debug.Log("XML loaded"); return(gD); }
private void SetUp(Scripts.GameData gD) { txtRowPlayer.text = gD.playerA; txtColumnPlayer.text = gD.playerB; byte rows = (byte)gD.matrix.GetLength(0); byte cols = (byte)gD.matrix.GetLength(1); float height = mainTable.GetComponent <RectTransform>().rect.height / rows; float width = mainTable.GetComponent <RectTransform>().rect.width / cols; rowGLG.cellSize = new Vector2(CELL_SIZE, height); columnGLG.cellSize = new Vector2(width, CELL_SIZE); tableGLG.cellSize = new Vector2(width, height); }
public void UpdateTable(Scripts.GameData gD) { int id = 0; for (int i = 0; i < gD.matrix.GetLength(0); i++) { for (int j = 0; j < gD.matrix.GetLength(1); j++) { InputField field = mainTable.GetChild(id).GetComponent <InputField>(); int oldValue = int.Parse(field.text); int newValue = gD.matrix[i, j]; if (oldValue != newValue) { gD.matrix[i, j] = oldValue; } id++; } } }
public void SetUp(Scripts.GameData gameData) { txtRowPlayerName.text = gameData.playerA; txtColumnPlayerName.text = gameData.playerB; float widthRow = rowPlayerList.GetComponent <RectTransform>().rect.width / gameData.matrix.GetLength(0); float widthCol = colPlayerList.GetComponent <RectTransform>().rect.width / gameData.matrix.GetLength(1); rowGridLayout.cellSize = new Vector2(widthRow, 60); colGridLayout.cellSize = new Vector2(widthCol, 60); rowStrategiesGridLayout.cellSize = new Vector2(widthRow, 40); colStrategiesLayoutGrid.cellSize = new Vector2(widthCol, 40); InputField inputField; for (int i = 0; i < gameData.matrix.GetLength(0); i++) { // Wypłata: inputField = Instantiate(freqFieldPrefab, rowPlayerList).GetComponent <InputField>(); inputField.text = "0"; // Strategia: inputField = Instantiate(strategyFieldPrefab, rowStrategiesList).GetComponent <InputField>(); inputField.text = gameData.rowStrategies[i].ToString(); } for (int i = 0; i < gameData.matrix.GetLength(1); i++) { //Wypłata inputField = Instantiate(freqFieldPrefab, colPlayerList).GetComponent <InputField>(); inputField.text = "0"; //Strategia: inputField = Instantiate(strategyFieldPrefab, colStrategiesList).GetComponent <InputField>(); inputField.text = gameData.colStrategies[i].ToString(); } cG.alpha = 1; }
public void DisplayTable(Scripts.GameData gD) { ClearTable(); SetUp(gD); InsertValues(gD); }