Beispiel #1
0
 private void Validate_Zone(ZoneProfile zone)
 {
     if (!Zones.Contains(zone))
     {
         throw new BrandonException($"The {nameof(ZoneProfile)} {zone} is not in the {nameof(BenthicProfile)} {this}!");
     }
 }
Beispiel #2
0
        public Vector2 GetZoneGeographicAltitudeBoundaries(ZoneProfile zoneProfile)
        {
            var zoneStart = 0 - Zones.TakeWhile(it => it != zoneProfile).Sum(it => it.Amplitude);
            var zoneEnd   = zoneStart - zoneProfile.Amplitude;

            return(new Vector2(zoneStart, zoneEnd));
        }
Beispiel #3
0
        public Vector2 GetZoneGeographicDistanceBoundaries(ZoneProfile zoneProfile)
        {
            var min = Zones.TakeWhile(it => it != zoneProfile).Sum(it => it.GeographicDistance);
            var max = min + zoneProfile.GeographicDistance;

            return(new Vector2(min, max));
        }
Beispiel #4
0
 public ZonePoint ZonePointOf(ZoneProfile zoneProfile, float zoneDist01, float zoneBreadth01)
 {
     return(new ZonePoint(CoastlineTerrain, BuildBenthicProfile(), zoneProfile)
     {
         Distance = zoneDist01,
         Breadth = zoneBreadth01
     });
 }
Beispiel #5
0
        public void PlantFakeTree(ZoneProfile zoneProfile, GameObject tree, Spacey.IWorldly treePoint, float treeScale)
        {
            var treeRandomizedRotation = Quaternion.AngleAxis(Random.Range(0, 360), Vector3.up);
            var treeRot      = TerrainCaster.SampleRotation(treePoint, CoastlineTerrain) * treeRandomizedRotation;
            var treeInstance = Instantiate(tree, treePoint.Worldly, treeRot, GetZoneTreeHolder(zoneProfile));

            treeInstance.transform.localScale = Vector3.one * treeScale;
        }
Beispiel #6
0
        /// <summary>
        /// goes from <see cref="DimensionSpace.Benthic"/> -> <see cref="DimensionSpace.Zone"/>
        /// </summary>
        /// <param name="geographicDistance"></param>
        /// <param name="zone"></param>
        /// <returns></returns>
        public float FindPointInZone(float geographicDistance, ZoneProfile zone)
        {
            Validate_GeographicDistance(geographicDistance);

            var zoneBounds = GetZoneGeographicDistanceBoundaries(zone);

            return(GetPortion(geographicDistance, zoneBounds));
        }
Beispiel #7
0
        private Holder GetZoneTreeHolder(ZoneProfile zoneProfile)
        {
            if (!ZoneTreeHolders.ContainsKey(zoneProfile))
            {
                ZoneTreeHolders.Add(zoneProfile, new Holder(zoneProfile.ToString(), TreeHolder));
            }

            return(ZoneTreeHolders[zoneProfile]);
        }
Beispiel #8
0
        public ZoneProfile FindRelativeZone(ZoneProfile currentZone, int offset)
        {
            var zoneIndex   = Zones.IndexOf(currentZone);
            var offsetIndex = zoneIndex + offset;

            if (offsetIndex < 0 || offsetIndex >= Zones.Count)
            {
                return(null);
            }

            return(Zones[offsetIndex]);
        }
Beispiel #9
0
 public ZonePoint(Terrain worldTerrain, BenthicProfile benthicProfile, ZoneProfile zoneProfile)
 {
     this.WorldTerrain   = worldTerrain;
     this.BenthicProfile = benthicProfile;
     this.ZoneProfile    = zoneProfile;
 }
Beispiel #10
0
 public void AddZone(ZoneProfile zoneProfile)
 {
     _zones.Add(zoneProfile);
     _zones.Sort();
 }
Beispiel #11
0
 private bool IsGeographicDistanceInZone(float geographicDistance, ZoneProfile zone)
 {
     return(IsPointInRange(geographicDistance, GetZoneGeographicDistanceBoundaries(zone)));
 }
Beispiel #12
0
        private float ZoneHeightToGeographicAltitude(ZoneProfile zone, float heightInZone)
        {
            var altitudeBoundaries = Sorted(GetZoneGeographicAltitudeBoundaries(zone));

            return(Mathf.Lerp(altitudeBoundaries.x, altitudeBoundaries.y, heightInZone));
        }