private void VerifyMustDeleteCommand(CommandPuzzle commandPuzzle) { if (commandPuzzle.commandsFor.Count <= 0) { listCommands.Remove(commandPuzzle); } showNextStepTutorial = true; }
private void ifCommands() { if (button.name == "ifCommandButton") { UIPuzzleController.mustShowIfConditionsChoices = true; currentCommand = "if"; currentId++; return; } // Conditions if (button.name == "foundBox" || button.name == "foundKey") { UIPuzzleController.mustShowIfConditionsChoices = false; UIPuzzleController.mustShowIfCommandChoices = true; currentCondition = button.name; TextMeshProUGUI textMesh = button.GetComponentInChildren <TextMeshProUGUI>(); currentConditionName = textMesh.text; return; } // Actions if (button.name == "destroyBox" || button.name == "getKey") { UIPuzzleController.mustShowIfCommandChoices = false; CommandPuzzle commandPuzzle = new CommandPuzzle(); commandPuzzle.id = currentId; commandPuzzle.command = button.name; commandPuzzle.commandType = currentCommand; commandPuzzle.commandTypeName = "CONDIÇÃO"; commandPuzzle.commandCondition = currentCondition; commandPuzzle.commandConditionName = currentConditionName; TextMeshProUGUI textMesh = button.GetComponentInChildren <TextMeshProUGUI>(); commandPuzzle.commandName = textMesh.text; PuzzleManipulate.listCommands.Add(commandPuzzle); PuzzleManipulate.refreshResultContentPanel = true; } }
private void ConditionAction(CommandPuzzle commandPuzzleMain) { if (commandPuzzleMain.commandCondition == "foundKey" && commandPuzzleMain.command == "getKey") { if (objectWithCrystalSamePosition != null && objectWithCrystalSamePosition.tag == "Key") { objectWithCrystalSamePosition.SetActive(false); keyFounded = true; } return; } if (commandPuzzleMain.commandCondition == "foundBox" && commandPuzzleMain.command == "destroyBox") { try { Damageable d = objectWithCrystalSamePosition.GetComponentInChildren <Damageable>() == null? objectWithCrystalSamePosition.GetComponentInParent <Damageable>() : objectWithCrystalSamePosition.GetComponentInChildren <Damageable>(); if (d == null) { d = objectWithCrystalSamePosition.GetComponent <Damageable>(); } if (d != null) { Damageable.DamageMessage damage = new Damageable.DamageMessage() { amount = 999, damager = this, direction = Vector3.up, }; d.ApplyDamage(damage); boxesDesroyed--; } } catch (System.Exception ex) { } } }
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; } }
private void onClickButton() { if (PuzzleManipulate.puzzleInProgress) { return; } if (forceOpenIfTutorial || (button.name == "helpButton" || button.name == "doneButton")) { if (panelGameObject != null) { panelGameObject.SetActive(!panelGameObject.activeSelf); } forceOpenIfTutorial = false; } if (button.name == "exitButton") { OnPuzzleClosed.Invoke(); return; } if (button.name == "startButton") { PuzzleManipulate.startPuzzleControl = true; return; } if (button.name == "backButton") { if (PuzzleManipulate.listCommands.Count > 0) { CommandPuzzle lastCommand = PuzzleManipulate.listCommands[PuzzleManipulate.listCommands.Count - 1]; if (lastCommand.id == currentId) { PuzzleManipulate.listCommands.Remove(lastCommand); } } PuzzleManipulate.showNextStepTutorial = true; UIPuzzleController.mustShowForCommandChoices = false; UIPuzzleController.mustShowIfCommandChoices = false; UIPuzzleController.mustShowIfConditionsChoices = false; currentCondition = string.Empty; currentConditionName = string.Empty; currentCommand = string.Empty; return; } if (button.name == "confirmButton") { if (PuzzleManipulate.listCommands.Count > 0) { UIPuzzleController.mustShowForCommandChoices = false; currentCommand = string.Empty; } return; } this.ifCommands(); this.forCommands(); }