private void Update() { if (gameState == GameState.None) { if (Input.GetMouseButtonDown(0)) { var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { hitGO = hit.collider.gameObject; gameState = GameState.SelectionStarted; } } } else if (gameState == GameState.SelectionStarted) { if (Input.GetMouseButtonDown(0)) { var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null && hitGO != hit.collider.gameObject) { StopCheckPotentialMatches(); if (!MatchChecker.AreNeighbors(hitGO.GetComponent <Candy>(), hit.collider.gameObject.GetComponent <Candy>())) { gameState = GameState.None; } else { FixSortingLayer(hitGO, hit.collider.gameObject); StartCoroutine(FindMatchesAndCollapse(hit)); } } } } }
internal bool Matches(object request, ITransportMatchers transportMatchers) { var context = new MatchingContext(transportMatchers.RequestMatchers.Concat(requestMatchers).ToArray(), true); var checker = new MatchChecker(); checker.Matches(this.request, request, context); return(context.Result.Matches); }
// Use this for initialization void Start() { GetAllComponents(); SetupGemSwapHandler(); //setup callbackd for the presentation to let us know when things have finished MatchChecker = PuzzleBoardController.MatchChecker; //for now start a coroutine and then start a game StartCoroutine(TestInitGame()); }
// Use this for initialization void Start () { GetAllComponents(); SetupGemSwapHandler(); //setup callbackd for the presentation to let us know when things have finished MatchChecker = PuzzleBoardController.MatchChecker; //for now start a coroutine and then start a game StartCoroutine(TestInitGame()); }
// Update is called once per frame void Update() { // if (state == GameState.None) { // Touch input if (Input.GetMouseButtonDown(0)) { // Figure out what they touched var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { hitGo = hit.collider.gameObject; // update game state to be aware the player is selecting state = GameState.SelectionStarted; } } } else if (state == GameState.SelectionStarted) { // player has tapped twice if (Input.GetMouseButtonDown(0)) { // Figure out what they touched var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); // The player touched something and it was not the same item if (hit.collider != null && hitGo != hit.collider.gameObject) { StopCheckForPotentialMatches(); // Compare if the two objects are not neighbors if (!MatchChecker.AreHorizontalOrVericalNeighbors(hitGo.GetComponent <Candy>(), hit.collider.gameObject.GetComponent <Candy>())) { state = GameState.None; } else { // next to each other state = GameState.Animating; // assign sorting layer FixSortingLayer(hitGo, hit.collider.gameObject); // Pass the raycast hit StartCoroutine(FindMatchesAndCollapse(hit)); } } } } }
private void GetAllComponents() { BoardConfig = GetComponentInParent<BoardConfig>() as BoardConfig; if (BoardConfig == null) { throw new UnityException("PuzzleBoardController must have a BoardConfig component attached or as a parent."); } MatchChecker = GetComponent<MatchChecker>() as MatchChecker; if (MatchChecker == null) { throw new UnityException("PuzzleBoardController must have a MatchChecker component attached."); } }
private void GetAllComponents() { BoardConfig = GetComponentInParent <BoardConfig>() as BoardConfig; if (BoardConfig == null) { throw new UnityException("PuzzleBoardController must have a BoardConfig component attached or as a parent."); } MatchChecker = GetComponent <MatchChecker>() as MatchChecker; if (MatchChecker == null) { throw new UnityException("PuzzleBoardController must have a MatchChecker component attached."); } }
private IEnumerator CheckPotentialMatches() { yield return(new WaitForSeconds(GameVariables.WaitBeforePotentialMatchesCheck)); potentialMatches = MatchChecker.GetPotentialMatches(marbles); if (potentialMatches != null) { while (true) { AnimatePotentialMatchesCoroutine = MatchChecker.AnimatePotentialMatches(potentialMatches); StartCoroutine(AnimatePotentialMatchesCoroutine); yield return(new WaitForSeconds(GameVariables.WaitBeforePotentialMatchesCheck)); } } }
public async Task <InteractionVerificationResult> Honour() { if (!string.IsNullOrEmpty(providerState)) { await ensureProviderState(providerState); } var actualResponse = await transport.Respond(request); var context = new MatchingContext(matchers, false); var checker = new MatchChecker(); var roundTrippedResponse = transport.Format.DeserializeResponse(transport.Format.SerializeResponse(actualResponse)); checker.Matches(response, roundTrippedResponse, context); return(new InteractionVerificationResult(description, context.Result.Matches, context.Result.FailureReasons)); }
public object Respond(object request, ITransportMatchers transportMatchers) { var response = responseFactory(request); var expectedResponse = responseFactory(this.request); var context = new MatchingContext(transportMatchers.ResponseMatchers.Concat(responseMatchers).ToArray(), false); var checker = new MatchChecker(); checker.Matches(expectedResponse, response, context); if (!context.Result.Matches) { throw new Exception("Invalid interaction setup - the generated response does not match the expected format: " + context.Result.FailureReasons); } CallCount++; return(response); }
public void V2Specs(string name, bool isRequest, JObject testCase) { var shouldMatch = (bool)testCase["match"]; var actual = testCase["actual"]; var expected = testCase["expected"]; Assert.Null(actual["matchingRules"]); var rulesJsonProperty = expected["matchingRules"]; var rules = new IMatcher[0]; if (rulesJsonProperty != null) { rules = MatcherParser.Parse(rulesJsonProperty as JObject); ((JObject)expected).Remove("matchingRules"); } var transportMatchers = new PactV2CompliantHttpTransportMatchers(); if (isRequest) { rules = transportMatchers.RequestMatchers.Concat(rules).ToArray(); } else { rules = transportMatchers.ResponseMatchers.Concat(rules).ToArray(); } var context = new MatchingContext(rules, isRequest); var matchChecker = new MatchChecker(); matchChecker.Matches(expected, actual, context); if (shouldMatch) { Assert.True(context.Result.Matches, name + ": " + context.Result.FailureReasons); } else { Assert.False(context.Result.Matches, name + ": did match although it shouldn't"); } }
/// <summary> /// Performs the operations and commands specified in the input arguments. /// </summary> private static async Task RunOptionsAsync(CLIOptions options) { ConfigCreator creator = new ConfigCreator(options); await creator.InitializeAsync(); if (creator.Catalog == null || creator.Config == null) { options.ErrorWriter.WriteLine(Strings.NoPartsMessage); return; } PartInfo infoGetter = new PartInfo(creator, options); infoGetter.PrintRequestedInfo(); MatchChecker checker = new MatchChecker(creator, options); checker.PerformMatching(); RejectionTracer tracer = new RejectionTracer(creator, options); tracer.PerformRejectionTracing(); }
void Update() { if (state == GameState.None) { if (Input.GetMouseButtonDown(0)) { var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null) { hitGo = hit.collider.gameObject; state = GameState.SelectionStarted; } } } else if (state == GameState.SelectionStarted) { if (Input.GetMouseButtonDown(0)) { var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); if (hit.collider != null && hitGo != hit.collider.gameObject) { StopCheckForPotentialMatches(); if (!MatchChecker.AreHorizontalOrVerticalNeigbhours(hitGo.GetComponent <Candy>(), hit.collider.gameObject.GetComponent <Candy>())) { state = GameState.None; } else { state = GameState.Animating; FixSortingLayer(hitGo, hit.collider.gameObject); StartCoroutine(FindMatchesAndCollapse(hit)); } } } } }
private IEnumerator CheckPotentialMatches() { // Wait delay before showing potential matches yield return(new WaitForSeconds(GameVariables.WaitBeforePotentialMatchesCheck)); // get any potential matches potentialMatches = MatchChecker.GetPotentialMatches(candies); // if we have matches if (potentialMatches != null) { // animate them until the player takes their turn while (true) { AnimatePotentialMatchesCoroutine = MatchChecker.AnimatePotentialMatches(potentialMatches); StartCoroutine(AnimatePotentialMatchesCoroutine); // Wait delay before showing potential matches yield return(new WaitForSeconds(GameVariables.WaitBeforePotentialMatchesCheck)); } } }
void Update() { //****** START TOUCH CONTROLS /* * if (Input.touchCount == 1) { * * Touch touch = Input.GetTouch (0); * * Vector2 v = Camera.main.ScreenToWorldPoint(touch.position); * * if (touch.phase == TouchPhase.Began) { * * var hit = Physics2D.OverlapPointAll(v); * * foreach(Collider2D c in hit) * { * hitGo = c.GetComponent<Collider2D>().gameObject; * state = GameState.SelectionStarted; * //Debug.Log ("hit!"); * fp = touch.position; * lp = touch.position; * } * * } else if (touch.phase == TouchPhase.Ended) { * //Debug.Log ("touch ended!"); * var hit = Physics2D.OverlapPointAll(v); * * lp = touch.position; * * if (Mathf.Abs (lp.x - fp.x) > dragDistance || Mathf.Abs (lp.y - fp.y) > dragDistance) { * //Debug.Log ("it's a swipe!"); * * foreach (Collider2D c in hit) { * * if (c.GetComponent<Collider2D> () != null && hitGo != c.GetComponent<Collider2D> ().gameObject) { * * StopCheckForPotentialMatches (); * * if (!MatchChecker.AreHorizontalOrVerticalNeighbors (hitGo.GetComponent<Marble> (), * c.GetComponent<Collider2D> ().gameObject.GetComponent<Marble> ())) { * state = GameState.None; * } else { * state = GameState.Animating; * FixSortingLayer (hitGo, c.GetComponent<Collider2D> ().gameObject); * StartCoroutine (FindMatchesAndCollapse (c)); * } * } * } * } else { * //Debug.Log ("just a tap"); * state = GameState.None; * } * } * } */ //***** END TOUCH CONTROLS //***** START MOUSE CONTROLS var mousePos = Input.mousePosition; if (state == GameState.None) { if (Input.GetMouseButtonDown(0)) { mousePos.z = -10; Vector2 v = Camera.main.ScreenToWorldPoint(mousePos); var hit = Physics2D.OverlapPointAll(v); if (hit.Length > 0) { foreach (Collider2D c in hit) { hitGo = c.GetComponent <Collider2D> ().gameObject; //if (hitGo.tag != "ElementalSphere") { state = GameState.SelectionStarted; //} else if (hitGo.tag == "ElementalSphere") { // Debug.Log ("ok, so it's a sphere. Now what?"); //} } } } } else if (state == GameState.SelectionStarted) { if (Input.GetMouseButtonDown(0)) { mousePos.z = -10; Vector2 v = Camera.main.ScreenToWorldPoint(mousePos); var hit = Physics2D.OverlapPointAll(v); if (hit.Length > 0) { foreach (Collider2D c in hit) { if (c.GetComponent <Collider2D> () != null && hitGo != c.GetComponent <Collider2D> ().gameObject) { StopCheckForPotentialMatches(); if (!MatchChecker.AreHorizontalOrVerticalNeighbors(hitGo.GetComponent <Marble> (), c.GetComponent <Collider2D> ().gameObject.GetComponent <Marble> ())) { state = GameState.None; } else { state = GameState.Animating; FixSortingLayer(hitGo, c.GetComponent <Collider2D> ().gameObject); StartCoroutine(FindMatchesAndCollapse(c)); } } } } } } // ****** END MOUSE CONTROLS } //End Update Function
private IEnumerator CheckPotentialMatches() { yield return(new WaitForSeconds(GameVariables.WaitBeforematchCheck)); potentialMatches = MatchChecker.GetPotentialMatches(candyArray).ToList <GameObject>(); }
public void SetCellTicked() { _cachedMaterial.SetTexture(MainTexture, SharedData.ins.cellTickedTexture); _iscellTicked = true; MatchChecker.CheckForMatch(_x, _y); }