private bool CheckNoOptionLeft() { //Check if target segment is reachable var finishSegment = PathfinderBeemaker.GetAllConnectedTiles(TileController.Instance.GetFinishHoneycomb()); var beeIsInFinishSegment = finishSegment.Contains(bee.currentTile); // Bee is moving if (!beeIsInFinishSegment) { var isAnyOpenInFinishSegment = finishSegment.Any(t => t.HasAnyDoor()); if (!isAnyOpenInFinishSegment) { StartCoroutine( GameOverWithAnItsyBitsyTeenyWeenyNoImmediateDeathMachiney(GameOverReason.TargetPathBlocked)); return(false); } } // Check if there if the segment the bee is on has at least one open connection var flood = PathfinderBeemaker.GetAllConnectedTiles(bee.currentTile); var isAnyOpen = flood.Any(t => t.HasAnyDoor()); if (!isAnyOpen) { StartCoroutine( GameOverWithAnItsyBitsyTeenyWeenyNoImmediateDeathMachiney(GameOverReason.BeePathBlocked)); return(false); } return(true); }
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 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 override void OnInspectorGUI() { var bee = target as Bee; DrawDefaultInspector(); if (GUILayout.Button("Check Connected Tiles")) { var flood = PathfinderBeemaker.GetAllConnectedTiles(bee.currentTile); IsAnyOpen = flood.Any(t => t.HasAnyDoor()); Debug.Log(string.Join(",", flood.Select(x => x.number))); Debug.Log(IsAnyOpen); } }
public override void OnInspectorGUI() { var test = target as PathfinderTest; DrawDefaultInspector(); if (GUILayout.Button("FindPath")) //10 { Debug.Log(test.from?.number + " to " + test.to?.number); var path = PathfinderBeemaker.FindPath(test.from, test.to); if (path.Count == 0) { Debug.Log("No Path found"); } else { var str = string.Join("-", path.Select(x => x.number)); Debug.Log(str); } } }