private GameObject[] tileObjects;                                            // this will contain all the GameObjects for visualisation purposes, their array index corresponds with the index of our Tiles


        void Start()
        {
            hexMap   = new HexMap <int, bool>(HexMapBuilder.CreateRectangularShapedMap(mapSize), null); //creates a HexMap using one of the pre-defined shapes in the static MapBuilder Class
            hexMouse = gameObject.AddComponent <HexMouse>();                                            //we attach the HexMouse script to the same gameObject this script is attached to, could also attach it anywhere else
            hexMouse.Init(hexMap);                                                                      //initializes the HexMouse
            tileObjects = new GameObject[hexMap.TilesByPosition.Count];                                 //creates an array with the size equal to the number on tiles of the map

            foreach (var tile in hexMap.Tiles)                                                          //loops through all the tiles, assigns them a random value and instantiates and positions a gameObject for each of them.
            {
                tile.Data = (Random.Range(0, 4));
                GameObject instance = GameObject.Instantiate(tilePrefab);
                instance.GetComponent <Renderer>().material = materials[tile.Data];
                instance.name = "MapTile_" + tile.Position;
                instance.transform.position = tile.CartesianPosition;
                tileObjects[tile.Index]     = instance;
            }

            foreach (var edge in hexMap.Edges) //we randomly spawn a GameObject on some corners (could be representing walls or rivers or anything else)
            {
                int randomNumber = Random.Range(0, 100);
                if (randomNumber > 89)
                {
                    edge.Data = true;
                    GameObject instance = GameObject.Instantiate(edgePrefab);
                    instance.name = "MapEdge_" + edge.Position;
                    instance.transform.position = edge.CartesianPosition;
                    instance.transform.rotation = Quaternion.Euler(0, edge.EdgeAlignmentAngle, 0);
                    //as we don't change the edges during runtime we don't need to add the gameObjects of the edges to an array as we don't need to manipulate them later on
                }
            }

            SetupCamera(); //set camera settings so that the map is captured by it
        }
예제 #2
0
        void Start()
        {
            hexMap   = new HexMap <int, bool, bool>(HexMapBuilder.CreateRectangularShapedMapOddRowsOneShorter(mapSize), null);
            hexMouse = gameObject.AddComponent <HexMouse>();
            hexMouse.Init(hexMap);

            InitMap();
            SetupCamera();
        }
        private List <GameObject> visionMarkers;                     //we will use this to display the border of the vision range

        void Start()
        {
            hexMap   = new HexMap <int>(HexMapBuilder.CreateHexagonalShapedMap(mapRadius), null); //creates a HexMap using one of the pre-defined shapes in the static MapBuilder Class
            hexMouse = gameObject.AddComponent <HexMouse>();                                      //we attach the HexMouse script to the same gameObject this script is attached to, could also attach it anywhere else
            hexMouse.Init(hexMap);                                                                //initializes the HexMouse

            InitMap();
            SetupCamera(); //set camera settings so that the map is captured by it
        }
예제 #4
0
        private List <GameObject> reachableTilesMarkers; // the gameObjects we use to visualise which tiles are within movementRange

        void Start()
        {
            hexMap   = new HexMap <MyTile, MyEdge>(HexMapBuilder.CreateRectangularShapedMapOddRowsOneShorter(mapSize), null);
            hexMouse = gameObject.AddComponent <HexMouse>();
            hexMouse.Init(hexMap);

            InitMap();
            reachableTilesMarkers = new List <GameObject>();
            SetupCamera();
        }
예제 #5
0
    void Start()
    {
        hexMap      = new HexMap(HexMapBuilder.CreateRectangularShapedMap(mapSize), null);
        tiles       = new TileData[hexMap.TileCount];
        tileObjects = new GameObject[hexMap.TileCount];

        hexMouse = gameObject.AddComponent <HexMouse>();
        hexMouse.Init(hexMap);
        SetupCamera();
        InitMapData();
        InitMapVisualisation();
    }
    // Start is called before the first frame update
    void Start()
    {
        lineMarkers = new List <GameObject>();
        MakeTerrainHashtable();

        MakeHexMap();

        hexMouse = GetComponent <HexMouse>();
        hexMouse.Init(hexMap);


        AdjustCameraToFit();
    }
예제 #7
0
    protected void Init()
    {
        MakeHexMap();

        HexMouse = GetComponent <HexMouse>();

        if (HexMouse == null)
        {
            HexMouse = gameObject.AddComponent <HexMouse>();
        }

        HexMouse.Init(HexMap);

        builtObjectsByPosition = new Dictionary <Vector3Int, List <GameObject> >();
        builtObjects           = new List <GameObject>();
    }