Ejemplo n.º 1
0
        protected virtual void GenerateRidge(Ridge ridge, Area area, EcsManager ecs, Random random)
        {
            var landscape = ecs.GetContainer <Landscape>();
            var building  = ecs.GetContainer <Building>();

            var delta = ridge.To - ridge.From;

            for (var px = Math.Max(0, Math.Min(ridge.From.X, ridge.To.X) - ridge.Width);
                 px < Math.Min(area.Size.X - 1, Math.Max(ridge.From.X, ridge.To.X) + ridge.Width);
                 px++)
            {
                for (var py = Math.Max(0, Math.Min(ridge.From.Y, ridge.To.Y) - ridge.Width);
                     py < Math.Min(area.Size.Y - 1, Math.Max(ridge.From.Y, ridge.To.Y) + ridge.Width);
                     py++)
                {
                    var position = new Vector(px, py);

                    var internalPosition = delta.TransitionMatrix() * (2 * position - ridge.From - ridge.To).ToMatrix() / 2;

                    var x = internalPosition[0, 0];
                    var y = internalPosition[1, 0] * delta.Magnitude / ridge.Width * 2;

                    if (random.Chance(
                            2 * (1 - Math.Sqrt(x * x + y * y))))
                    {
                        area.ContainerSlice <Landscape>()[position] = landscape.Plain;
                        area.ContainerSlice <Building>()[position]  = building.Mountain;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void CreateRidgesFromHexes()
 {
     while (this.ridgesHexes.Count > 0)
     {
         Ridge ridge = new Ridge();
         ridge.Hexes.Add(this.ridgesHexes[0]);
         this.ridgesHexes.RemoveAt(0);
         Queue <HexPos> queue = new Queue <HexPos>();
         queue.Enqueue(ridge.Hexes[0]);
         while (queue.Count > 0)
         {
             HexPos pos = queue.Dequeue();
             foreach (HexPos item in base.Context.Grid.Adjacents(pos))
             {
                 int num = this.tmxPointOfInterestLayer.Data[item.Row, item.Column];
                 if (num != 0 && base.Context.Settings.TmxMap.GetTileProperty(num, ImportTmxPointOfInterestLayer.poiTypeNameProperty) == "Ridge" && !ridge.Hexes.Contains(item))
                 {
                     ridge.Hexes.Add(item);
                     this.ridgesHexes.Remove(item);
                     queue.Enqueue(item);
                 }
             }
         }
         base.Context.Ridges.Add(ridge);
     }
 }
Ejemplo n.º 3
0
        public object Clone()
        {
            SkeletonBuilder clone = new SkeletonBuilder();

            Dictionary<Minutia, Minutia> minutiaClones = new Dictionary<Minutia, Minutia>();
            foreach (Minutia minutia in AllMinutiae)
            {
                Minutia minutiaClone = new Minutia(minutia.Position);
                minutiaClone.Valid = minutia.Valid;
                clone.AddMinutia(minutiaClone);
                minutiaClones[minutia] = minutiaClone;
            }

            Dictionary<Ridge, Ridge> ridgeClones = new Dictionary<Ridge, Ridge>();
            foreach (Minutia minutia in AllMinutiae)
            {
                foreach (Ridge ridge in minutia.Ridges)
                {
                    if (!ridgeClones.ContainsKey(ridge))
                    {
                        Ridge ridgeClone = new Ridge();
                        ridgeClone.Start = minutiaClones[ridge.Start];
                        ridgeClone.End = minutiaClones[ridge.End];
                        foreach (Point point in ridge.Points)
                            ridgeClone.Points.Add(point);
                        ridgeClones[ridge] = ridgeClone;
                        ridgeClones[ridge.Reversed] = ridgeClone.Reversed;
                    }
                }
            }
            return clone;
        }
Ejemplo n.º 4
0
 public void AttachStart(Ridge ridge)
 {
     if (!AllRidges.Contains(ridge))
     {
         AllRidges.Add(ridge);
         ridge.Start = this;
     }
 }
Ejemplo n.º 5
0
 public void AttachStart(Ridge ridge)
 {
     if (!AllRidges.Contains(ridge))
     {
         AllRidges.Add(ridge);
         ridge.Start = this;
     }
 }
Ejemplo n.º 6
0
 public void DetachStart(Ridge ridge)
 {
     if (AllRidges.Contains(ridge))
     {
         AllRidges.Remove(ridge);
         if (ridge.Start == this)
             ridge.Start = null;
     }
 }
Ejemplo n.º 7
0
 public void DetachStart(Ridge ridge)
 {
     if (AllRidges.Contains(ridge))
     {
         AllRidges.Remove(ridge);
         if (ridge.Start == this)
         {
             ridge.Start = null;
         }
     }
 }
Ejemplo n.º 8
0
 public void AddEdge(Edge AddedEdge)
 {
     foreach (Edge edge in Ridge)
     {
         if (AddedEdge == edge)
         {
             return;
         }
     }
     Ridge.Add(AddedEdge);
 }
Ejemplo n.º 9
0
        [HttpPost] public ActionResult CreateRidge(int fetuse, int ground, int scenario)
        {
            ViewBag.LogStatus = CurrentAccount.LogStatus;
            Random rand      = new Random();
            var    new_ridge = new Ridge();

            new_ridge.idRidge      = ctx.Ridges.OrderByDescending(i => i.idRidge).First().idRidge + 1;
            new_ridge.Owner_idUser = CurrentAccount.user.idUser;
            new_ridge.Auto         = 1;
            new_ridge.GroundType   = ground;
            new_ridge.FetuseType   = fetuse;
            new_ridge.idScenario   = scenario;
            new_ridge.Humidity     = ctx.Grounds.Find(ground).HumDefault;
            new_ridge.Luminescence = 20000 + rand.Next(6000);
            new_ridge.Temperature  = 21 + rand.Next(6);

            var red_lamp = new Lapm();

            red_lamp.idLamp   = ctx.Lapms.OrderByDescending(i => i.idLamp).First().idLamp + 1;
            red_lamp.Efficacy = 150;
            red_lamp.Name     = "Натрієва лампа високого тиску";
            red_lamp.Spectre  = "Червоний";
            red_lamp.Toggle   = 1;
            red_lamp.idRidge  = new_ridge.idRidge;

            var blue_lamp = new Lapm();

            blue_lamp.idLamp   = ctx.Lapms.OrderByDescending(i => i.idLamp).First().idLamp + 2;
            blue_lamp.Efficacy = 80;
            blue_lamp.Name     = "Люмінісцентна лампа";
            blue_lamp.Spectre  = "Синій";
            blue_lamp.Toggle   = 0;
            blue_lamp.idRidge  = new_ridge.idRidge;

            ctx.Ridges.Add(new_ridge);
            ctx.Lapms.Add(red_lamp);
            ctx.Lapms.Add(blue_lamp);

            ctx.SaveChanges();

            return(RedirectToAction("Ridges"));
        }
Ejemplo n.º 10
0
        public object Clone()
        {
            SkeletonBuilder clone = new SkeletonBuilder();

            Dictionary <Minutia, Minutia> minutiaClones = new Dictionary <Minutia, Minutia>();

            foreach (Minutia minutia in AllMinutiae)
            {
                Minutia minutiaClone = new Minutia(minutia.Position);
                minutiaClone.Valid = minutia.Valid;
                clone.AddMinutia(minutiaClone);
                minutiaClones[minutia] = minutiaClone;
            }

            Dictionary <Ridge, Ridge> ridgeClones = new Dictionary <Ridge, Ridge>();

            foreach (Minutia minutia in AllMinutiae)
            {
                foreach (Ridge ridge in minutia.Ridges)
                {
                    if (!ridgeClones.ContainsKey(ridge))
                    {
                        Ridge ridgeClone = new Ridge();
                        ridgeClone.Start = minutiaClones[ridge.Start];
                        ridgeClone.End   = minutiaClones[ridge.End];
                        foreach (Point point in ridge.Points)
                        {
                            ridgeClone.Points.Add(point);
                        }
                        ridgeClones[ridge]          = ridgeClone;
                        ridgeClones[ridge.Reversed] = ridgeClone.Reversed;
                    }
                }
            }

            return(clone);
        }
Ejemplo n.º 11
0
 Ridge(Ridge reversed)
 {
     Reversed = reversed;
     Points = new ReversedList<Point>(reversed.Points);
 }
Ejemplo n.º 12
0
 public Ridge()
 {
     Points = new CircularArray<Point>();
     Reversed = new Ridge(this);
 }
Ejemplo n.º 13
0
 Ridge(Ridge reversed)
 {
     Reversed = reversed;
     Points   = new ReversedList <Point>(reversed.Points);
 }
Ejemplo n.º 14
0
 public Ridge()
 {
     Points   = new CircularArray <Point>();
     Reversed = new Ridge(this);
 }