Beispiel #1
0
        //----------------------------------------------------------------------------
        //           UpdateHexNeighbours
        //----------------------------------------------------------------------------

        #region UpdateHexNeighbours

        /// <summary>
        /// After all hexes have been instantiated and validated
        /// check in each direction for a valid neighbour
        /// </summary>
        public void UpdateHexNeighbours()
        {
            List <Vector3Int> directions = GetDirections();

            foreach (KeyValuePair <Vector3Int, IHexagon> hex in HexDict)
            {
                HashSet <IHexagon> neighbours = new HashSet <IHexagon>();
                foreach (Vector3Int direction in directions)
                {
                    Vector3Int neighbourCoords = hex.Value.MyHexMap.CoOrds + direction;

                    if (HexDict.ContainsKey(neighbourCoords))
                    {
                        neighbours.Add(HexDict[neighbourCoords]);
                    }
                }
                ((IHexagonRestricted)hex.Value).MyHexMapRestricted.SetNeighbours(neighbours);
            }
        }