private IEnumerator GameControllerInit(string stateName) { yield return(LoadStageData(stateName)); _stageData = _stageCtrl.Data; _gameController.Initialize(this); }
private void CheckMapData(model.StageData stageData) { for (int i = 0; i < stageData.cellDataList.Count; i++) { Debug.Log(string.Format("[{0}, {1}] : {2}", stageData.cellDataList[i].column, stageData.cellDataList[i].row, stageData.cellDataList[i].number)); } }
private int[] GetNumberValueOfPackFromStageData(model.StageData stagedata, int packIndex) { int[] numberArr = new int[DefineData.MAX_CELL_COUNT]; int startIndex = packIndex * DefineData.MAX_CELL_COUNT; for (int i = 0; i < DefineData.MAX_CELL_COUNT; i++) { numberArr[i] = stagedata.cellDataList[startIndex + i].number; } return(numberArr); }
public IEnumerator LoadStageData(string stageName) { string dir = DefineData.StreamingAssetsPath; string sourcePath = string.Format("{0}{1}.json", dir, stageName); WWW www = new WWW(sourcePath); yield return(www); Debug.Log(string.Format("{0} : {1}", sourcePath, www.isDone)); string sourceStr = this.ByteToString(www.bytes); _stagedata = new model.StageData(); JsonUtility.FromJsonOverwrite(sourceStr, _stagedata); }
public void Initialize(model.StageData stageData) { int[] packNumberArr = new int[DefineData.MAX_CELL_COUNT]; int emptyCount = 0; for (int i = 0; i < _squarePacks.Length; i++) { packNumberArr = GetNumberValueOfPackFromStageData(stageData, i); _squarePacks[i].Initialize(packNumberArr); for (int j = 0; j < packNumberArr.Length; j++) { if (packNumberArr[j] == 0) { emptyCount++; } } } this._emptyCellCount = emptyCount; Debug.Log(string.Format("Init EmptyCellCount : {0}", this._emptyCellCount)); }
public void MapSave(model.SquareBoard board) { model.StageData stageData = new model.StageData(); model.SquarePack targetPack = null; model.SquareCell targetCell = null; int column, row; for (int i = 0; i < board.SquarePack.Length; i++) { targetPack = board.SquarePack[i]; for (int j = 0; j < targetPack.SquareCells.Length; j++) { targetCell = targetPack.SquareCells[j]; column = targetCell.BoardCoorinate.column; row = targetCell.BoardCoorinate.row; stageData.cellDataList.Add(new model.CellData(column, row, targetCell.NumberValue)); } } string str = JsonUtility.ToJson(stageData, prettyPrint: true); Debug.Log(str); using (FileStream fs = new FileStream("Assets/Resources/stage1.json", FileMode.Create)) { using (StreamWriter writer = new StreamWriter(fs)) { writer.Write(str); writer.Close(); writer.Dispose(); } fs.Close(); fs.Dispose(); } }