Пример #1
0
    /// <summary>
    /// The function that responds to the Hexgonal button click event
    /// Checks the width and height of the maze appropriate or not
    /// Loads the scene of the hexagonal-grid maze environment
    /// </summary>
    public void startHexagonalGrid()
    {
        //TODO
        //Load the scene of the hexagonal-grid maze
        //createHexTileMap();
        bool widthValid  = mapWidth >= 8 && mapWidth <= 13;
        bool heightValid = mapHeight >= 8 && mapHeight <= 13;

        if (!(widthValid && heightValid))
        {
            Debug.LogError("Inappropriate width or height");
            return;
        }
        HexGridGenerator.setInstance(instance);
        SceneManager.LoadScene(1);
    }
Пример #2
0
    public List <Node> GetNeighbours()
    {
        if (!open)
        {
            return(new List <Node>());
        }
        neighbours = new List <Node>();
        HexGridGenerator gen = GameObject.FindWithTag("Generator").GetComponent <HexGridGenerator>();

        // Check left sides
        if (gridPosition.x - 1 >= 0)
        {
            if (gridPosition.y - 1 + offset >= 0)
            {
                neighbours.Add(HexGridGenerator.nodes[gridPosition.x - 1][gridPosition.y - 1 + offset]);
            }
            if (gridPosition.y < gen.size - offset)
            {
                neighbours.Add(HexGridGenerator.nodes[gridPosition.x - 1][gridPosition.y + offset]);
            }
        }
        // Check top and bottom sides
        if (gridPosition.x >= 0)
        {
            if (gridPosition.y - 1 >= 0)
            {
                neighbours.Add(HexGridGenerator.nodes[gridPosition.x][gridPosition.y - 1]);
            }
            if (gridPosition.y + 1 < gen.size)
            {
                neighbours.Add(HexGridGenerator.nodes[gridPosition.x][gridPosition.y + 1]);
            }
        }
        // Check right sides
        if (gridPosition.x + 1 < gen.size)
        {
            if (gridPosition.y - 1 + offset >= 0)
            {
                neighbours.Add(HexGridGenerator.nodes[gridPosition.x + 1][gridPosition.y - 1 + offset]);
            }
            if (gridPosition.y < gen.size - offset)
            {
                neighbours.Add(HexGridGenerator.nodes[gridPosition.x + 1][gridPosition.y + offset]);
            }
        }
        return(neighbours);
    }
Пример #3
0
        public void Awake()
        {
            this.overworldGameState = OverworldState.PLANNING;

            // Delegate control of map loading to the OverworldManager.
            List <HexMapCsv> file = null;

            // Load the default map
            if (string.IsNullOrEmpty(hexGrid.mapToLoad))
            {
                HexGridGenerator.GenerateDefault(hexGrid, hexGrid.width, hexGrid.height);
            }
            // Load from file
            else
            {
                file = HexMapFileSaver.ReadFile(hexGrid.mapToLoad);
                HexGridGenerator.GenerateFromFile(hexGrid, file);
            }

            this.monsterManager.SetInitialSpawn(this.hexGrid, file);

            OverworldEventManager.Instance().onHexTileClicked += ProcessTileSelection;
        }