Exemple #1
0
        public Dome AddDome(TerrainHex loc)
        {
            if (loc == null)
            {
                throw new System.Exception("Attempt to add dome with no location");
            }
//						Debug.Log ("Game addDome");
            return(Domes.AddDome(loc));
        }
        int Distance(TerrainHex terrainHex)
        {
            if (terrainHex == null)
            {
                throw new System.ArgumentNullException("terrainHex");
            }
            float distance = ((terrainHex.transform.position - transform.position).magnitude);

            // Debug.Log (string.Format ("Distance between {0} and {1} is {2}", ToString (), terrainHex.ToString (), distance / RADIUS));
            return(Mathf.RoundToInt(distance / RADIUS));
        }
Exemple #3
0
        void AddHex(int i, int j)
        {
            int height = (int)Random.Range(0, Heights);
            //Debug.Log (string.Format ("Terrain Adding Hex ({0}, {1}); height = {2} ({3} .. {4})", i, j, height, 0, Heights));
            GameObject newHex = (GameObject)Instantiate(Hex);
            TerrainHex hex    = newHex.GetComponent <TerrainHex> ();

            hex.Index       = new Vector3(i, height, j);
            hex.InTerrain   = this;
            hex.Initialized = true;

            newHex.transform.SetParent(transform, true);

            Hexes [i + Rows, j + Cols] = hex;
        }
Exemple #4
0
        public Dome AddDome(TerrainHex location)
        {
            foreach (Dome oldDome in this)
            {
                if (oldDome.Location == location)
                {
                    Debug.Log("Attempting to create two domes at the same location");
                    return(null);
                }
            }

            Dome dome = new Dome(location);

            Add(dome);
            return(dome);
        }
Exemple #5
0
        public bool IsAdjcentTo(TerrainHex targetHex)
        {
            if (targetHex == null)
            {
                return(false);
            }
            if (Location == null)
            {
                return(false);
            }

            foreach (TerrainHex hex in Location.Neighbors)
            {
                if (hex == targetHex)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #6
0
 public Dome(TerrainHex terrainHex) : base()
 {
     Init();
     Location = terrainHex;
 }