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; } } } }
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); } }
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; }
public void AttachStart(Ridge ridge) { if (!AllRidges.Contains(ridge)) { AllRidges.Add(ridge); ridge.Start = this; } }
public void DetachStart(Ridge ridge) { if (AllRidges.Contains(ridge)) { AllRidges.Remove(ridge); if (ridge.Start == this) ridge.Start = null; } }
public void DetachStart(Ridge ridge) { if (AllRidges.Contains(ridge)) { AllRidges.Remove(ridge); if (ridge.Start == this) { ridge.Start = null; } } }
public void AddEdge(Edge AddedEdge) { foreach (Edge edge in Ridge) { if (AddedEdge == edge) { return; } } Ridge.Add(AddedEdge); }
[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")); }
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); }
Ridge(Ridge reversed) { Reversed = reversed; Points = new ReversedList<Point>(reversed.Points); }
public Ridge() { Points = new CircularArray<Point>(); Reversed = new Ridge(this); }
Ridge(Ridge reversed) { Reversed = reversed; Points = new ReversedList <Point>(reversed.Points); }
public Ridge() { Points = new CircularArray <Point>(); Reversed = new Ridge(this); }