Example #1
0
    private void SetAdjacentIslands()
    {
        adjacentIslands.Clear();
        Vector3 position = armyMarker.transform.localPosition;

        foreach (Island island in islands)
        {
            float distance = Vector2.Distance(island.transform.localPosition, position);
            if (Mathf.Abs(distance) == 2)
            {
                Bridge bridge = FindBridge(currentIsland, island);
                if (bridge != null)
                {
                    adjacentIslands.Add(island);
                    island.IsAdjacent(true);
                }
                else
                {
                    island.IsAdjacent(false);
                }
            }
            else
            {
                island.IsAdjacent(false);
            }
        }

        if (adjacentIslands.Count == 0)
        {
            mapUI.ShowGameOver("Dead end");
            playerControl = false;
        }
    }