private void forCommands() { if (button.name == "forCommandButton") { UIPuzzleController.mustShowForCommandChoices = true; currentCommand = "for"; currentId++; return; } if (currentCommand == "for") { CommandPuzzle lastCommand = PuzzleManipulate.listCommands.Count > 0 ? PuzzleManipulate.listCommands[PuzzleManipulate.listCommands.Count - 1] : new CommandPuzzle(); if (lastCommand.id != currentId) { CommandPuzzle commandPuzzle = new CommandPuzzle(); commandPuzzle.id = currentId; commandPuzzle.commandType = currentCommand; commandPuzzle.commandTypeName = "REPETIÇÃO"; commandPuzzle.countLoop = currentNumberLoopForCommand; PuzzleManipulate.listCommands.Add(commandPuzzle); lastCommand = PuzzleManipulate.listCommands[PuzzleManipulate.listCommands.Count - 1]; } CommandFor commandFor = new CommandFor(); TextMeshProUGUI textMesh = button.GetComponentInChildren <TextMeshProUGUI>(); commandFor.commandName = textMesh.text; commandFor.command = button.name; lastCommand.commandsFor.Add(commandFor); PuzzleManipulate.showNextStepTutorial = true; return; } }
public void CommandSelected() { if (showNextStepTutorial && hasPlayerInArea) { showNextStepTutorial = false; foreach (GameObject gameObject in generatedObjects) { Destroy(gameObject); } GetCurrentCrystalSimulator().SetActive(false); currentFloorX = 0; currentFloorY = 0; foreach (CommandPuzzle commandPuzzleMain in listCommands) { if (commandPuzzleMain.commandType == "for") { for (int i = 0; i < commandPuzzleMain.countLoop; i++) { for (int j = 0; j < commandPuzzleMain.commandsFor.Count; j++) { CommandFor commandFor = commandPuzzleMain.commandsFor[j]; GameObject currentCrystalSimulator = GetCurrentCrystalSimulator(); if (commandFor.command == "moveUp") { currentFloorY++; } if (commandFor.command == "moveDown") { currentFloorY--; } if (commandFor.command == "turnRight") { currentFloorX++; } if (commandFor.command == "turnLeft") { currentFloorX--; } if ((currentFloorX >= sizeXMatrix || currentFloorX < 0) || (currentFloorY >= sizeYMatrix || currentFloorY < 0) || !ValidateMustAddCommand(j)) { commandPuzzleMain.commandsFor.RemoveAt(j); ClearOnlyCrystalSimulators(); currentFloorX = 0; currentFloorY = 0; VerifyMustDeleteCommand(commandPuzzleMain); return; } currentCrystalSimulator.SetActive(false); GameObject newCrystalSimulator = GetCurrentCrystalSimulator(); Color color = newCrystalSimulator.GetComponent <Renderer>().material.color; newCrystalSimulator.GetComponent <Renderer>().material.color = new Color(1, 1, 1, 1); newCrystalSimulator.SetActive(true); showNextStepTutorial = false; } } } } this.ClearAndCreateResultContent(); } }