コード例 #1
0
        public KendokuGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            this.IsMouseVisible            = true;
            this.Window.AllowUserResizing  = true;
            this.Window.ClientSizeChanged += Window_ClientSizeChanged;

            textureManager = new TextureManager(this.Content);
            gridSolver     = new GridSolver();
            gridRawData1   = new GridRawData();
            gridRawData2   = new GridRawData();
            gridRawData3   = new GridRawData();
            gridRawData1   = gridRawData1.LoadRawData("KendokuData_1.json");
            gridRawData2   = gridRawData2.LoadRawData("KendokuData_2.json");
            gridRawData3   = gridRawData3.LoadRawData("KendokuData_3.json");

            gridData1      = new GridData(gridRawData1);
            solveGridData1 = new GridData(gridRawData1);

            gridData2      = new GridData(gridRawData2);
            solveGridData2 = new GridData(gridRawData2);

            gridData3      = new GridData(gridRawData3);
            solveGridData3 = new GridData(gridRawData3);


            state_ = new GameState();
        }
コード例 #2
0
ファイル: GridData.cs プロジェクト: octobus55/Kendoku
        public GridRawData CreateGridRawData()
        {
            GridRawData gridRawData = new GridRawData();

            gridRawData.CreateRawData(this);
            return(gridRawData);
        }
コード例 #3
0
ファイル: GridData.cs プロジェクト: octobus55/Kendoku
        public GridData(GridRawData gridRawData)
        {
            this.gridCount = gridRawData.gridCount;

            this.sections = new Section[gridRawData.sectionDatas.Length];
            for (int i = 0; i < this.sections.Length; i++)
            {
                string sectionData              = gridRawData.sectionDatas[i];
                char   operationSymbol          = sectionData[0];
                Section.MathOperation operation = Section.MathOperation.None;
                int result = int.Parse(sectionData.Substring(1, sectionData.Length - 1));


                if (operationSymbol == '+')
                {
                    operation = Section.MathOperation.Add;
                }
                else if (operationSymbol == '-')
                {
                    operation = Section.MathOperation.Substract;
                }
                else if (operationSymbol == '×')
                {
                    operation = Section.MathOperation.Multiply;
                }
                else if (operationSymbol == '÷')
                {
                    operation = Section.MathOperation.Divide;
                }

                this.sections[i] = new Section(result, operation, i);
            }


            gridCells = new GridCell[gridRawData.gridCount, gridRawData.gridCount];


            for (int i = 0; i < gridRawData.gridCount; i++)
            {
                for (int j = 0; j < gridRawData.gridCount; j++)
                {
                    int sectionIndex = gridRawData.sectionIndexes[i, j];
                    gridCells[i, j] = new GridCell(i, j, this.sections[sectionIndex], this);
                }
            }

            for (int i = 0; i < sections.Length; ++i)
            {
                for (int j = 0; j < gridRawData.gridCount; ++j)
                {
                    for (int k = 0; k < gridRawData.gridCount; ++k)
                    {
                        if (gridRawData.sectionIndexes[j, k] == i)
                        {
                            sections[i].AddGridData(gridCells[j, k]);
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: GridData.cs プロジェクト: octobus55/Kendoku
        public GridRawData LoadRawData(string fileName)
        {
            GridRawData gridRawData = null;

            using (StreamReader streamReader = new StreamReader(fileName))
            {
                string jsonData = streamReader.ReadToEnd();
                gridRawData = JsonConvert.DeserializeObject <GridRawData>(jsonData);
            }

            return(gridRawData);
        }