Exemplo n.º 1
0
        private void _InstantiateHexagon(Vector3Int coords)
        {
            Vector3 worldSpacePos = HexMath.HexCoordsToWorldSpace(coords);

            GameObject HexagonGO = Instantiate(HexagonPrefab, worldSpacePos, Quaternion.identity, gameObject.transform);

            HexagonGO.name = "Hex " + coords.ToString();

            Hexagon hexagon = HexagonGO.AddComponent <Hexagon>();

            hexagon.Initialise(coords, 1);

            HexDict.Add(coords, hexagon);
        }
Exemplo n.º 2
0
        //----------------------------------------------------------------------------
        //           ConnectContentsToHex
        //----------------------------------------------------------------------------

        #region ConnectContentsToHex

        /// <summary>
        /// Initialise the IHexContents subsystem <para />
        /// This allows objects/map to interact
        /// </summary>
        public void ConnectContentsToHex()
        {
            IContentMarker[] hexContentMarkers = GameObject.FindObjectsOfType <IContentMarker>();
            foreach (IContentMarker hexContentMarker in hexContentMarkers)
            {
                GameObject go       = hexContentMarker.gameObject;
                IContents  contents = go.GetComponent <IContents>();

                //object told about hex
                contents.Location = HexDict[HexMath.CalculateHexCoords(contents.ContentTransform.position)];
                //hex told about object
                contents.Location.Contents = contents;

                //Move the object to the centre of the hex
                contents.ContentTransform.position = HexMath.HexCoordsToWorldSpace(contents.Location.MyHexMap.CoOrds);
                contents.Initialise();
            }
        }