public PuzzlePage() { InitializeComponent(); SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape; // Puzzle Game this.game = new PuzzleGame(3); this.game.GameStarted += delegate { this.StatusPanel.Visibility = Visibility.Visible; this.TapToContinueTextBlock.Opacity = 0; this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString(); }; this.game.GameOver += delegate { this.TapToContinueTextBlock.Opacity = 1; this.StatusPanel.Visibility = Visibility.Visible; this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString(); }; this.game.PieceUpdated += delegate(object sender, PieceUpdatedEventArgs args) { int pieceSize = ImageSize / this.game.ColsAndRows; this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.LeftProperty, (int)args.NewPosition.X * pieceSize); this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.TopProperty, (int)args.NewPosition.Y * pieceSize); this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString(); }; this.InitBoard(); }
public void NewGameClicked() { if (String.IsNullOrEmpty(nameField.text) || !toggleGroup.AnyTogglesOn()) { return; } var activeToggle = toggleGroup.ActiveToggles().First(); BPGame game; var model = GetGameModel(activeToggle.gameObject.name); if (model == GameModel.Puzzle) { game = new PuzzleGame(); } else { game = new BPGame(); } game.name = nameField.text.Trim(); game.model = model; DataManager.AddGame(game); MenuMaster.Instance.ChangeMenu("editor"); }
private void ParameterPuzzleCommand(string input) { PuzzleGame pGame = GameObject.Find("PuzzleManager").transform.GetChild(0).gameObject.GetComponent <PuzzleGame> (); bool isParameter = CheckInput(input); Debug.Log(isParameter); if (isParameter) { int leftParam = input.IndexOf("("); int rightParam = input.IndexOf(")"); int beginning = input.IndexOf("-"); string parameter = input.Substring(leftParam, rightParam - (leftParam - 1)); string command = input.Substring(beginning, leftParam); string valueParam = parameter.Substring(parameter.IndexOf("(") + 1, parameter.IndexOf(")") - ((parameter.IndexOf("(") + 1))); // Decrement the number of multi command that the user is able to use within the puzzle instance gManager.numberCommands--; int intParam = int.Parse(valueParam); PerformPuzzleCommand(command, intParam); } else if (!isParameter) { // Convey to the user that the command was not valid in text DebugText.GetComponent <Text> ().text = "[ERROR] : Non-recognizable Command"; // And then through graphics StartCoroutine(DebugGraphicalNotifier(false)); } }
/// <summary> /// 加载游戏 /// </summary> void LoadGame() { // 加载 拼图游戏 预制体,并挂载游戏脚本 puzzleGame = NGUITools.AddChild(uiRootGame, Resources.Load <GameObject>("Puzzle")).AddComponent <PuzzleGame>(); // 设置游戏摄像机 puzzleGame.cam = uiRootGame.transform.Find("Camera").GetComponent <Camera>(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); MaximumSize = Screen.PrimaryScreen.WorkingArea.Size; ChangeTheme(false, true); AnimateWindow(Handle, 200, AnimateWindowFlags.AW_BLEND); PuzzleGame = new PuzzleGame(this); }
public override CreatePicturePuzzleResponse Execute(CreatePicturePuzzleRequest request) { var puzzleGame = new PuzzleGame(new PuzzleGameBoard() { Height = request.BoardGameHeight, Width = request.BoardGameWidth, }); Random rnd = new Random(); var randomIds = new List <int>(); for (int i = 0; i < request.NumberOfPuzzles; i++) { // Number 21 for now is hardcoded it should be moved to a setting file var randomNumber = rnd.Next(1, 22); while (randomIds.Contains(randomNumber)) { randomNumber = rnd.Next(1, 22); } randomIds.Add(randomNumber); } var pictureNationalityPuzzles = _pictureNationalityPuzzleRepository.GetPuzzlesByIds(randomIds); var response = new CreatePicturePuzzleResponse(); foreach (var puzzle in pictureNationalityPuzzles) { puzzleGame.GameHistories.Add(new PuzzleGameHistory() { Id = Guid.NewGuid(), PictureNationalityPuzzleId = puzzle.Id, PuzzleGameId = puzzleGame.Id, }); response.PicturePuzzleResponses.Add(new PicturePuzzleResponse() { PictureId = puzzle.Id, PictureUrl = puzzle.PictureUrl, }); } _puzzleGameRepository.Create(puzzleGame); UnitOfWork.Commit(); return(response); }
// Use this for initialization void Start () { doOnce = true; pGame = GameObject.Find("PuzzleManager").transform.GetChild(0).gameObject.GetComponent<PuzzleGame>(); DetermineFloorType(); }
private void HandleFloorAffector(Collider x) { PuzzleGame pGame = GameObject.Find ("PuzzleManager").transform.GetChild (0).gameObject.GetComponent<PuzzleGame> (); if(true) { // Set flag to true, indicating that a user is being affected affectingPlayer = true; // Copy the movescale, in order to handle out of scope movement int movement = moveScale; if (movePlayerLeft || movePlayerRight) { if (movePlayerRight) {Debug.Log ("Moving Left");movement *= -1;}else if (movePlayerLeft){Debug.Log("Moving Right");} Vector3 desiredPosition = (pGame.player.transform.localPosition + new Vector3 (movement, -0.75f, 0)); // First attempt to move the player, and see if it is within scope of the map bool attemptMovement = pGame.MovePlayer (desiredPosition); Debug.Log ("Attempted Movement : " + attemptMovement); Debug.Log ("Movement : " + movement); // Continually try to move the player in the same direction, but with less movement , as long // the desired position is within scope of the map while(attemptMovement == false && movement != 0) { // Increment movement based upon which direction the affecter is trying to move the player if(movePlayerRight){movement++;}else if (movePlayerLeft){movement--;} Debug.Log ("Dynamic Movement : " + movement); // Update the desired position based upon what is dynaimic value of movement desiredPosition = (pGame.player.transform.localPosition + new Vector3 (movement, -0.75f, 0)); // Attempt to move the player again, and continue until the affecter can't (when the affecter won't move the player at all) if (movement != 0) attemptMovement = pGame.MovePlayer (desiredPosition); Debug.Log("Dynamic Attempt Movement : " + attemptMovement); } // If the affecter isn't able to move the player at all.. if(movement == 0) { // Reset the color to white x.gameObject.GetComponent<MeshRenderer> ().material.color = Color.magenta; Debug.Log ("Can't Move player at all -- End of Map affecter case"); GameObject.Find ("PuzzleManager").transform.GetChild (0).gameObject.GetComponent<PuzzleGame> ().PerformMapMovement (); affectingPlayer = false; GameObject.Find ("PuzzleManager").GetComponent<PuzzleManager> ().affecterInUse = null; } } else if (movePlayerUp || movePlayerDown) { if (movePlayerUp) {Debug.Log ("Moving Up");movement *= -1;}else if (movePlayerDown){Debug.Log ("Moving Down");} Vector3 desiredPosition = (pGame.player.transform.localPosition + new Vector3 (0, -0.75f, movement)); // First attempt to move the player, and see if it is within scope of the map bool attemptMovement = pGame.MovePlayer (desiredPosition); // Continually try to move the player in the same direction, but with less movement , as long // the desired position is within scope of the map while(attemptMovement == false && movement != 0) { // Increment movement based upon which direction the affecter is trying to move the player if(movePlayerUp){movement++;}else if (movePlayerDown){movement--;} Debug.Log ("Dynamic Movement : " + movement); desiredPosition = (pGame.player.transform.localPosition + new Vector3 (0, -0.75f, movement)); attemptMovement = pGame.MovePlayer (desiredPosition); Debug.Log("Dynamic Attempt Movement : " + attemptMovement); } if(movement == 0) { Debug.Log ("Can't Move player at all -- End of Map affecter case"); GameObject.Find ("PuzzleManager").transform.GetChild (0).gameObject.GetComponent<PuzzleGame> ().PerformMapMovement (); GameObject.Find ("PuzzleManager").GetComponent<PuzzleManager> ().affecterInUse = null; } } else if (traversePlayer) { pGame.MovePlayer (traverseLocation); } } }
void StartLevel(int p_id) { puzzleID = p_id; if (puzzleID == 1) { // The number of max multi commands that can be used for puzzle one int puzzleOneMCommands = 1; // The number of commands that can be executed for puzzle one int puzzleOneCommands = 10; int maxStep = 3; // Instantiate prefab of level one GameObject puzzleInstance = Instantiate(puzzleTypes[0]) as GameObject; // Initialize the puzzle one's number of Multi and Single commands allowed for the level pGame = puzzleInstance.GetComponent <PuzzleGame> (); puzzleInstance.GetComponent <PuzzleGame> ().InitPuzzleGame(puzzleOneCommands, puzzleOneMCommands, maxStep); // Set the parent of the instantiated puzzle to this object puzzleInstance.transform.SetParent(this.transform); // Set the puzzle location to start at the origin puzzleInstance.transform.localPosition = Vector3.zero; } else if (puzzleID == 2) { // The number of max multi commands that can be used for puzzle one int puzzleOneMCommands = 1; // The number of commands that can be executed for puzzle one int puzzleOneCommands = 7; int maxStep = 3; // Instantiate prefab of level one GameObject puzzleInstance = Instantiate(puzzleTypes[1]) as GameObject; // Initialize the puzzle one's number of Multi and Single commands allowed for the level pGame = puzzleInstance.GetComponent <PuzzleGame> (); puzzleInstance.GetComponent <PuzzleGame> ().InitPuzzleGame(puzzleOneCommands, puzzleOneMCommands, maxStep); // Set the parent of the instantiated puzzle to this object puzzleInstance.transform.SetParent(this.transform); // Set the puzzle location to start at the origin puzzleInstance.transform.localPosition = Vector3.zero; } else if (puzzleID == 3) { // The number of max multi commands that can be used for puzzle one int puzzleOneMCommands = 1; // The number of commands that can be executed for puzzle one int puzzleOneCommands = 10; int maxStep = 3; // Instantiate prefab of level one GameObject puzzleInstance = Instantiate(puzzleTypes[2]) as GameObject; // Initialize the puzzle one's number of Multi and Single commands allowed for the level pGame = puzzleInstance.GetComponent <PuzzleGame> (); puzzleInstance.GetComponent <PuzzleGame> ().InitPuzzleGame(puzzleOneCommands, puzzleOneMCommands, maxStep); // Set the parent of the instantiated puzzle to this object puzzleInstance.transform.SetParent(this.transform); // Set the puzzle location to start at the origin puzzleInstance.transform.localPosition = Vector3.zero; } }
public static void AutosplitHelp(PuzzleGame __instance, ref int ____goalAffection, ref bool ____victory, ref bool ____isBonusRound) { //allow splits to happen with cheats/has returned, as long as we don't auto-start with those on it's fine //if (BaseHunieModPlugin.cheatsEnabled || BaseHunieModPlugin.hasReturned) return; if (__instance.currentDisplayAffection == 0) { startingCompletedGirls = GameManager.System.Player.GetTotalMaxRelationships(); startingRelationship = GameManager.System.Player.GetGirlData(GameManager.Stage.girl.definition).relationshipLevel; } if (__instance.currentDisplayAffection == ____goalAffection && (____victory || ____isBonusRound)) { //make the autosplitter more viable for 100%? if (startingCompletedGirls < 12) { searchForMe = 100; } //if a timer is running, split if (!splitThisDate && BaseHunieModPlugin.run != null) { bool didSplit = false; RunTimer run = BaseHunieModPlugin.run; //don't split for dates in postgame if (startingCompletedGirls < 12) { //check our rules if (run.goal <= 2 || BaseHunieModPlugin.SplitRules.Value <= 0) { didSplit = run.split(____isBonusRound); } else if (BaseHunieModPlugin.SplitRules.Value == 1 && !____isBonusRound) { didSplit = run.split(____isBonusRound); } else if (BaseHunieModPlugin.SplitRules.Value == 2 && ____isBonusRound) { didSplit = run.split(____isBonusRound); } //check for final split regardless of option //technically someone could just repeat sex with a girl to trigger this split. if they do that, too bad else if (____isBonusRound && (run.goal == startingCompletedGirls + 1)) { didSplit = run.split(____isBonusRound); } } if (didSplit) { RunTimerPatches.initialTimerDelay.Start(); if (!____isBonusRound) { RunTimerPatches.revertDiffDelay.Start(); } RunTimerPatches.isBonusRound = ____isBonusRound; int dateNum = startingRelationship; //if (____isBonusRound) dateNum++; I thought I need to increase this but it makes it #6 string newSplit = GameManager.Stage.girl.definition.firstName + " #" + dateNum; if (GameManager.Stage.girl.definition.firstName == "Kyu" && startingCompletedGirls == 0) { newSplit = "Tutorial"; } newSplit += "\n " + run.splitText + "\n"; run.push(newSplit); if (____isBonusRound && (run.goal == startingCompletedGirls + 1)) { run.save(); } } } splitThisDate = true; } else { searchForMe = 0; replacingText = false; splitThisDate = false; } }
void Awake() { instance = this; }
private void PerformPuzzleCommand(string input, int param) { PuzzleGame pGame = GameObject.Find("PuzzleManager").transform.GetChild(0).gameObject.GetComponent <PuzzleGame> (); if (input == "-stepleft") { Vector3 desiredPosition = pGame.player.transform.localPosition + new Vector3(1 * param, -0.75f, 0); bool validOperation = pGame.MovePlayer(desiredPosition); if (validOperation) { DebugText.GetComponent <Text> ().text = "SUCCESS"; StartCoroutine(DebugGraphicalNotifier(true)); } else if (validOperation != true) { DebugText.GetComponent <Text> ().text = "[ERROR] : MOVEMENT OUTSIDE SCOPE OF MAP"; StartCoroutine(DebugGraphicalNotifier(false)); } } else if (input == "help") { puzzleHelpGUI.SetActive(true); StartCoroutine(ShowHelpPuzzleGUI()); } else if (input == "-stepright") { Vector3 desiredPosition = pGame.player.transform.localPosition + new Vector3(-1 * param, -0.75f, 0); bool validOperation = pGame.MovePlayer(desiredPosition); if (validOperation) { DebugText.GetComponent <Text> ().text = "SUCCESS"; StartCoroutine(DebugGraphicalNotifier(true)); } else if (validOperation != true) { DebugText.GetComponent <Text> ().text = "[ERROR] : MOVEMENT OUTSIDE SCOPE OF MAP"; StartCoroutine(DebugGraphicalNotifier(false)); } } else if (input == "-stepup") { Vector3 desiredPosition = pGame.player.transform.localPosition + new Vector3(0, -0.75f, -1 * param); bool validOperation = pGame.MovePlayer(desiredPosition); if (validOperation) { DebugText.GetComponent <Text> ().text = "SUCCESS"; StartCoroutine(DebugGraphicalNotifier(true)); } else if (validOperation != true) { DebugText.GetComponent <Text> ().text = "[ERROR] : MOVEMENT OUTSIDE SCOPE OF MAP"; StartCoroutine(DebugGraphicalNotifier(false)); } } else if (input == "-stepdown") { Vector3 desiredPosition = pGame.player.transform.localPosition + new Vector3(0, -0.75f, 1 * param); bool validOperation = pGame.MovePlayer(desiredPosition); if (validOperation) { DebugText.GetComponent <Text> ().text = "SUCCESS"; StartCoroutine(DebugGraphicalNotifier(true)); } else if (validOperation != true) { DebugText.GetComponent <Text> ().text = "[ERROR] : MOVEMENT OUTSIDE SCOPE OF MAP"; StartCoroutine(DebugGraphicalNotifier(false)); } } // Clear the console inField.text = ""; }
public PuzzleGameModel() { _instanceGame = new PuzzleGame(); }