コード例 #1
0
        private IEnumerator GameControllerInit(string stateName)
        {
            yield return(LoadStageData(stateName));

            _stageData = _stageCtrl.Data;
            _gameController.Initialize(this);
        }
コード例 #2
0
ファイル: StageData.cs プロジェクト: developer119korea/sudoku
 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));
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: StageData.cs プロジェクト: developer119korea/sudoku
        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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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();
            }
        }