public void TilePlaced(Honeycomb tile, bool corrupted) { var optionLeft = CheckNoOptionLeft(); if (!optionLeft) { return; } // Move Milfs MilfController.Instance.MoveMilfs(bee.currentTile); if (corrupted) { //Bee shouldnt move to newly placed corrupted tiles return; } MilfController.Instance.IncreaseMilfCounter(); var path = PathfinderBeemaker.FindPath(bee.currentTile, TileController.Instance.GetFinishHoneycomb()); if (path.Count == 0) { // No Path to finish found, get to target tile path = PathfinderBeemaker.FindPath(bee.currentTile, tile); } // // No path to target found. Be will not move. Check losing condition // if (path.Count == 0) // { // CheckNoOptionLeft(); // } bee.Navigate(path); }
public void Hello() { Honeycomb.Send(new Event() { Hello = "hi" }); }
/* ======================================================================================================================== */ /* PUBLIC FUNCTIONS */ /* ======================================================================================================================== */ // Play Start and Finish Tiles public void Setup() { // randomize selection honeycombs GameObject newSelectionHoneycomb = Instantiate(honeycombPrefab, tileSelectionTileMap.CellToWorld(new Vector3Int(6, 2, 0)), Quaternion.identity, availableHoneycombContainer); newSelectionHoneycomb.GetComponent<Honeycomb>().InitWalls(GetRandomEdgeDefinition()); newSelectionHoneycomb = Instantiate(honeycombPrefab, tileSelectionTileMap.CellToWorld(new Vector3Int(6, 0, 0)), Quaternion.identity, availableHoneycombContainer); newSelectionHoneycomb.GetComponent<Honeycomb>().InitWalls(GetRandomEdgeDefinition()); newSelectionHoneycomb = Instantiate(honeycombPrefab, tileSelectionTileMap.CellToWorld(new Vector3Int(6, -2, 0)), Quaternion.identity, availableHoneycombContainer); newSelectionHoneycomb.GetComponent<Honeycomb>().InitWalls(GetRandomEdgeDefinition()); selectedHoneycomb = null; var startGO = Instantiate(honeycombPrefab, playAreaTileMap.CellToWorld(new Vector3Int(0, -4, 0)), Quaternion.identity, honeycombContainer); startGO.name = "Start"; startHoneycomb = startGO.GetComponent<Honeycomb>(); startHoneycomb.SetStartWalls(); startHoneycomb.SetDoors(); startHoneycomb.UpdateWalls(); GameController.Instance.StartTilePlaced(startHoneycomb); var finishGO = Instantiate(honeycombPrefab, playAreaTileMap.CellToWorld(new Vector3Int(0, 4, 0)), Quaternion.identity, honeycombContainer); finishGO.name = "End"; finishHoneycomb = finishGO.GetComponent<Honeycomb>(); finishHoneycomb.SetFinishWalls(); finishHoneycomb.SetDoors(); finishHoneycomb.UpdateWalls(); finishGO.transform.Find("Honeycomb").GetComponent<SpriteRenderer>().sortingOrder = 10; }
void Destroy() { if (Honeycomb.instance == this) { Honeycomb.instance = null; } }
public static void Cell633() { TilingConfig config = new TilingConfig(6, 3, maxTiles: 20000); Tiling tiling = new Tiling(); tiling.GenerateInternal(config, Polytope.Projection.VertexCentered); double edgeLength = Honeycomb.EdgeLength(6, 3, 3); double z = 0.25; double offset = H3Models.UHS.ToEHorizontal(edgeLength, z); double scale = offset / tiling.Tiles.First().Boundary.Segments.First().Length; foreach (Tile tile in tiling.Tiles) { tile.Transform(Mobius.Scale(scale)); } Vector3D dummy; double radius; H3Models.UHS.Geodesic(new Vector3D(0, 0, z), new Vector3D(scale, 0, z), out dummy, out radius); Vector3D midradius = H3Models.UHSToBall(new Vector3D(0, 0, radius)); double temp = midradius.Z; double temp2 = (1 - temp) / 2; double temp3 = temp + temp2; double temp4 = temp3; Vector3D circumradius = H3Models.UHSToBall(new Vector3D(0, 0, z)); temp = circumradius.Z; temp2 = (1 - temp) / 2; temp3 = temp + temp2; temp4 = temp3; // Checking /* * Vector3D test = new Vector3D( offset, 0, z ); * test = H3Models.UHSToBall( test ); * double edgeLength2 = DonHatch.e2hNorm( test.Abs() ); * edgeLength2 += 0; */ HashSet <H3.Cell.Edge> edges = new HashSet <H3.Cell.Edge>(); foreach (Tile tile in tiling.Tiles) { foreach (Segment seg in tile.Boundary.Segments) { H3.Cell.Edge edge = new H3.Cell.Edge( H3Models.UHSToBall(seg.P1 + new Vector3D(0, 0, z)), H3Models.UHSToBall(seg.P2 + new Vector3D(0, 0, z))); edges.Add(edge); } } PovRay.WriteH3Edges(new PovRay.Parameters(), edges.ToArray(), "edges.pov"); }
private void SaveResults(Honeycomb <long> honeycomb) { var now = DateTime.Now; string filename = $"Hex19Results_{now:yyyyMMdd}_{now:HHmmss}.txt"; string folder = @"C:\Users\lotop_000\Documents\Quizzes"; string filepath = Path.Combine(folder, filename); honeycomb.Save(filepath); }
// Set the walls based on another honeycomb (selection) public void SetWalls(Honeycomb honeycomb) { walls = new bool[6]; walls = honeycomb.GetWalls(); for (int i = 0; i < walls.Length; i++) { wallSprites.GetChild(i).gameObject.SetActive(walls[i]); } }
public void MoveMilfs(Honeycomb beeCurrentTile) { Debug.Log($"Moving {spawnedMilfs.Count} milfs"); // Bee segment foreach (var milf in spawnedMilfs) { var path = PathfinderBeemaker.FindPath(milf.currentTile, beeCurrentTile); milf.Navigate(path); } }
public void TestWalk() { Honeycomb <long> honeycomb = CreateHex19(); int steps = 4; var walker = new Walker(honeycomb, steps); walker.Walk(); SaveResults(walker.Honeycomb); }
public void TestNorth() { Cell <bool> seed = Honeycomb <bool> .Create(true); Honeycomb <bool> bhc = seed.Honeycomb; Cell <bool> cell = bhc.AddNorth(seed, false); Assert.AreEqual(2, bhc.Count); Assert.AreEqual(cell, seed.North); Assert.AreEqual(seed, cell.South); }
private IEnumerator NavigateAsync(List <Honeycomb> path) { moving = true; if (path.Count >= minPathLengthForSound) { AudioController.Instance.PlaySound("BeeLoopSound"); } var startIndex = path.First() == originTile ? 1 : 0; currentTile = path[startIndex]; beeGfx.DOLocalMoveY(graphicsYOffset + hoverOffset, hoverTime); shadowGfx.DOScale(Vector3.one * shadowHoverScale, hoverTime); AudioController.Instance.TransitionToSnapshot("BeeSnapshot", hoverTime); yield return(new WaitForSeconds(hoverTime)); for (int i = startIndex; i < path.Count; i++) { if (!moving) // moving set to false if milfed by check in milf code { break; } var current = path[i]; currentTile = current; var milfed = GameController.Instance.CheckMilfedBee(); transform.DOLocalMove(current.transform.position - levitatingObjects.position, 1f / movementSpeed); yield return(new WaitForSeconds(1f / movementSpeed)); if (milfed || !moving) // moving set to false if milfed by check in milf code { break; } } beeGfx.DOLocalMoveY(graphicsYOffset, hoverTime); shadowGfx.DOScale(Vector3.one, hoverTime); AudioController.Instance.TransitionToSnapshot("SoundSnapshot", hoverTime); yield return(new WaitForSeconds(hoverTime)); AudioController.Instance.StopSound("BeeLoopSound"); originTile = targetTile; targetTile = null; moving = false; GameController.Instance.BeeFinishedNavigating(originTile); }
/// <summary> /// Call this to connect the end of the path to the given honeycomb. /// </summary> /// <param name="honeycomb">The honeycomb to connect the path to.</param> public void ConnectToHoneycomb(Honeycomb honeycomb) { // Make sure we have a valid path. if (Waypoints.Count > 0) { // Performing a cast to Vector2 as we are only interested in the (x, y) // coordinates of the honeycomb. Waypoints[Waypoints.Count - 1] = (Vector2)honeycomb.transform.position; // Keep a reference to our destination. destinationHoneycomb = honeycomb; // Update the line renderer colors to connected. lineRenderer.startColor = connectedColor; } }
internal static void CalcSelfSimilarityScale() { double inRadius = DonHatch.h2eNorm(Honeycomb.InRadius(4, 3, 7)); Vector3D facePoint = new Vector3D(0, 0, -inRadius); Sphere s = H3Models.Ball.OrthogonalSphereInterior(facePoint); Vector3D facePoint2 = new Vector3D(0, 0, inRadius); facePoint2 = s.ReflectPoint(facePoint2); facePoint = H3Models.BallToUHS(facePoint); facePoint2 = H3Models.BallToUHS(facePoint2); double scale = facePoint.Z / facePoint2.Z; scale += 0; }
public void Navigate(List <Honeycomb> path) { if (path.Count == 0) { GameController.Instance.CheckMilfedBee(); return; } if (activeNavigation != null) { StopCoroutine(activeNavigation); } targetTile = path.Last(); activeNavigation = StartCoroutine(NavigateAsync(path)); }
public void BeeFinishedNavigating(Honeycomb targetTile) { if (IsFinished == true) { return; } if (targetTile == TileController.Instance.GetFinishHoneycomb()) { LevelFinished(); } else { // Be has moved to new tile. Check loosing condition. CheckNoOptionLeft(); } }
private static List <Honeycomb> BuildListFromParentPath(Honeycomb end, Dictionary <Honeycomb, Honeycomb> parents) { var path = new List <Honeycomb>(); path.Add(end); var current = end; while (parents.ContainsKey(current)) { var parent = parents[current]; path.Add(parent); current = parent; } path.Reverse(); return(path); }
public override List <float> CollectState() { lives = lifeRankScore.lives; score = lifeRankScore.score; List <float> state = new List <float>(); rank.Equals(LevelManager.Instance.GetRank(score)); bSelf = transform; state.Add(transform.position.x); state.Add(transform.position.y); state.Add(score); state.Add(lives); targ = FindObjectsOfType <Honeycomb>(); foreach (Honeycomb h in targ) { if (h.open) { targActive = h; state.Add(targActive.transform.position.x); state.Add(targActive.transform.position.y); } if (transform.position.x != h.transform.position.x || transform.position.y != h.transform.position.y) { reward = -0.1f; } } GameObject[] Beez = GameObject.FindGameObjectsWithTag("Bee"); foreach (GameObject bee in Beez) { if (bee.activeSelf == true) { if (bee.transform.position.x - bSelf.position.x < 2.5 || bee.transform.position.y - bSelf.position.y < 2.5) { reward -= .1f; } } } return(state); }
private IEnumerator NavigateAsync(List <Honeycomb> path) { moving = true; var startIndex = path.First() == originTile ? 1 : 0; for (int i = startIndex; i < path.Count; i++) { var current = path[i]; transform.DOLocalMove(current.transform.position - levitatingObjects.position, 1f / movementSpeed); yield return(new WaitForSeconds(1f / movementSpeed)); currentTile = current; GameController.Instance.CheckMilfedBee(); } originTile = targetTile; targetTile = null; moving = false; }
static void Main(string[] args) { Console.Write("Creating honeycomb ..."); Honeycomb <long> honeycomb = ReadyHoneycombs.Hex19; Console.WriteLine(" done."); int steps; Console.Write("How many steps? "); string userSteps = Console.ReadLine(); bool numEnetered = int.TryParse(userSteps, out steps); while (!numEnetered) { Console.WriteLine("Not a number."); Console.Write("How many steps? "); userSteps = Console.ReadLine(); numEnetered = int.TryParse(userSteps, out steps); } Console.Write("Creating walker ..."); var walker = new Walker(honeycomb, steps); walker.CacheingData += PrintCacheingMessage; Console.WriteLine(" done."); Console.WriteLine($"Walking {steps} steps ..."); Cell <long> mostLikeley = walker.Walk(); Console.WriteLine(" done."); Console.WriteLine($"Most likely destination: {mostLikeley.Key}"); Console.WriteLine($"Number of hits: {mostLikeley.Data}"); Console.Write("Saving results ..."); string filepath = SaveResults(walker.Honeycomb); Console.WriteLine($" saved in {filepath}."); Console.ReadLine(); }
public static List <Honeycomb> FindPath(Honeycomb start, Honeycomb end, int maxSteps = 500) { if (start == null || end == null) { return(new List <Honeycomb>()); } var parents = new Dictionary <Honeycomb, Honeycomb>(); var q = new Queue <Honeycomb>(); var discovered = new HashSet <Honeycomb>(); discovered.Add(start); q.Enqueue(start); int steps = 1; while (steps < maxSteps && q.Count > 0) { var current = q.Dequeue(); if (current == end) { return(BuildListFromParentPath(current, parents)); } foreach (var next in current.GetConnectedHoneycombs()) { if (next != null && !discovered.Contains(next)) { discovered.Add(next); parents[next] = current; q.Enqueue(next); } } steps++; } // Not found or exceeded max Steps. Should not occur if tiles can only be placed "door on door" and are // therefore always connected. return(new List <Honeycomb>()); // DUMMY }
public static HashSet <Honeycomb> GetAllConnectedTiles(Honeycomb start) { var discovered = new HashSet <Honeycomb>(); var queue = new Queue <Honeycomb>(); queue.Enqueue(start); while (queue.Count > 0) { var tile = queue.Dequeue(); discovered.Add(tile); foreach (var connected in tile.GetConnectedHoneycombs()) { if (connected != null && !discovered.Contains(connected)) { queue.Enqueue(connected); } } } return(discovered); }
/// <summary> /// Call this to snap the end of a flight path to an opened honeycomb. This method would /// only perform the snapping if there is an opened honeycomb that is close enough. /// </summary> /// <param name="path">Flight path for a given bee.</param> public void SnapToHoneycomb(FlightPath path) { // Get the end point of the path. Vector2 current = path.GetLastPosition(); // Go through and find an open honeycomb that is close by the end point. foreach (GameObject honeycombObject in openHoneycombs) { Vector2 testPos = honeycombObject.transform.position; if (Vector2.Distance(current, testPos) < honeycombSize * 0.55f) { Honeycomb honeycomb = honeycombObject.GetComponent <Honeycomb>(); // Snap the path to the honeycomb. path.ConnectToHoneycomb(honeycomb); // Register this path with the honeycomb, this is so that we can update // the path's color if the honeycomb is closed before the bee reaches it. honeycomb.RegisterPath(path); break; } } }
public void Navigate(List <Honeycomb> path) { if (path.Count == 0) { return; } if (activeNavigation != null) { StopCoroutine(activeNavigation); } targetTile = path.FirstOrDefault(x => x != currentTile); if (targetTile == null) { return; } var singlePath = new List <Honeycomb>(1); singlePath.Add(targetTile); activeNavigation = StartCoroutine(NavigateAsync(singlePath)); }
public static H3.Cell.Edge[] OneHoneycombOrthoscheme(HoneycombDef def, int[] active, int baseHue, Settings settings = null) { // Setup parameters. int numEdges = 250000; if (settings != null) { active = settings.PovRay.Active; def = new HoneycombDef(settings.P, settings.Q, settings.R); numEdges = settings.PovRay.NumEdges; } CalcThickness(active); if (settings != null) { H3.m_settings.AngularThickness = settings.PovRay.EdgeWidth; // ZZZ - should really stop using that settings class. } string baseName = BaseName(def); string mirrorsString = ActiveMirrorsString(active); string suffix = "-" + mirrorsString; string fileName = baseName + suffix; if (ViewPath != null) { fileName += string.Format("_{0:D4}", ViewPath.Step); } if (File.Exists(fileName + ".pov")) { File.Delete(fileName + ".pov"); //Console.WriteLine( string.Format( "Skipping {0}", fileName ) ); //return; } Program.Log(string.Format("Building {0}", fileName)); // The wiki mirrors are labeled in the reverse of ours. Func <int, int> mapMirror = i => 3 - i; active = active.Select(i => mapMirror(i)).OrderBy(i => i).ToArray(); Simplex simplex = new Simplex(); simplex.Facets = SimplexCalcs.Mirrors(def.P, def.Q, def.R); simplex.Verts = SimplexCalcs.VertsBall(def.P, def.Q, def.R); Vector3D startingPoint = IterateToStartingPoint(def, active, simplex); if (startingPoint.DNE) { return(null); } List <H3.Cell.Edge> startingEdges = new List <H3.Cell.Edge>(); foreach (int a in active) { Vector3D reflected = simplex.ReflectInFacet(startingPoint, a); startingEdges.Add(new H3.Cell.Edge(startingPoint, reflected)); //startingEdges.Add( new H3.Cell.Edge( simplex.Verts[0], simplex.Verts[3] ) ); // Used for Borromean Rings complement image. } if (false) { Vector3D[] kv = simplex.Verts.Select(v => HyperbolicModels.PoincareToKlein(v)).ToArray(); kv[3] = SimplexCalcs.VertexPointKlein(def.P, def.Q, def.R); Vector3D t = (kv[3] - kv[0]) * 0.5; Sphere gSphere = H3Models.Ball.OrthogonalSphereInterior(HyperbolicModels.KleinToPoincare(t)); gSphere = H3Models.BallToKlein(gSphere); Vector3D t2 = Euclidean3D.IntersectionPlaneLine(gSphere.Normal, gSphere.Offset, kv[3] - kv[2], kv[2]); //t2 = kv[2] + ( kv[3] - kv[2]) * 0.5; t = HyperbolicModels.KleinToPoincare(t); t2 = HyperbolicModels.KleinToPoincare(t2); startingEdges.Add(new H3.Cell.Edge(t, t2)); startingEdges.Add(new H3.Cell.Edge(t, simplex.ReflectInFacet(t, 3))); } // If we are doing a view path, transform our geometry. if (ViewPath != null) { //Vector3D p = new Vector3D( 0, 0, .5 ); Vector3D p = new Vector3D(0.08, 0.12, 0.07); simplex.Facets = simplex.Facets.Select(f => H3Models.Transform_PointToOrigin(f, p)).ToArray(); simplex.Verts = simplex.Verts.Select(v => H3Models.Transform_PointToOrigin(v, p)).ToArray(); startingEdges = startingEdges.Select(e => new H3.Cell.Edge( H3Models.Transform_PointToOrigin(e.Start, p), H3Models.Transform_PointToOrigin(e.End, p))).ToList(); } SetupBaseHue(fileName, mirrorsString, baseHue); Recurse.m_background = baseHue == -1 ? new Vector3D() : new Vector3D(baseHue, 1, .1); H3.Cell.Edge[] edges = Recurse.CalcEdgesSmart2(simplex.Facets, startingEdges.ToArray(), numEdges); //H3.Cell.Edge[] edges = Recurse.CalcEdges( simplex.Facets, startingEdges.ToArray(), // new Recurse.Settings() { ThreshType = Recurse.EdgeThreshType.Radial, Threshold = H3Models.Ball.FindLocationForDesiredRadius( settings.PovRay.EdgeWidth, 0.8/100 ) } ); //edges = edges.Where( e => e.Depths[0] % 2 == 1 ).ToArray(); // Used for Borromean Rings complement image. // Shapeways truncated 436. if (false) { if (true) { Mobius m = Mobius.Scale(1.0 / H3Models.UHS.ToE(Honeycomb.InRadius(def.P, def.Q, def.R))); double a = -Math.PI / 2 + Math.Asin(1 / Math.Sqrt(3)); edges = edges.Select(e => { Vector3D v1 = e.Start; Vector3D v2 = e.End; v1.RotateAboutAxis(new Vector3D(1, 0, 0), a); v2.RotateAboutAxis(new Vector3D(1, 0, 0), a); v1 = H3Models.Ball.ApplyMobius(m, v1); v2 = H3Models.Ball.ApplyMobius(m, v2); return(new H3.Cell.Edge(v1, v2)); }).ToArray(); double thresh = -.01; Vector3D looking = new Vector3D(0, 0, -1); edges = edges.Where(e => e.Start.Dot(looking) > thresh && e.End.Dot(looking) > thresh).ToArray(); Dictionary <H3.Cell.Edge, int> edgeDict = edges.ToDictionary(e => e, e => 1); H3.RemoveDanglingEdgesRecursive(edgeDict); edges = edgeDict.Keys.ToArray(); } else { Mobius m = Mobius.Scale(2); edges = edges.Select(e => { Vector3D v1 = e.Start; Vector3D v2 = e.End; v1 = H3Models.Ball.ApplyMobius(m, v1); v2 = H3Models.Ball.ApplyMobius(m, v2); return(new H3.Cell.Edge(v1, v2)); }).ToArray(); Dictionary <H3.Cell.Edge, int> edgeDict = edges.ToDictionary(e => e, e => 1); H3.RemoveDanglingEdgesRecursive(edgeDict); edges = edgeDict.Keys.ToArray(); } } //H3.m_settings.Output = H3.Output.STL; //H3.m_settings.Scale = 50; H3.SaveToFile(fileName, edges, finite: true, append: true); bool doCells = false; H3.Cell[] cellsToHighlight = null; if (doCells) { int[] polyMirrors = new int[] { 1, 2, 3 }; active = active.Select(i => mapMirror(i)).OrderBy(i => i).ToArray(); H3.Cell startingCell = PolyhedronToHighlight(Geometry.Hyperbolic, polyMirrors, simplex, startingPoint); cellsToHighlight = Recurse.CalcCells(simplex.Facets, new H3.Cell[] { startingCell }); H3.AppendFacets(fileName, cellsToHighlight); } return(edges); }
// Update is called once per frame void Update() { if ((GameController.Instance.IsPaused == true) || (GameController.Instance.IsRunning == false) || (GameController.Instance.IsGameOver == true) || (GameController.Instance.IsFinished == true)) { return; } if (Input.GetMouseButtonDown(0) == true) { Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector3Int position = grid.WorldToCell(mouseWorldPos); // check if a free space on the play area was clicked and if a honeycomb is selected if (backgroundTileMap.HasTile(position) == true) { if (playAreaTileMap.HasTile(position) == false) { if (selectedHoneycomb != null) { var hc = PlaceTile(position, false); // get new randomized honeycomb and deselect it selectedHoneycomb.InitWalls(GetRandomEdgeDefinition()); selectedHoneycomb.Deselect(); selectedHoneycomb = null; GameController.Instance.TilePlaced(hc, false); ScoreController.Instance.IncrementTilesUsed(); } } } // check if a honeycomb from the selection is clicked and set the selected honeycomb if (tileSelectionTileMap.HasTile(position) == true) { string[] grabSounds = { "GrabSound1", "GrabSound2", "GrabSound3" }; AudioController.Instance.PlaySound(grabSounds[Random.Range(0, grabSounds.Length)]); if (selectedHoneycomb != null) { selectedHoneycomb.Deselect(); } foreach (Transform item in availableHoneycombContainer) { if (item.position == tileSelectionTileMap.CellToWorld(position) == true) { selectedHoneycomb = item.GetComponent<Honeycomb>(); selectedHoneycomb.Select(); } } } } }
// The student will complete this function as part of an activity private void checkCollisions() { // remove all dead sprites from their lists pruneList(beeShots); pruneList(smokeShots); pruneList(bees); pruneList(hiveSections); foreach (Sprite Bee in bees) { foreach (Sprite SmokeShot in smokeShots) { if (Bee.IsCollided(SmokeShot)) { Bee.IsAlive = false; SmokeShot.IsAlive = false; explosion.Play(1, 0, 0); } } } foreach (Sprite Honeycomb in hiveSections) { foreach (Sprite BeeShot in beeShots) { if (Honeycomb.IsCollided(BeeShot)) { Honeycomb.IsAlive = false; BeeShot.IsAlive = false; explosion.Play(1, 0, 0); } } foreach (Sprite SmokeShot in smokeShots) { if (Honeycomb.IsCollided(SmokeShot)) { Honeycomb.IsAlive = false; SmokeShot.IsAlive = false; explosion.Play(1, 0, 0); } } foreach (Sprite Bee in bees) { if (Honeycomb.IsCollided(Bee)) { Honeycomb.IsAlive = false; explosion.Play(1, 0, 0); } } } foreach (Sprite BeeShot in beeShots) { if (BeeShot.IsCollided(smokeSprayer)) { smokeSprayer.StartAnimationShort(1, 4, 4); int LoseNum = randomNumGen.Next(0, 2); if (LoseNum == 0) { stopGame(false, "That looked like it hurt..."); } if (LoseNum == 1) { stopGame(false, "Shall I get some vinegar?"); } if (LoseNum == 2) { stopGame(false, "Bees can have all your life!"); } explosion.Play(1, 0, 0); } } }
/// <summary> /// Call this to remove a honeycomb from the opened list. /// </summary> /// <param name="honeycomb">Honeycomb to be closed.</param> public void OnClose(Honeycomb honeycomb) { openHoneycombs.Remove(honeycomb.gameObject); }
public void Send() { Honeycomb.Send(this); }
public void TestHex19() { Cell <bool>[] tops; Cell <bool>[] bottoms; Honeycomb <bool> hex19 = CreateHex19(out tops, out bottoms); int count = 73; int top = 0; int bottom = -22; int left = -11; int right = 3; Assert.AreEqual(count, hex19.Count); Assert.AreEqual(top, hex19.Top); Assert.AreEqual(bottom, hex19.Bottom); Assert.AreEqual(left, hex19.Left); Assert.AreEqual(right, hex19.Right); Cell <bool> cell = hex19[-11, -13]; Assert.AreEqual(cell, bottoms[0]); Assert.AreEqual(cell, tops[0]); cell = hex19[-10, -12]; Assert.AreEqual(cell, bottoms[1]); cell = hex19[-10, -4]; Assert.AreEqual(cell, tops[1]); cell = hex19[-9, -11]; Assert.AreEqual(cell, bottoms[2]); cell = hex19[-9, -5]; Assert.AreEqual(cell, tops[2]); cell = hex19[-8, -12]; Assert.AreEqual(cell, bottoms[3]); cell = hex19[-8, -6]; Assert.AreEqual(cell, tops[3]); cell = hex19[-7, -13]; Assert.AreEqual(cell, bottoms[4]); cell = hex19[-7, -7]; Assert.AreEqual(cell, tops[4]); cell = hex19[-6, -12]; Assert.AreEqual(cell, bottoms[5]); cell = hex19[-6, -8]; Assert.AreEqual(cell, tops[5]); cell = hex19[-5, -13]; Assert.AreEqual(cell, bottoms[6]); cell = hex19[-5, -9]; Assert.AreEqual(cell, tops[6]); cell = hex19[-4, -14]; Assert.AreEqual(cell, bottoms[7]); cell = hex19[-4, -8]; Assert.AreEqual(cell, tops[7]); cell = hex19[-3, -21]; Assert.AreEqual(cell, bottoms[8]); cell = hex19[-3, -7]; Assert.AreEqual(cell, tops[8]); cell = hex19[-2, -22]; Assert.AreEqual(cell, bottoms[9]); cell = hex19[-2, -6]; Assert.AreEqual(cell, tops[9]); cell = hex19[-1, -21]; Assert.AreEqual(cell, bottoms[10]); cell = hex19[-1, -3]; Assert.AreEqual(cell, tops[10]); cell = hex19[0, -14]; Assert.AreEqual(cell, bottoms[11]); cell = hex19[0, 0]; Assert.AreEqual(cell, tops[11]); cell = hex19[1, -9]; Assert.AreEqual(cell, bottoms[12]); cell = hex19[1, -1]; Assert.AreEqual(cell, tops[12]); cell = hex19[2, -8]; Assert.AreEqual(cell, bottoms[13]); cell = hex19[2, 0]; Assert.AreEqual(cell, tops[13]); cell = hex19[3, -7]; Assert.AreEqual(cell, bottoms[14]); Assert.AreEqual(cell, tops[14]); }
private Honeycomb <bool> CreateHex19(out Cell <bool>[] tops, out Cell <bool>[] bottoms) { Cell <bool> seed = Honeycomb <bool> .Create(true); Honeycomb <bool> bhc = seed.Honeycomb; Cell <bool> cell; // 15 columns - col[0] -> col[14] // seed is top of col11 - tops[11] tops = new Cell <bool> [15]; bottoms = new Cell <bool> [15]; // create tops 1->13 starting from seed - tops[11] // tops 12->13 - going east from seed tops[11] = seed; // top of col 12 is SE of top of col 11 tops[12] = bhc.AddSouthEast(tops[11], false); // top of col 13 is NE of top of col 12 tops[13] = bhc.AddNorthEast(tops[12], false); // fill columns 11->13 - going south each time // col 11 - 8 cells, need to create 7 more cell = bhc.AddSouth(tops[11], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[11] = cell; // col 12 - 5 cells, need to create 4 more cell = bhc.AddSouth(tops[12], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[12] = cell; // col 13 - 5 cells, need to create 4 more cell = bhc.AddSouth(tops[13], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[13] = cell; // col 14 is one cell to the NE of the bottom of col 13 tops[14] = bhc.AddNorthEast(bottoms[13], false); bottoms[14] = tops[14]; // tops 10->1 going west from seed - tops[11] // top of col 10 is S then SW of top of col 11 tops[10] = bhc.AddSouthWest(tops[11].South, false); // col 10 - 10 cells, need to add 9 more cell = bhc.AddSouth(tops[10], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[10] = cell; // top of col 9 is S then SW of top of col 10 tops[9] = bhc.AddSouthWest(tops[10].South, false); // col 9 - 9 cells, need to add 8 more cell = bhc.AddSouth(tops[9], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[9] = cell; // top of col 8 is SW of top of col 9 tops[8] = bhc.AddSouthWest(tops[9], false); // col 8 - 8 cells, need to add 7 more cell = bhc.AddSouth(tops[8], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[8] = cell; // top of col 7 is SW of top of col 8 tops[7] = bhc.AddSouthWest(tops[8], false); // col 7 - 4 cells, need to add 3 more cell = bhc.AddSouth(tops[7], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[7] = cell; // top of col 6 is SW of top of col 7 tops[6] = bhc.AddSouthWest(tops[7], false); // col 6 - 3 cells, need to add 2 more cell = bhc.AddSouth(tops[6], false); cell = bhc.AddSouth(cell, false); bottoms[6] = cell; // top of col 5 is NW of top of col 6 tops[5] = bhc.AddNorthWest(tops[6], false); // col 5 - 3 cells, need to add 2 more cell = bhc.AddSouth(tops[5], false); cell = bhc.AddSouth(cell, false); bottoms[5] = cell; // top of col 4 is NW of top of col 5 tops[4] = bhc.AddNorthWest(tops[5], false); // col 4 - 4 cells, need to add 3 more cell = bhc.AddSouth(tops[4], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[4] = cell; // top of col 3 is NW of top of col 4 tops[3] = bhc.AddNorthWest(tops[4], false); // col 3 - 4 cells, need to add 3 more cell = bhc.AddSouth(tops[3], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[3] = cell; // top of col 2 is NW of top of col 3 tops[2] = bhc.AddNorthWest(tops[3], false); // col 2 - 4 cells, need to add 3 more cell = bhc.AddSouth(tops[2], false); cell = bhc.AddSouth(cell, false); cell = bhc.AddSouth(cell, false); bottoms[2] = cell; // top of col 1 is NW of top of col 2 tops[1] = bhc.AddNorthWest(tops[2], false); // col 1 - 4 cells, need to add 3 more and mind the gap in the middle cell = bhc.AddSouth(tops[1], false); // gap! // bottom of col 1 is SW of bottom of col 2 bottoms[1] = bhc.AddSouthWest(bottoms[2], false); cell = bhc.AddNorth(bottoms[1], false); // col 0 is one cell SW of bottom of col 1 tops[0] = bhc.AddSouthWest(bottoms[1], false); bottoms[0] = tops[0]; return(bhc); }