public void AssertThat_MetaSet_SetsValue() { var input = new Vector2[] { new Vector2(10, 10), new Vector2(10, -10), new Vector2(-10, -10), new Vector2(-10, 10) }; var meta = new NamedBoxCollection(); var set = new MetaSet <bool>("test value", true); Test(set, input, meta); Assert.IsTrue(meta.GetValue(new TypedName <bool>("test value"), false)); }
void SetSrcDstSquares() // Src/dst looks correct, complete & concise 9/28/19, but advSqs are wip. { Color srcColor = Color.yellow; Color dstColor = Color.magenta; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); // From camera to mouse. RaycastHit hit; if (Physics.Raycast(ray, out hit)) // Ray hit a GameObject (square, piece, etc.). { Vector3Int raycastSquare = FindRaycastSquare(hit); // Click marks source square. if (Input.GetMouseButtonUp(1)) { if (srcSquare == nullSquare) // Fresh srcSq. { if (dstSquare == raycastSquare) // Overrides dstSq. { dstSquare = Unhighlight(raycastSquare); print("Overrides dstSq."); } srcSquare = Highlight(raycastSquare, srcColor); if (dstSquare != nullSquare) { print("Show new advSq."); } lastAdvSqLocked = false; } else if (raycastSquare == srcSquare) // Toggle srcSq. { srcSquare = Unhighlight(srcSquare); if (dstSquare != nullSquare) { print("Revert last advSq."); } } else // Move srcSq. { srcSquare = Unhighlight(srcSquare); if (dstSquare == raycastSquare) // Lock advSq (srcSq ontop of dstSq). { print("Lock last advSq."); lastAdvSqLocked = true; } else { srcSquare = Highlight(raycastSquare, srcColor); if (dstSquare != nullSquare) { // Mock code until can return a new advancement square: AdvancementSquare first = new AdvancementSquare(); AdvancementSquare second = new AdvancementSquare(); // Mock code, is only returning 'Different': MetaSet metaSet = AdvancementSquare.AreAdSqsMetaSet(first, second); if (metaSet == MetaSet.SubSet || metaSet == MetaSet.SuperSet || metaSet == MetaSet.ShiftSet) { print("Resize or shift advSq"); } else if (metaSet == MetaSet.Null) { if (!lastAdvSqLocked) { print("Clear last advSq."); } } else if (metaSet == MetaSet.Different) { if (!lastAdvSqLocked) { print("Clear last advSq."); } print("Show next advSq."); lastAdvSqLocked = false; } else if (metaSet == MetaSet.Identical) { print("Identical should never happen - Do nothing."); } } } } } // Click marks destination square. if (Input.GetMouseButtonUp(0)) { if (dstSquare == nullSquare) // Fresh dstSq. { if (srcSquare == raycastSquare) // Overrides srcSq. { srcSquare = Unhighlight(srcSquare); print("Overrides srcSq."); } dstSquare = Highlight(raycastSquare, dstColor); if (srcSquare != nullSquare) { print("Show new advSq."); AdvancementSquare advSq = CreateAdvSq(srcSquare, dstSquare); if (advSq != null) { advSqs.Add(advSq); StartCoroutine(highlightRookPlanes.ShowAdvSqByPerimeter(advSq)); } print(" Size of advSqs = " + advSqs.Count); } lastAdvSqLocked = false; } else if (raycastSquare == dstSquare) // Toggle dstSq. { dstSquare = Unhighlight(dstSquare); if (srcSquare != nullSquare) { print("Revert last advSq."); int prevAdvSqIndex = advSqs.Count - 1; StartCoroutine(highlightRookPlanes.ClearAdvSqByPerimeter(advSqs[prevAdvSqIndex])); advSqs.RemoveAt(prevAdvSqIndex); } } else // Move dstSq. { Unhighlight(dstSquare); if (srcSquare == raycastSquare) // Lock advSq (dstSq ontop of srcSq). { print("Lock last advSq."); bool line = false; highlightRookPlanes.HighlightSquare(dstSquare, line); dstSquare = nullSquare; lastAdvSqLocked = true; } else { dstSquare = Highlight(raycastSquare, dstColor); if (srcSquare != nullSquare) { // Mock code until can return a new advancement square: AdvancementSquare first = new AdvancementSquare(); AdvancementSquare second = new AdvancementSquare(); // Mock code, is only returning 'Different': MetaSet metaSet = AdvancementSquare.AreAdSqsMetaSet(first, second); if (metaSet == MetaSet.SubSet || metaSet == MetaSet.SuperSet) { print("Resize advSq (extend or contract perimeters)."); } else if (metaSet == MetaSet.Null) { if (!lastAdvSqLocked) { print("Clear last advSq."); } } else if (metaSet == MetaSet.Different) { int prevAdvSqIndex = advSqs.Count - 1; AdvancementSquare advSq1 = advSqs[prevAdvSqIndex]; AdvancementSquare advSq2 = CreateAdvSq(srcSquare, dstSquare); if (advSq2 != null) { advSqs.Add(advSq2); } if (lastAdvSqLocked) { print("Show next advSq."); StartCoroutine(highlightRookPlanes.ShowAdvSqByPerimeter(advSq2)); } else { print("Clear previous advSq and show next advSq."); StartCoroutine(highlightRookPlanes.ClearShowAdvSqsByPerimeter(advSq1, advSq2)); advSqs.RemoveAt(prevAdvSqIndex); lastAdvSqLocked = false; } } else if (metaSet == MetaSet.Identical) { print("Do nothing."); } } } } } } else // Clear src & dst squares off the board. { if (Input.GetMouseButtonUp(1)) { if (srcSquare != nullSquare) { srcSquare = Unhighlight(srcSquare); print("Lock last advSq."); lastAdvSqLocked = true; } if (srcSquare == nullSquare && dstSquare == nullSquare) { print("--- Clear all advancement squares off the board."); StartCoroutine(ClearAllAdvSqsInReverseOrder()); } } if (Input.GetMouseButtonUp(0)) { if (dstSquare != nullSquare) { dstSquare = Unhighlight(dstSquare); print("Lock last advSq."); lastAdvSqLocked = true; } if (srcSquare == nullSquare && dstSquare == nullSquare) { print("--- Clear all advancement squares off the board."); } } } }