private void DrawListOfBoards() { GUILayout.BeginArea(ColumnOneUpperRect); BoardsScrollPos = GUILayout.BeginScrollView(BoardsScrollPos); EditorGUILayout.BeginVertical("box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); EditorGUI.BeginDisabledGroup(false); GUILayout.Space(10); GUILayout.Label("Boards:"); for (int iBoard = 0; iBoard < PuzzlesPool.Count; iBoard++) { if (CurrentBoardPool == PuzzlesPool[iBoard]) { GUI.color = Color.cyan; } if (GUILayout.Button(PuzzlesPool[iBoard].BoardType.ToString())) { CurrentBoardPool = PuzzlesPool[iBoard]; CurrentPuzzle = null; } GUI.color = Color.white; } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); }
void Start() { moduleId = moduleIdCounter++; for (int i = 0; i < Grid.Length; i++) { Grid[i].OnInteract += GridPress(i); } for (int i = 0; i < 36; i++) { Cells[i].GridPoint = Grid[i]; Cells[i].XObj = Xs[i]; Cells[i].OObj = Os[i]; Cells[i].Digit = Digits[i]; Cells[i].X = false; Cells[i].O = false; } puzzleInfo = GeneratePuzzle(); Debug.LogFormat(@"[Kyudoku #{0}] Puzzle:", moduleId); for (int row = 0; row < 6; row++) { Debug.LogFormat(@"[Kyudoku #{0}] {1}", moduleId, Enumerable.Range(0, 6).Select(col => string.Format(puzzleInfo.Given == 6 * row + col ? "[{0}]" : " {0} ", puzzleInfo.NumberGrid[6 * row + col])).Join("")); } Debug.LogFormat(@"[Kyudoku #{0}] Solution:", moduleId); for (int row = 0; row < 6; row++) { Debug.LogFormat(@"[Kyudoku #{0}] {1}", moduleId, Enumerable.Range(0, 6).Select(col => puzzleInfo.Solution[6 * row + col] ? "[" + puzzleInfo.NumberGrid[6 * row + col] + "]" : " # ").Join("")); } Cells[puzzleInfo.Given].OObj.SetActive(true); Cells[puzzleInfo.Given].O = true; for (int i = 0; i < puzzleInfo.NumberGrid.Length; i++) { Cells[i].Digit.text = puzzleInfo.NumberGrid[i].ToString(); } Reset.OnInteract += delegate { Reset.AddInteractionPunch(); Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Reset.transform); if (moduleSolved) { return(false); } for (int i = 0; i < 36; i++) { Cells[i].O = false; Cells[i].X = false; Cells[i].OObj.SetActive(false); Cells[i].XObj.SetActive(false); } Cells[puzzleInfo.Given].O = true; Cells[puzzleInfo.Given].OObj.SetActive(true); return(false); }; }
public void StartLevel(PuzzleInfo puzzleInfo) { // instantiate // (later check if new level’s board matches the prev’s board. If not, destroy that and instantiate this.) CurrentBoard = InstantiateNewBoardIfNeeded(puzzleInfo); CurrentBoard.RunLevel(puzzleInfo); }
private void DrawSecondColumn() { if (CurrentPuzzle == null) { return; } GUILayout.BeginArea(ColumnTwoRect); EditorGUILayout.BeginVertical("box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); EditorGUI.BeginDisabledGroup(false); GUILayout.Space(10); GUI.color = Color.blue; if (GUILayout.Button("Delete")) { if (CurrentPuzzle != null) { CurrentBoardPool.PuzzlesList.Remove(CurrentPuzzle); CurrentPuzzle = null; EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); GUILayout.EndArea(); return; } } GUI.color = Color.white; GUILayout.Space(20); if (CurrentPuzzle.LevelName == null || CurrentPuzzle.LevelName == "") { CurrentPuzzle.LevelName = $"Level {CurrentBoardPool.PuzzlesList.IndexOf(CurrentPuzzle)}"; } CurrentPuzzle.LevelName = EditorGUILayout.TextField("Level Name: ", CurrentPuzzle.LevelName); GUILayout.Space(30); switch (CurrentBoardPool.BoardType) { case BoardTypes.Squ5: Draw5x5(); break; case BoardTypes.Squ10: Draw10x10(); break; case BoardTypes.Squ15: break; } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); GUILayout.EndArea(); }
public void RunLevel(PuzzleInfo puzzleToApply) { CurrentPuzzle = puzzleToApply; List <string> calculatedRowsInfo = SequencesInRowsToString(); for (int i = 0; i < RowsInfo.Count; i++) { RowsInfo[i].text = calculatedRowsInfo[i]; } }
private Board InstantiateNewBoardIfNeeded(PuzzleInfo nextPuzzleInfo) { if (!IsBoardInstantiatingNeeded(nextPuzzleInfo)) { return(CurrentBoard); } return(null); //return Instantiate(Resources.Load(GetPrefabPath(CurrentBoard.CurrentPuzzle.MyPool.BoardType), typeof(GameObject))) as Board; }
public void LoadInfo(PuzzleInfo info) { // 把所有 pice 拿起 foreach (var pice in PiceManager.list) { //pice.SetToFloating(); PiceMover.SetBlockToFloat(pice); pice.StopTween(); } // 逐个设置 pice 归属 foreach (var i in info.piceInfoList) { var index = i.index; var pice = PiceManager.GetByIndex(index); if (i.owner == PiceOwner.Board) { //pice.SetToBoard(i.boardX, i.boardY); PiceMover.SetBlockToBoard(pice, i.boardX, i.boardY); } else if (i.owner == PiceOwner.Side) { //pice.SetToSide(i.sideIndex); //side.Append(pice); PiceMover.SetToSide(pice, -1); } else if (i.owner == PiceOwner.Floating) { PiceMover.SetToSide(pice, -1); //pice.SetToSide(side.count - 1); } pice.isFixed = i.isFixed; pice.SortingOrder = i.sortingOrder; // linking pice.linkingList.Clear(); foreach (var linkingInfo in i.LinkingInfoList) { var linking = new Linking(); linking.directory = linkingInfo.directory; var linkingToPinceIndex = linkingInfo.piceIndex; var linkingToPice = PiceManager.GetByIndex(linkingToPinceIndex); linking.pice = linkingToPice; pice.linkingList.Add(linking); } // edge type pice.LeftType = i.leftType; pice.RightType = i.rightType; pice.BottomType = i.bottomType; pice.TopType = i.topType; } board.RepositionAllPiceNoAnimation(); side.RepositionPiceListNoAnimation(); LayerOrderDispatcher.next = info.nextOrder; }
public PuzzleInfo CreateInfo() { var info = new PuzzleInfo(); foreach (var pice in PiceManager.list) { var piceInfo = pice.CreateInfo(); info.piceInfoList.Add(piceInfo); } info.nextOrder = LayerOrderDispatcher.next; return(info); }
private void DrawListOfLevels() { if (CurrentBoardPool == null) { return; } GUILayout.BeginArea(ColumnOneBottomRect); LevelsScrollPos = GUILayout.BeginScrollView(LevelsScrollPos); EditorGUILayout.BeginVertical("box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); EditorGUI.BeginDisabledGroup(false); GUI.color = Color.cyan; if (GUILayout.Button("Generate 100")) { for (int iAppendedLevel = 0; iAppendedLevel < 100; iAppendedLevel++) { PuzzleInfo puzzle = new PuzzleInfo(); if (puzzle.Map == null) { puzzle.Map = new Cell[GetBoardSizeFromBoardEnum(CurrentBoardPool.BoardType), GetBoardSizeFromBoardEnum(CurrentBoardPool.BoardType)]; } CurrentBoardPool.PuzzlesList.Add(puzzle); ManagersSingleton.Managers.PuzzleGenerator.Generate(ref puzzle, GetBoardSizeFromBoardEnum(CurrentBoardPool.BoardType)); } } GUI.color = Color.white; for (int iLevel = 0; iLevel < CurrentBoardPool.PuzzlesList.Count; iLevel++) { GUI.color = (CurrentBoardPool.PuzzlesList[iLevel] == CurrentPuzzle) ? Color.cyan : Color.white; if (GUILayout.Button($"Level {iLevel + 1}")) { CurrentPuzzle = CurrentBoardPool.PuzzlesList[iLevel]; } } GUI.color = Color.white; EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndArea(); }
private HttpResponse puzzlesMainPage(HttpRequest req, PuzzleInfo info, KtaneWebSession session) { return(HttpResponse.Html(new HTML( new HEAD( new META { httpEquiv = "Content-Type", content = "text/html; charset=utf-8" }, new TITLE("Puzzles"), new SCRIPT { src = "js" }, new LINK { href = "css", rel = "stylesheet", type = "text/css" } ), new BODY(new DIV { id = "everything" }._(new Api(_config, session).RenderBody())), new SCRIPTLiteral("initializePuzzles();") ))); }
private HttpResponse puzzles(HttpRequest req, PuzzleInfo info, KtaneWebSession session) { var resolver = new UrlResolver( #if DEBUG new UrlMapping(path: "/js", specificPath: true, handler: rq => HttpResponse.File(_config.Puzzles.JavaScriptFile, "text/javascript; charset=utf-8")), new UrlMapping(path: "/css", specificPath: true, handler: rq => HttpResponse.File(_config.Puzzles.CssFile, "text/css; charset=utf-8")), #else new UrlMapping(path: "/js", specificPath: true, handler: rq => HttpResponse.JavaScript(Resources.PuzzlesJs)), new UrlMapping(path: "/css", specificPath: true, handler: rq => HttpResponse.Css(Resources.PuzzlesCss)), #endif new UrlMapping(path: "/api", handler: rq => _puzzlesAjax.Handle(rq, new Api(_config, session, saveConfig))), new UrlMapping(path: "/HTML", handler: rq => _puzzlesAjax.Handle(rq, new Api(_config, session, saveConfig))), new UrlMapping(path: "", specificPath: true, handler: rq => HttpResponse.Redirect(rq.Url.WithPath("/"))), new UrlMapping(path: "/", specificPath: true, handler: rq => puzzlesMainPage(rq, info, session)), // Fallback: file system handler new UrlMapping(rq => new FileSystemHandler(Path.Combine(_config.BaseDir, "puzzles")).Handle(req)) ); return(resolver.Handle(req)); }
public void Generate(ref PuzzleInfo puzzle, int size) { for (int row = 0; row < size; row++) { bool[] rowBoolValues = AssignRowWithRandoms(size); for (int col = 0; col < size; col++) { if (puzzle.Map[row, col] == null) { puzzle.Map[row, col] = new Cell(); } if (rowBoolValues[col]) { puzzle.Map[row, col].CellMode = CellModes.MarkedAsFull; } else { puzzle.Map[row, col].CellMode = CellModes.MarkedAsEmpty; } } } }
private bool IsBoardInstantiatingNeeded(PuzzleInfo nextPuzzleInfo) { return(false);// CurrentBoard.CurrentPuzzle.MyPool.BoardType != nextPuzzleInfo.MyPool.BoardType; }