public void IsPointInPolygonTest2(double x, double y, bool outcome) { var testPoint = new Point2D(x, y); var testPoly = this.TestPolygon4(); Assert.AreEqual(outcome, Polygon2D.IsPointInPolygon(testPoint, testPoly)); }
public void CountOfPositionInMatrix_SholudBe_EqualEcept_XYZ() { Point2D<int> point1 = new Point2D<int>(1, 0); Point2D<int> point2 = new Point2D<int>(2, 0); Point2D<int> point3 = new Point2D<int>(3, 0); Point2D<int> point4 = new Point2D<int>(4, 0); Point2D<int> point5 = new Point2D<int>(5, 0); Position position1 = Position.CreatePosition<int>(PointDimensions.XY); position1.AddPoint(point1); position1.AddPoint(point2); position1.AddPoint(point3); Position position2 = Position.CreatePosition<int>(PointDimensions.XY); position2.AddPoint(point4); position2.AddPoint(point5); Matrix matrix1 = Matrix.CreateMatrix<int>(PointDimensions.XY); matrix1.AddPosition(position1); matrix1.AddPosition(position2); Matrix matrix2 = Matrix.CreateMatrix<int>(PointDimensions.XY); matrix2.AddPosition(position1); Container container = Container.CreateContainer<int>(); container.AddMatrix(matrix1); container.AddMatrix(matrix2); }
public int GetNumberOfHousesWithGiftsUsingRobo(IEnumerable<char> chars) { var directions = GetDirections(chars); Point2D santa = new Point2D(0, 0); Point2D robo = new Point2D(0, 0); Dictionary<Point2D, int> map = new Dictionary<Point2D, int>(); AddGiftToPos(santa, map); AddGiftToPos(robo, map); int moves = 0; foreach (var direction in directions) { if (moves % 2 == 0) { santa = santa.Move(direction); AddGiftToPos(santa, map); } else { robo = robo.Move(direction); AddGiftToPos(robo, map); } moves++; } return map.Count; }
public static Line2D DrawLine(this Factory2D F, Point2D Start, Point2D End) { Line2D L = F.CreateLine(Start.GetPos(), End.GetPos()); L.StartPoint = Start; L.EndPoint = End; return L; }
/// <inheritdoc/> public Point2D InchesToPixels(Point2D inches) { var x = InchesToPixels(inches.X); var y = InchesToPixels(inches.Y); return new Point2D(x, y); }
public void Point2D_IsConstructedProperly() { var result = new Point2D(123.45, 456.78); TheResultingValue(result) .ShouldBe(123.45, 456.78); }
public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) { if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down) return new MahjongPieceDim(position, 40, 20); else return new MahjongPieceDim(position, 20, 40); }
/// <summary> /// Finds the distance of a specified point from the line segment and the /// closest point on the segment to the specified point. /// </summary> /// <param name="p">The test point.</param> /// <param name="closestPt">Closest point on the segment to c.</param> /// <returns>Returns the distance from p to the closest point on the segment.</returns> public double Distance(Point2D p, Point2D closestPt) { if (closestPt == null) closestPt = new Point2D(); // Construct vector v (AB) and w (AP) var v = new Vector2D(A, B); var w = new Vector2D(A, p); // Numerator of the component of w onto v. If <= 0 then A // is the closest point. By separating into the numerator // and denominator of the component we avoid a division unless // it is necessary. double n = w.Dot(v); if (n <= 0.0f) { closestPt.Set(A); return w.Norm(); } // Get the denominator of the component. If the component >= 1 // (d <= n) then point B is the closest point double d = v.Dot(v); if (d <= n) { closestPt.Set(B); return new Vector2D(B, p).Norm(); } // Closest point is along the segment. The point is the projection of // w onto v. closestPt.Set(v.Mult(n / d)); closestPt.Add(A); return new Vector2D(closestPt, p).Norm(); }
void buildGumpling(int x, int y, int hue, int fontid, string text) { Position = new Point2D(x, y); Hue = hue; FontID = fontid; Text = text; }
public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind) { this.m_Game = game; this.m_Position = position; this.m_Direction = direction; this.m_Wind = wind; }
public static void DrawLine(Vector2 from, Vector2 to, Texture2D texture) { Point2D tFrom = new Point2D(from); Point2D tTo = new Point2D(to); DrawLine(tFrom,tTo,texture); }
public static void DrawLine(Point2D tFrom, Point2D tTo, Texture2D texture) { //Debug.Log ("Drawing from: " + tFrom.x + "," + tFrom.y + " to " + tTo.x + "," + tTo.y); int deltaX = tFrom.x - tTo.x; int deltaY = tFrom.y - tTo.y; int d = 2*deltaY - deltaX; texture.SetPixel(tFrom.x,tFrom.y,Color.black); int y = tFrom.y; for(int x = tFrom.x + 1; x< tTo.x; x+=1) { if(d > 0) { y+=1; //Debug.Log (x + " " + y); texture.SetPixel(x,y,Color.black); d+=(2*deltaY)-(2*deltaX); } else { //Debug.Log (x + " " + y); texture.SetPixel(x,y,Color.black); d+=(2*deltaY); } } texture.Apply(); }
/// <summary> /// Checks if a given set of points forms an ear for a given polygon /// </summary> /// <param name="polygonPoints">The points describing the polygon</param> /// <param name="ear">The resulting ear, if applicable</param> /// <returns>True if these points form an ear</returns> private static bool IsEar(Point2D p1, Point2D p2, Point2D p3, List<Point2D> polygonPoints, out Triangle ear) { // for now, assign null to the ear ear = null; // Check if these points form a concave angle //if (Point2D.CalculateAngle(p1, p2, p3) > 0) // return false; // Can't be an ear // Make a triangle from the given points Triangle t = new Triangle(p1, p2, p3); // Check all other points of the polygon, if one falls within this triangle, this isn't an ear foreach (Point2D p in polygonPoints) if (!p.Equals(p1) && !p.Equals(p2) && !p.Equals(p3)) if (Triangle.PointInTriangle(t, p)) return false; // Sort our points counter-clockwise (this is how wpf indices-triangles face 'up') t.Points = Point2D.SortPoints(true, p1, p2, p3).ToArray(); // This is an ear ear = t; // Remove the center point out of the polygon polygonPoints.Remove(p1); // Report succes return true; }
/// <summary> /// Maps a GazeData gaze point (RawCoordinates or SmoothedCoordinates) to Unity screen space. /// Note that gaze points have origo in top left corner, whilst Unity uses lower left. /// </summary> /// <param name="gp"/>gaze point to map</param> /// <returns>2d point mapped to unity window space</returns> public static Point2D getGazeCoordsToUnityWindowCoords(Point2D gp) { double rx = gp.X * ((double)Screen.width / GazeManager.Instance.ScreenResolutionWidth); double ry = (GazeManager.Instance.ScreenResolutionHeight - gp.Y) * ((double)Screen.height / GazeManager.Instance.ScreenResolutionHeight); return new Point2D(rx, ry); }
public Message(uint id, IntPtr wParam, IntPtr lParam) { this.Id = id; this.WParam = wParam; this.LParam = lParam; this.Point = new Point2D(LowWord(lParam), HighWord(lParam)); }
public ExpandableScroll(Control owner, int page, int x, int y, int height) : base(0, 0) { _owner = owner; Position = new Point2D(x, y); _expandableScrollHeight = height; }
public Parabola2D(Point2D focus, Line2D directrix) : base(ShapeType2D.ParametricCurve) { m_focus = focus; m_directrix = directrix; m_tOffset = m_directrix.NearestT(m_focus); }
/// <summary> /// Seek a target in a 2-dimensional grid /// </summary> /// <param name="grid">The grid to search</param> /// <param name="startPoint">The start point to seek from</param> /// <param name="targetPoint">The target to seek to</param> /// <returns>An array of points in world space needed to pass through to get to the target</returns> /// <exception cref="ArgumentOutOfRangeException"> /// If the start or target are out of range of the grid /// </exception> public static Point2D[] Seek(GridNode2D[,] grid, Point2D startPoint, Point2D targetPoint) { return Seek( grid, startPoint, targetPoint, true, DEFAULT_MOVEMENTCOST, DEFAULT_DIAGONALCOST, DEFAULT_ASCENTCOST, DEFAULT_DESCENTCOST ); }
public override bool Contains(Point2D p) { foreach (var point in m_points) if (point.EuclideanDistanceTo(p) <= kContainsEpsilon) return true; return false; }
public static Point2D[] GrahamScan(Point2D[] p) { Debug.Assert(p != null); Debug.Assert(p.Length > 2); Stack<Point2D> hull = new Stack<Point2D>(); Array.Sort(p, Point2D.Y_ORDER); //p[0] is now point with lowest y-coordinate Array.Sort(p, p[0].POLAR_ORDER); //sort with respect to p[0] hull.Push(p[0]); hull.Push(p[1]); for (int i = 2; i < p.Length; i++) { Point2D top = hull.Pop(); while (Point2D.ccw(hull.Peek(), top, p[i]) <= 0) { top = hull.Pop(); } hull.Push(top); hull.Push(p[i]); } return hull.ToArray(); }
public void Point2DEqualityTests() { Point2D p1 = new Point2D(); Point2D p2 = Point2D.Empty; Point2D p3 = Point2D.Zero; Point2D p4 = new Point2D(0, 0); Point2D p5 = new Point2D(9, 10); Assert.AreEqual(p1, p2); Assert.AreNotEqual(p1, p3); Assert.AreEqual(p3, p4); Assert.AreNotEqual(p1, p5); Assert.AreNotEqual(p3, p5); IVectorD v1 = p1; IVectorD v2 = p2; IVectorD v3 = p3; IVectorD v4 = p4; IVectorD v5 = p5; Assert.AreEqual(v1, v2); Assert.AreNotEqual(v1, v3); Assert.AreEqual(v3, v4); Assert.AreNotEqual(v1, v5); Assert.AreNotEqual(v3, v5); Assert.AreEqual(v5, p5); }
public MastermindShield(string name, Point2D position, ContentManager content) : base(name, position, content) { this.ItemPicture = new Sprite("Sprites\\Items\\Mastermind_Shield", position); this.BoundingBox = new Rectangle2D((int)this.Position.X, (int)this.Position.Y, this.ItemPicture.Texture.Texture.Width, this.ItemPicture.Texture.Texture.Height); this.NumberOfCollection = MastermindShield.Counter; }
public void Update(GameTime gameTime, Point2D characterPosition) { if((characterPosition.X + Constant.WindowWidth / 2 < OrusTheGame.Instance.GameInformation.Levels[OrusTheGame.Instance.GameInformation.CurrentLevelIndex].LevelBackground.Texture.Texture.Width && characterPosition.X - Constant.WindowWidth / 2 > 0) || characterPosition.X > this.Center.X + Constant.WindowWidth) { this.Center = new Point2D(characterPosition.X - Constant.WindowWidth / 2, 0); this.Transform = Matrix.CreateScale(new Vector3(1, 1, 0)) * Matrix.CreateTranslation(new Vector3(-this.Center.X, -this.Center.Y, 0)); } if(characterPosition.X < this.Center.X) { this.Center = new Point2D(characterPosition.X - Constant.StartingPlayerXPosition, 0); this.Transform = Matrix.CreateScale(new Vector3(1, 1, 0)) * Matrix.CreateTranslation(new Vector3(-this.Center.X, -this.Center.Y, 0)); } var levelWidth = OrusTheGame.Instance.GameInformation.Levels[OrusTheGame.Instance.GameInformation.CurrentLevelIndex].LevelBackground.Texture.Texture.Width; if (this.Center.X + Constant.WindowWidth > levelWidth) { this.Center = new Point2D(levelWidth - Constant.WindowWidth, 0); this.Transform = Matrix.CreateScale(new Vector3(1, 1, 0)) * Matrix.CreateTranslation(new Vector3(-this.Center.X, -this.Center.Y, 0)); } }
static void Main(string[] args) { Point2D<int> dot2D = new Point2D<int>(10, 20); dot2D.ToString(); Point3D dot3D = new Point3D(10, 20, 30); dot3D.ToString(); }
/// <summary> /// Gets a value indicating whether the specified point is potentially a hit for the specified element. /// </summary> /// <param name="element">The element to evaluate.</param> /// <param name="point">The point to evaluate.</param> /// <returns><see langword="true"/> if the specified point is a potential hit; otherwise, <see langword="false"/>.</returns> public static Boolean IsPotentialHit(UIElement element, Point2D point) { if (element.Visibility != Visibility.Visible) return false; if (!element.IsHitTestVisible) return false; if (!element.VisualBounds.Contains(point)) return false; var clip = element.ClipRectangle; if (clip.HasValue) { var absoluteClip = clip.Value; var relativeClip = new RectangleD( absoluteClip.X - element.UntransformedAbsolutePosition.X, absoluteClip.Y - element.UntransformedAbsolutePosition.Y, absoluteClip.Width, absoluteClip.Height); if (!relativeClip.Contains(point)) return false; } return true; }
public static bool ContieneElPunto(this IEnumerable<Point2D> secuencia, Point2D punto) { foreach (var puntoEnSecuencia in secuencia) if (punto == puntoEnSecuencia) return true; return false; }
private static void Main() { Point p = new Point2D(1, 2); IVisitor v = new Chebyshev(); p.Accept(v); Console.WriteLine(p.Metric); }
// The main function that returns true if line segment 'p1q1' // and 'p2q2' intersect. static bool DoIntersect(Point2D p1, Point2D q1, Point2D p2, Point2D q2) { // Find the four orientations needed for general and // special cases int o1 = orientation(p1, q1, p2); int o2 = orientation(p1, q1, q2); int o3 = orientation(p2, q2, p1); int o4 = orientation(p2, q2, q1); // General case if (o1 != o2 && o3 != o4) return true; // Special Cases // p1, q1 and p2 are colinear and p2 lies on segment p1q1 if (o1 == 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are colinear and q2 lies on segment p1q1 if (o2 == 0 && onSegment(p1, q2, q1)) return true; // p2, q2 and p1 are colinear and p1 lies on segment p2q2 if (o3 == 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and q1 are colinear and q1 lies on segment p2q2 if (o4 == 0 && onSegment(p2, q1, q2)) return true; return false; // Doesn't fall in any of the above cases }
public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameColor = "-") { ScatterPlot scatterPlot = new ScatterPlot(); IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); if (variableNameColor == null || variableNameColor == "-") { List<Point2D<double>> points = new List<Point2D<double>>(); for (int i = 0; i < xValues.Count; i++) { Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]); points.Add(point); } ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points); scatterPlot.Rows.Add(scdr); } else { var colorValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameColor)); var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(colorValues, (v, c) => new { v.x, v.y, c }).ToList(); var gradients = ColorGradient.Colors; int curGradient = 0; int numColors = colorValues.Distinct().Count(); foreach (var colorValue in colorValues.Distinct()) { var values = data.Where(x => x.c == colorValue); var row = new ScatterPlotDataRow( variableNameX + " - " + variableNameY + " (" + colorValue + ")", "", values.Select(v => new Point2D<double>(v.x, v.y)), new ScatterPlotDataRowVisualProperties() { Color = gradients[curGradient] }); curGradient += gradients.Count / numColors; scatterPlot.Rows.Add(row); } } return scatterPlot; }
public void Add(Point2D[] points) { foreach (Point2D pt in points) { Add(pt.X, pt.Y); } }
protected override void OnTarget(Mobile from, object targeted) { if (m_Map.Deleted) { return; } Map map = m_Map.m_Map; if (m_Map.m_Completed) { from.SendLocalizedMessage(503028); // The treasure for this map has already been found. } /* * else if ( from != m_Map.m_Decoder ) * { * from.SendLocalizedMessage( 503016 ); // Only the person who decoded this map may actually dig up the treasure. * } */ else if (m_Map.m_Decoder != from && !m_Map.HasRequiredSkill(from)) { from.SendLocalizedMessage(503031); // You did not decode this map and have no clue where to look for the treasure. return; } else if (!from.CanBeginAction(typeof(TreasureMap))) { from.SendLocalizedMessage(503020); // You are already digging treasure. } else if (!HasDiggingTool(from)) { from.SendMessage("You must have a digging tool to dig for treasure."); } else if (from.Map != map) { from.SendLocalizedMessage(1010479); // You seem to be in the right place, but may be on the wrong facet! } else { IPoint3D p = targeted as IPoint3D; Point3D targ3D; if (p is Item) { targ3D = ((Item)p).GetWorldLocation(); } else { targ3D = new Point3D(p); } int maxRange; double skillValue = from.Skills[SkillName.Mining].Value; if (skillValue >= 100.0) { maxRange = 4; } else if (skillValue >= 81.0) { maxRange = 3; } else if (skillValue >= 51.0) { maxRange = 2; } else { maxRange = 1; } Point2D loc = m_Map.m_Location; int x = loc.X, y = loc.Y; Point3D chest3D0 = new Point3D(loc, 0); if (Utility.InRange(targ3D, chest3D0, maxRange)) { if (from.Location.X == x && from.Location.Y == y) { from.SendLocalizedMessage(503030); // The chest can't be dug up because you are standing on top of it. } else if (map != null) { int z = map.GetAverageZ(x, y); if (!map.CanFit(x, y, z, 16, true, true)) { from.SendLocalizedMessage(503021); // You have found the treasure chest but something is keeping it from being dug up. } else if (from.BeginAction(typeof(TreasureMap))) { new DigTimer(from, m_Map, new Point3D(x, y, z), map).Start(); } else { from.SendLocalizedMessage(503020); // You are already digging treasure. } } } else if (m_Map.Level > 0) { if (Utility.InRange(targ3D, chest3D0, 8)) // We're close, but not quite { from.SendLocalizedMessage(503032); // You dig and dig but no treasure seems to be here. } else { from.SendLocalizedMessage(503035); // You dig and dig but fail to find any treasure. } } else { if (Utility.InRange(targ3D, chest3D0, 8)) // We're close, but not quite { from.SendAsciiMessage(0x44, "The treasure chest is very close!"); } else { Direction dir = Utility.GetDirection(targ3D, chest3D0); string sDir; switch (dir) { case Direction.North: sDir = "north"; break; case Direction.Right: sDir = "northeast"; break; case Direction.East: sDir = "east"; break; case Direction.Down: sDir = "southeast"; break; case Direction.South: sDir = "south"; break; case Direction.Left: sDir = "southwest"; break; case Direction.West: sDir = "west"; break; default: sDir = "northwest"; break; } from.SendAsciiMessage(0x44, "Try looking for the treasure chest more to the {0}.", sDir); } } } }
public override void OnFrame(Bot bot) { if (HideLocation == null) { HideLocation = ProxyTask.Task.GetHideLocation(); } if (HideLocation != null) { if (ProxyTask.Task.UnitCounts.ContainsKey(UnitTypes.PYLON) && ProxyTask.Task.UnitCounts[UnitTypes.PYLON] > 0 && ProxyTask.Task.UnitCounts.ContainsKey(UnitTypes.STARGATE) && ProxyTask.Task.UnitCounts[UnitTypes.STARGATE] > 0) { float dist = 10 * 10; Unit fleeEnemy = null; foreach (Unit enemy in bot.Enemies()) { if (!UnitTypes.CanAttackAir(enemy.UnitType)) { continue; } float newDist = SC2Util.DistanceSq(enemy.Pos, HideLocation); if (newDist > dist) { continue; } dist = newDist; fleeEnemy = enemy; } if (fleeEnemy != null) { TempestController.RetreatPos = new PotentialHelper(HideLocation, 6).From(fleeEnemy.Pos).Get(); } else { TempestController.RetreatPos = HideLocation; } } else { TempestController.RetreatPos = null; } } if (TempestController.RetreatPos == null) { TempestController.RetreatPos = ProxyTask.Task.GetHideLocation(); } DepoweredStargates = 0; foreach (Agent agent in bot.Units()) { if (agent.Unit.UnitType == UnitTypes.STARGATE && !agent.Unit.IsPowered && agent.Unit.BuildProgress >= 0.99) { DepoweredStargates++; } } bot.DrawText("DepoweredStargates: " + DepoweredStargates); bot.NexusAbilityManager.PriotitizedAbilities.Add(1568); ProxyTask.Task.EvadeEnemies = true; bot.buildingPlacer.BuildCompact = true; bot.TargetManager.PrefferDistant = false; bot.TargetManager.TargetAllBuildings = true; TrainStep.WarpInLocation = ProxyTask.Task.GetHideLocation(); DefendRegionTask.Task.DefenseLocation = ProxyTask.Task.GetHideLocation(); TimingAttackTask.Task.RequiredSize = 1; TimingAttackTask.Task.RetreatSize = 0; TimingAttackTask.Task.UnitType = UnitTypes.TEMPEST; if (bot.Frame >= 22.4 * 60 * 4) { ProxyTask.Task.Stopped = true; } else { ProxyTask.Task.Stopped = Count(UnitTypes.GATEWAY) == 0; if (ProxyTask.Task.Stopped) { ProxyTask.Task.Clear(); } } if (UpgradeType.LookUp[UpgradeType.WarpGate].Progress() >= 0.5 && IdleTask.Task.OverrideTarget == null && (bot.EnemyRace != Race.Protoss || bot.Frame >= 22.4 * 4 * 60)) { IdleTask.Task.OverrideTarget = bot.MapAnalyzer.Walk(ProxyTask.Task.GetHideLocation(), bot.MapAnalyzer.EnemyDistances, 10); } foreach (Agent agent in bot.UnitManager.Agents.Values) { if (bot.Frame % 224 != 0) { break; } if (agent.Unit.UnitType != UnitTypes.GATEWAY) { continue; } agent.Order(Abilities.MOVE, agent.From(bot.MapAnalyzer.GetMainRamp(), 4)); } }
public Boxy(Window gameWindow, Player player) { // SplashKit.Rnd(); //if the random that we got was less than .5 do this if (SplashKit.Rnd() < 0.5) { //if the random is lower than 0.5 make the X and Y exactly at the border of the screen //X is now a random with the integer of the width of gamewindow X = SplashKit.Rnd(gameWindow.Width);//Unbound vlaue here is gamewindow.width // Bot generate at X position means between 0 to 600 px //Similar with Y generate at -800 position if (SplashKit.Rnd() < 0.5) { Y = -Height; } // else // Y = gameWindow.Height; } else { Y = SplashKit.Rnd(gameWindow.Height); if (SplashKit.Rnd() < 0.5) { X = -Width; } // else // Y = gameWindow.Width; } /* * X = SplashKit.Rnd(gameWindow.Width - Width) / 2; * Y = SplashKit.Rnd(gameWindow.Height - Height) / 2; */ MainColor = Color.RandomRGB(200); //all caps for constant? Convention? int speed = 1; // if (SplashKit.KeyDown(KeyCode.SpaceKey)) // { // speed += 2; // } //get a point for the Robot Point2D fromPt = new Point2D() { Y = Y }; //point for the player so robot can move towards the player one time //will not always update so robot will just move straight Point2D toPt = new Point2D() { Y = player.Y }; // Calculate the direction to head Vector2D dir; dir = SplashKit.UnitVector(SplashKit.VectorPointToPoint(fromPt, toPt)); // Set the speed and assign to the Velocity Velocity = SplashKit.VectorMultiply(dir, speed); }
public Ray2D(double startX, double startY, double directionX, double directionY) { this.origin = new Point2D(startX, startY); this.direction = new Vector2D(directionX, directionY); }
public Ray2D(Point2D origin, Vector2D direction) { this.origin = origin; this.direction = direction; }
public void Add(Point2D point) { HashSet.Add(point); }
public bool Contains(Point2D point) { return(HashSet.Contains(point)); }
// *************************************************************************** // * Constructors * // *************************************************************************** /// <summary> /// Initializes a new instance of the <see cref="Cell"/> class. /// </summary> /// <param name="x">X-Position</param> /// <param name="y">Y-Position</param> /// <param name="type">Cell Type</param> protected Cell(int x, int y, CellType type) { Type = type; Position = new Point2D(x, y); }
/// <summary> /// Case 15: Calculation of capacity state in asymmetric section for bidirectional bending with axial force /// </summary> public void Case15() { // Case 15a // geometry definition Geometry geometry = new Geometry(); geometry.Add(0.00, 0.00); geometry.Add(0.00, 0.60); geometry.Add(0.25, 0.60); geometry.Add(0.25, 0.25); geometry.Add(0.70, 0.25); geometry.Add(0.70, 0.00); // rebars definition List <Rebar> rebars = new List <Rebar>(); double rebarArea = 0.020 * 0.020 * Math.PI / 4.0; rebars.Add(new Rebar(0.05, 0.05, rebarArea)); rebars.Add(new Rebar(0.05, 0.55, rebarArea)); rebars.Add(new Rebar(0.20, 0.55, rebarArea)); rebars.Add(new Rebar(0.20, 0.05, rebarArea)); rebars.Add(new Rebar(0.65, 0.05, rebarArea)); rebars.Add(new Rebar(0.65, 0.20, rebarArea)); rebars.Add(new Rebar(0.05, 0.20, rebarArea)); // concrete parameters Concrete concrete = new Concrete(); concrete.SetStrainStressModelRectangular(20e6, 0.0035, 35e9, 0.8); // steel parameters Steel steel = new Steel(); steel.SetModelIdealElastoPlastic(310e6, 0.075, 200e9); // solver creation and parameterization RCSolver solver = RCSolver.CreateNewSolver(geometry); solver.SetRebars(rebars); solver.SetConcrete(concrete); solver.SetSteel(steel); //calulation solver.SolveResistance(72.4471E3, -28.9825E3, 2.5743E3); // result for rebars SetOfForces forcesRebar = solver.GetInternalForces(ResultType.Rebars); // result for concrete SetOfForces forcesConcrete = solver.GetInternalForces(ResultType.Concrete); Point2D Gcc = solver.GetStressGravityCenter(ResultType.Concrete); double Acc = solver.GetConcreteStressArea(); // result for RC section SetOfForces forces = solver.GetInternalForces(ResultType.Section); double angle = solver.GetNeutralAxisAngle(); double dist = solver.GetNeutralAxisDistance(); // result presentation sb.AppendLine(); sb.AppendLine(decoration); sb.AppendLine("Case 15a: Calculation of capacity state in asymmetric section for bidirectional bending with axial force "); sb.AppendLine(decoration); sb.AppendLine(FormatOutput("Ns", forcesRebar.AxialForce, 6)); sb.AppendLine(FormatOutput("Mxs", forcesRebar.MomentX, 6)); sb.AppendLine(FormatOutput("Mys", forcesRebar.MomentY, 6)); sb.AppendLine(FormatOutput("Ac", Acc, 6)); sb.AppendLine(FormatOutput("Gcx", Gcc.X, 6)); sb.AppendLine(FormatOutput("Gcy", Gcc.Y, 6)); sb.AppendLine(FormatOutput("Nc", forcesConcrete.AxialForce, 6)); sb.AppendLine(FormatOutput("Mxc", forcesConcrete.MomentX, 6)); sb.AppendLine(FormatOutput("Myc", forcesConcrete.MomentY, 6)); sb.AppendLine(FormatOutput("N", forces.AxialForce, 6)); sb.AppendLine(FormatOutput("Mx", forces.MomentX, 6)); sb.AppendLine(FormatOutput("My", forces.MomentY, 6)); sb.AppendLine(FormatOutput("dist", dist, 6)); sb.AppendLine(FormatOutput("angle", angle, 6)); // Case 15b // concrete parameters (rectangular) concrete.SetStrainStressModelRectangular(20e6, 0.0035, 35e9, 0.8); // solver parameterization solver.SetConcrete(concrete); //calulation solver.SolveResistance(72.4471E3, -28.9825E3, 2.5743E3); // result for RC section forces = solver.GetInternalForces(ResultType.Section); // result presentation sb.AppendLine(); sb.AppendLine(decoration); sb.AppendLine("Case 15b: Calculation of capacity state in asymmetric section for bidirectional bending with axial force (rectangular)"); sb.AppendLine(decoration); sb.AppendLine(FormatOutput("N", forces.AxialForce, 6)); sb.AppendLine(FormatOutput("Mx", forces.MomentX, 6)); sb.AppendLine(FormatOutput("My", forces.MomentY, 6)); // concrete parameters(linear) concrete.SetStrainStressModelLinear(25e6, 0.0035, 32e9); // solver parameterization solver.SetConcrete(concrete); //calulation solver.SolveResistance(72.4471E3, -28.9825E3, 2.5743E3); // result for RC section forces = solver.GetInternalForces(ResultType.Section); // result presentation sb.AppendLine(); sb.AppendLine(decoration); sb.AppendLine("Case 15b: Calculation of capacity state in asymmetric section for bidirectional bending with axial force (linear)"); sb.AppendLine(decoration); sb.AppendLine(FormatOutput("N", forces.AxialForce, 6)); sb.AppendLine(FormatOutput("Mx", forces.MomentX, 6)); sb.AppendLine(FormatOutput("My", forces.MomentY, 6)); // concrete parameters (bilinear) concrete.SetStrainStressModelBiLinear(25e6, 0.0035, 32e9, 0.0020); // solver parameterization solver.SetConcrete(concrete); //calulation solver.SolveResistance(72.4471E3, -28.9825E3, 2.5743E3); // result for RC section forces = solver.GetInternalForces(ResultType.Section); // result presentation sb.AppendLine(); sb.AppendLine(decoration); sb.AppendLine("Case 15b: Calculation of capacity state in asymmetric section for bidirectional bending with axial force (bilinear)"); sb.AppendLine(decoration); sb.AppendLine(FormatOutput("N", forces.AxialForce, 6)); sb.AppendLine(FormatOutput("Mx", forces.MomentX, 6)); sb.AppendLine(FormatOutput("My", forces.MomentY, 6)); // concrete parameters (parabolic-rectangular) concrete.SetStrainStressModelParabolicRectangular(25e6, 0.0035, 32e9, 0.0020); // solver parameterization solver.SetConcrete(concrete); //calulation solver.SolveResistance(72.4471E3, -28.9825E3, 2.5743E3); // result for RC section forces = solver.GetInternalForces(ResultType.Section); // result presentation sb.AppendLine(); sb.AppendLine(decoration); sb.AppendLine("Case 15b: Calculation of capacity state in asymmetric section for bidirectional bending with axial force (parabolic-rectangular)"); sb.AppendLine(decoration); sb.AppendLine(FormatOutput("N", forces.AxialForce, 6)); sb.AppendLine(FormatOutput("Mx", forces.MomentX, 6)); sb.AppendLine(FormatOutput("My", forces.MomentY, 6)); // concrete parameters (power-rectangular) concrete.SetStrainStressModelPowerRectangular(25e6, 0.0035, 32e9, 0.002, 1.5); // solver parameterization solver.SetConcrete(concrete); //calulation solver.SolveResistance(72.4471E3, -28.9825E3, 2.5743E3); // result for RC section forces = solver.GetInternalForces(ResultType.Section); // result presentation sb.AppendLine(); sb.AppendLine(decoration); sb.AppendLine("Case 15b: Calculation of capacity state in asymmetric section for bidirectional bending with axial force (parabolic-rectangular)"); sb.AppendLine(decoration); sb.AppendLine(FormatOutput("N", forces.AxialForce, 6)); sb.AppendLine(FormatOutput("Mx", forces.MomentX, 6)); sb.AppendLine(FormatOutput("My", forces.MomentY, 6)); }
private void DoWork(Player me) { var myVehicles = VehicleRegistry.MyVehicles(me); var fightersGroup = new VehiclesGroup(Id, myVehicles .Where(v => v.Type == VehicleType.Fighter) .Select(v => v.Id) .ToList(), VehicleRegistry, CommandManager); var helicoptersGroup = new VehiclesGroup(Id, myVehicles .Where(v => v.Type == VehicleType.Helicopter) .Select(v => v.Id) .ToList(), VehicleRegistry, CommandManager); var leftPoint = new Point2D(MagicConstants.InitialGapSize * 1, MagicConstants.InitialGapSize * 3); var rightPoint = new Point2D(MagicConstants.InitialGapSize * 3, MagicConstants.InitialGapSize * 1); if (fightersGroup.Center.GetDistanceTo(leftPoint) < helicoptersGroup.Center.GetDistanceTo(leftPoint)) { fightersGroup .SelectVehicles(VehicleType.Fighter) .MoveTo(leftPoint); helicoptersGroup .SelectVehicles(VehicleType.Helicopter) .MoveTo(rightPoint); fightersGroup .SelectVehicles(VehicleType.Fighter) .MoveByVector(0, -MagicConstants.InitialGapSize, canBeParallel: true); commands.Add(CommandManager.PeekLastCommand(Id) as MoveCommand); helicoptersGroup .SelectVehicles(VehicleType.Helicopter) .MoveByVector(0, MagicConstants.InitialGapSize); commands.Add(CommandManager.PeekLastCommand(Id) as MoveCommand); } else { fightersGroup .SelectVehicles(VehicleType.Fighter) .MoveTo(rightPoint); helicoptersGroup .SelectVehicles(VehicleType.Helicopter) .MoveTo(leftPoint); fightersGroup .SelectVehicles(VehicleType.Fighter) .MoveByVector(0, MagicConstants.InitialGapSize, canBeParallel: true); commands.Add(CommandManager.PeekLastCommand(Id) as MoveCommand); helicoptersGroup .SelectVehicles(VehicleType.Helicopter) .MoveByVector(0, -MagicConstants.InitialGapSize); commands.Add(CommandManager.PeekLastCommand(Id) as MoveCommand); } }
public override bool DetermineAction(Agent agent, Point2D target) { if (agent.Unit.UnitType == UnitTypes.THOR) { return(false); } if (agent.Unit.WeaponCooldown >= 5 && (Bot.Main.Frame % 100 > 50 || Bot.Main.UnitManager.Completed(UnitTypes.STALKER) + Bot.Main.UnitManager.Completed(UnitTypes.IMMORTAL) >= 8)) { return(false); } if (agent.Unit.UnitType != UnitTypes.VOID_RAY && agent.Unit.UnitType != UnitTypes.ADEPT && agent.Unit.UnitType != UnitTypes.STALKER && agent.Unit.UnitType != UnitTypes.COLOSUS && agent.Unit.UnitType != UnitTypes.IMMORTAL && agent.Unit.UnitType != UnitTypes.ROACH && agent.Unit.UnitType != UnitTypes.HYDRALISK && agent.Unit.UnitType != UnitTypes.QUEEN && agent.Unit.UnitType != UnitTypes.INFESTOR_TERRAN && agent.Unit.UnitType != UnitTypes.CORRUPTOR && agent.Unit.UnitType != UnitTypes.BROOD_LORD && agent.Unit.UnitType != UnitTypes.MUTALISK && agent.Unit.UnitType != UnitTypes.RAVAGER && agent.Unit.UnitType != UnitTypes.MARINE && agent.Unit.UnitType != UnitTypes.MARAUDER && agent.Unit.UnitType != UnitTypes.SIEGE_TANK && agent.Unit.UnitType != UnitTypes.HELLION && agent.Unit.UnitType != UnitTypes.HELLBAT && agent.Unit.UnitType != UnitTypes.THOR && agent.Unit.UnitType != UnitTypes.THOR_SINGLE_TARGET && agent.Unit.UnitType != UnitTypes.CYCLONE) { return(false); } if (agent.Unit.WeaponCooldown == 0 && agent.Unit.UnitType != UnitTypes.CYCLONE) { return(false); } float dist = 10 * 10; Unit fleeTarget = null; foreach (Unit unit in Bot.Main.Enemies()) { if (unit.UnitType != UnitTypes.PHOTON_CANNON) { continue; } float newDist = agent.DistanceSq(unit); if (newDist > dist) { continue; } fleeTarget = unit; dist = newDist; } if (fleeTarget != null) { PotentialHelper potential = new PotentialHelper(agent.Unit.Pos, 4); potential.From(fleeTarget.Pos, 2); potential.To(FleeToward); agent.Order(Abilities.MOVE, potential.Get()); return(true); } return(false); }
protected override void OnInit(Point2D position, object[] args) { }
/// <summary> /// /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> public static double GetMaximumsDistance2D(Point2D p1, Point2D p2) { return(Math.Max(Math.Abs(p1.X - p2.X), Math.Abs(p1.Y - p2.Y))); }
public virtual void Update() { // update gazedata based on store Eye right = null, left = null; bool userPosIsValid = false; Point2D gazeCoords = Point2D.Zero; Point2D gazeCoordsSmooth = Point2D.Zero; Point2D userPos = Point2D.Zero; double userDist = 0f; Point2D eyeDistVecHalf = Point2D.Zero; GazeData gd; lock (_Frames) { for (int i = _Frames.Count; --i >= 0;) { gd = _Frames.ElementAt(i); // if no tracking problems, then cache eye data if ((gd.State & NO_TRACKING_MASK) == 0) { if (!userPosIsValid) { if (left == null && Point2D.Zero != gd.LeftEye.PupilCenterCoordinates) { left = gd.LeftEye; } else if (right == null && Point2D.Zero != gd.RightEye.PupilCenterCoordinates) { right = gd.RightEye; } if (left != null && right != null) { userPosIsValid = true; } } // if gaze coordinates available, cache both raw and smoothed if (Point2D.Zero == gazeCoords && Point2D.Zero != gd.RawCoordinates) { gazeCoords = gd.RawCoordinates; gazeCoordsSmooth = gd.SmoothedCoordinates; } } // break loop if valid values found if (userPosIsValid && Point2D.Zero != gazeCoords) { break; } } _LastRawGazeCoords = gazeCoords; _LastSmoothedGazeCoords = gazeCoordsSmooth; //Update eye based user position values if needed data is valid and no head data provided if (userPosIsValid) { if (left != _LastLeftEye || right != _LastRightEye) { userPos = (left.PupilCenterCoordinates + right.PupilCenterCoordinates) * .5f; eyeDistVecHalf = (right.PupilCenterCoordinates - left.PupilCenterCoordinates) * .5f; if (Point2D.Zero != eyeDistVecHalf && eyeDistVecHalf != _LastEyesDistHalfVec) { _LastEyesDistHalfVec = eyeDistVecHalf; } userDist = GazeUtils.GetDistancePoint2D(left.PupilCenterCoordinates, right.PupilCenterCoordinates); _LastLeftEye = left; _LastRightEye = right; //update 'depth' measure if (userDist < _MinimumEyesDistance) { _MinimumEyesDistance = (float)userDist; } if (userDist > _MaximumEyesDistance) { _MaximumEyesDistance = (float)userDist; } _LastEyeDistance = 1f - ((float)userDist / _MaximumEyesDistance); //update user position _LastUserPosition = new Point3D(userPos.X, userPos.Y, (float)_LastEyeDistance); //map to normalized 3D space _LastUserPosition.X = (_LastUserPosition.X * 2) - 1; _LastUserPosition.Y = (_LastUserPosition.Y * 2) - 1; _UserPosTimeStamp = _FrameTimeStamp; //update angle double dy = _LastRightEye.PupilCenterCoordinates.Y - _LastLeftEye.PupilCenterCoordinates.Y; double dx = _LastRightEye.PupilCenterCoordinates.X - _LastLeftEye.PupilCenterCoordinates.X; _LastEyeAngle = ((180 / Math.PI * Math.Atan2(GazeManager.Instance.ScreenResolutionHeight * dy, GazeManager.Instance.ScreenResolutionWidth * dx))); } } else if (null != left) { if (left != _LastLeftEye) { _LastLeftEye = left; Point2D newPos = _LastLeftEye.PupilCenterCoordinates + _LastEyesDistHalfVec; _LastUserPosition = new Point3D(newPos.X, newPos.Y, (float)_LastEyeDistance); //map to normalized 3D space _LastUserPosition.X = (_LastUserPosition.X * 2) - 1; _LastUserPosition.Y = (_LastUserPosition.Y * 2) - 1; _UserPosTimeStamp = _FrameTimeStamp; } } else if (null != right) { if (right != _LastRightEye) { _LastRightEye = right; Point2D newPos = _LastRightEye.PupilCenterCoordinates - _LastEyesDistHalfVec; _LastUserPosition = new Point3D(newPos.X, newPos.Y, (float)_LastEyeDistance); //map to normalized 3D space _LastUserPosition.X = (_LastUserPosition.X * 2) - 1; _LastUserPosition.Y = (_LastUserPosition.Y * 2) - 1; _UserPosTimeStamp = _FrameTimeStamp; } } else { _LastRightEye = null; _LastLeftEye = null; _LastUserPosition = Point3D.Zero; } } }
public List <SC2APIProtocol.Action> SplitArmy(int frame, IEnumerable <UnitCalculation> closerEnemies, Point2D attackPoint, IEnumerable <UnitCommander> unitCommanders, bool defendToDeath) { var actions = new List <SC2APIProtocol.Action>(); var winnableDefense = false; if (LastSplitFrame + 25 < frame) { ReSplitArmy(frame, closerEnemies, attackPoint, unitCommanders); LastSplitFrame = frame; } foreach (var split in ArmySplits) { if (split.SelfGroup.Count() > 0) { var groupVectors = split.SelfGroup.Select(u => u.UnitCalculation.Position); var groupPoint = new Point2D { X = groupVectors.Average(v => v.X), Y = groupVectors.Average(v => v.Y) }; var defensePoint = new Point2D { X = split.EnemyGroup.FirstOrDefault().Unit.Pos.X, Y = split.EnemyGroup.FirstOrDefault().Unit.Pos.Y }; actions.AddRange(MicroController.Attack(split.SelfGroup, defensePoint, TargetingData.ForwardDefensePoint, groupPoint, frame)); winnableDefense = true; } } if (AvailableCommanders.Count() > 0) { var groupVectors = AvailableCommanders.Select(u => u.UnitCalculation.Position); var groupPoint = new Point2D { X = groupVectors.Average(v => v.X), Y = groupVectors.Average(v => v.Y) }; if (AttackData.Attacking) { actions.AddRange(MicroController.Attack(AvailableCommanders, attackPoint, TargetingData.ForwardDefensePoint, groupPoint, frame)); } else { if (winnableDefense || defendToDeath) { actions.AddRange(MicroController.Attack(AvailableCommanders, new Point2D { X = closerEnemies.FirstOrDefault().Unit.Pos.X, Y = closerEnemies.FirstOrDefault().Unit.Pos.Y }, TargetingData.ForwardDefensePoint, groupPoint, frame)); } else { var defensiveVector = new Vector2(TargetingData.ForwardDefensePoint.X, TargetingData.ForwardDefensePoint.Y); var shieldBattery = ActiveUnitData.SelfUnits.Values.Where(u => u.Unit.UnitType == (uint)UnitTypes.PROTOSS_SHIELDBATTERY && u.Unit.IsPowered && u.Unit.BuildProgress == 1 && u.Unit.Energy > 5).OrderBy(u => Vector2.DistanceSquared(u.Position, defensiveVector)).FirstOrDefault(); if (shieldBattery != null) { actions.AddRange(MicroController.Retreat(AvailableCommanders, new Point2D { X = shieldBattery.Position.X, Y = shieldBattery.Position.Y }, groupPoint, frame)); } else { actions.AddRange(MicroController.Retreat(AvailableCommanders, TargetingData.MainDefensePoint, groupPoint, frame)); } } } } return(actions); }
public void OnHoverSelection(Point2D point) { Game.Scene3D.LocalPlayer.HoveredUnit = FindClosestObject(point.ToVector2()); }
/// <summary> /// Метод для «постройки» конкретного объекта с учреждением. /// </summary> /// <param name="firstRoad">Первая из двух дорог, на пересечении которых будет располагаться учреждение.</param> /// <param name="secondRoad">Вторая из двух дорог, на пересечении которых будет располагаться учреждение.</param> /// <param name="location">Координаты пересечения.</param> /// <returns>Экземпляр конкретного объекта с учреждением.</returns> public abstract Institution Build(Road firstRoad, Road secondRoad, Point2D location);
/// <summary> /// /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> public static double GetManhattanDistance2D(Point2D p1, Point2D p2) { return(Math.Abs(p1.X - p2.X) + Math.Abs(p1.Y - p2.Y)); }
public ScoutProxyTask(Point2D target) : base(10) { Target = target; }
// Find the point of intersection between // the lines p1 --> p2 and p3 --> p4. private static void FindIntersection( Point2D p1, Point2D p2, Point2D p3, Point2D p4, out bool lines_intersect, out bool segments_intersect, out Point2D intersection, out Point2D close_p1, out Point2D close_p2) { // Get the segments' parameters. double dx12 = p2.X - p1.X; double dy12 = p2.Y - p1.Y; double dx34 = p4.X - p3.X; double dy34 = p4.Y - p3.Y; // Solve for t1 and t2 double denominator = (dy12 * dx34 - dx12 * dy34); double t1 = ((p1.X - p3.X) * dy34 + (p3.Y - p1.Y) * dx34) / denominator; if (double.IsInfinity(t1)) { // The lines are parallel (or close enough to it). lines_intersect = false; segments_intersect = false; intersection = new Point2D(double.NaN, double.NaN); close_p1 = new Point2D(double.NaN, double.NaN); close_p2 = new Point2D(double.NaN, double.NaN); return; } lines_intersect = true; double t2 = ((p3.X - p1.X) * dy12 + (p1.Y - p3.Y) * dx12) / -denominator; // Find the point of intersection. intersection = new Point2D(p1.X + dx12 * t1, p1.Y + dy12 * t1); // The segments intersect if t1 and t2 are between 0 and 1. segments_intersect = ((t1 >= 0) && (t1 <= 1) && (t2 >= 0) && (t2 <= 1)); // Find the closest points on the segments. if (t1 < 0) { t1 = 0; } else if (t1 > 1) { t1 = 1; } if (t2 < 0) { t2 = 0; } else if (t2 > 1) { t2 = 1; } close_p1 = new Point2D(p1.X + dx12 * t1, p1.Y + dy12 * t1); close_p2 = new Point2D(p3.X + dx34 * t2, p3.Y + dy34 * t2); }
public Class152(Point2D position) : base(position) { }
public override List <WidgetAndPosition> FindDescendants(IEnumerable <string> namesToSearchFor, List <WidgetAndPosition> foundChildren, RectangleDouble touchingBounds, SearchType seachType, bool allowInvalidItems = true) { foreach (InteractionVolume child in this.InteractionVolumes) { string object3DName = child.Name; bool nameFound = false; foreach (var nameToSearchFor in namesToSearchFor) { if (seachType == SearchType.Exact) { if (object3DName == nameToSearchFor) { nameFound = true; break; } } else { if (nameToSearchFor == "" || object3DName.Contains(nameToSearchFor)) { nameFound = true; break; } } } if (nameFound && child.CollisionVolume != null) { AxisAlignedBoundingBox bounds = child.CollisionVolume.GetAxisAlignedBoundingBox(); bounds = bounds.NewTransformed(child.TotalTransform); RectangleDouble screenBoundsOfObject3D = RectangleDouble.ZeroIntersection; for (int i = 0; i < 4; i++) { screenBoundsOfObject3D.ExpandToInclude(this.World.GetScreenPosition(bounds.GetTopCorner(i))); screenBoundsOfObject3D.ExpandToInclude(this.World.GetScreenPosition(bounds.GetBottomCorner(i))); } if (touchingBounds.IsTouching(screenBoundsOfObject3D)) { Vector3 renderPosition = bounds.Center; Vector2 objectCenterScreenSpace = this.World.GetScreenPosition(renderPosition); var screenPositionOfObject3D = new Point2D((int)objectCenterScreenSpace.X, (int)objectCenterScreenSpace.Y); foundChildren.Add(new WidgetAndPosition(this, screenPositionOfObject3D, object3DName, child)); } } } foreach (var child in scene.Children) { string object3DName = child.Name; if (object3DName == null && child.MeshPath != null) { object3DName = Path.GetFileName(child.MeshPath); } bool nameFound = false; foreach (var nameToSearchFor in namesToSearchFor) { if (seachType == SearchType.Exact) { if (object3DName == nameToSearchFor) { nameFound = true; break; } } else { if (nameToSearchFor == "" || object3DName.Contains(nameToSearchFor)) { nameFound = true; break; } } } if (nameFound) { AxisAlignedBoundingBox bounds = child.GetBVHData().GetAxisAlignedBoundingBox(); RectangleDouble screenBoundsOfObject3D = RectangleDouble.ZeroIntersection; for (int i = 0; i < 4; i++) { screenBoundsOfObject3D.ExpandToInclude(this.World.GetScreenPosition(bounds.GetTopCorner(i))); screenBoundsOfObject3D.ExpandToInclude(this.World.GetScreenPosition(bounds.GetBottomCorner(i))); } if (touchingBounds.IsTouching(screenBoundsOfObject3D)) { Vector3 renderPosition = bounds.Center; Vector2 objectCenterScreenSpace = this.World.GetScreenPosition(renderPosition); var screenPositionOfObject3D = new Point2D((int)objectCenterScreenSpace.X, (int)objectCenterScreenSpace.Y); foundChildren.Add(new WidgetAndPosition(this, screenPositionOfObject3D, object3DName, child)); } } } return(base.FindDescendants(namesToSearchFor, foundChildren, touchingBounds, seachType, allowInvalidItems)); }
public Class147(Point2D start, Point2D end) { this.point2D_0 = start; this.point2D_1 = end; }
internal static void smethod_1(Polygon2D polygon, byte type, List <Class145.Class148.Class149> localMinimumList) { if (polygon.Count == 0) { return; } Point2D item = polygon[0]; Point2D point2D = item; int num = 1; int num1 = 0; int count = polygon.Count; while (true) { if (num < count) { point2D = polygon[num]; num1 = Math.Sign(point2D.Y - item.Y); if (num1 == 0) { num1 = Math.Sign(point2D.X - item.X); } if (num1 != 0) { num++; break; } else { num++; } } else { break; } } Class145.Class148 class150 = null; Action <Class145.Class148> class1480 = null; while (true) { if (num <= count) { Point2D item1 = polygon[num % count]; int num2 = Math.Sign(item1.Y - point2D.Y); if (num2 == 0) { num2 = Math.Sign(item1.X - point2D.X); } if (num2 != 0) { if (num2 == num1) { if (num2 <= 0) { Class145.Class148 class148 = new Class145.Class148.Class150(point2D); class1480 = (Class145.Class148 prev) => class148.class148_0 = prev; class150 = class148; } else { Class145.Class148 class1501 = new Class145.Class148.Class150(point2D); class1480 = (Class145.Class148 prev) => prev.class148_0 = class1501; class150 = class1501; } } else if (num2 <= 0 || num1 >= 0) { Class145.Class148.Class151 class151 = new Class145.Class148.Class151(point2D); Class145.Class148.Class152 class152 = new Class145.Class148.Class152(point2D); class1480 = (Class145.Class148 prev) => prev.class148_0 = class152; class150 = class151; } else { Class145.Class148.Class149 class149 = new Class145.Class148.Class149(point2D); class1480 = (Class145.Class148 prev) => class149.class148_1 = prev; class150 = class149; localMinimumList.Add(class149); } num1 = num2; point2D = item1; num++; break; } else { num++; } } else { break; } } int num3 = count + 2; while (num < num3) { Point2D point2D1 = polygon[num % count]; int num4 = Math.Sign(point2D1.Y - point2D.Y); if (num4 == 0) { num4 = Math.Sign(point2D1.X - point2D.X); } if (num4 != 0) { if (num4 == num1) { if (num4 <= 0) { class150 = new Class145.Class148.Class150(point2D) { class148_0 = class150 }; } else { Class145.Class148 class1481 = new Class145.Class148.Class150(point2D); class150.class148_0 = class1481; class150 = class1481; } } else if (num4 <= 0 || num1 >= 0) { Class145.Class148.Class151 class1511 = new Class145.Class148.Class151(point2D); class150.class148_0 = new Class145.Class148.Class152(point2D); class150 = class1511; } else { Class145.Class148.Class149 class1491 = new Class145.Class148.Class149(point2D) { class148_1 = class150 }; class150 = class1491; localMinimumList.Add(class1491); } num1 = num4; point2D = point2D1; } num++; } if (class1480 != null) { class1480(class150); } }
public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove) { // If this spot is considered valid, every item and mobile in this list will be moved under the house sign toMove = new ArrayList(); Map map = from.Map; if (map == null || map == Map.Internal) { return(HousePlacementResult.BadLand); // A house cannot go here } if (from.AccessLevel >= AccessLevel.GameMaster) { return(HousePlacementResult.Valid); // Staff can place anywhere } if (map == Map.Ilshenar || SpellHelper.IsFeluccaT2A(map, center) || SpellHelper.IsEodon(map, center)) { return(HousePlacementResult.BadRegion); // No houses in Ilshenar/T2A/Eodon } if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E)) { return(HousePlacementResult.InvalidCastleKeep); } #region SA if (map == Map.TerMur && !Server.Engines.Points.PointsSystem.QueensLoyalty.IsNoble(from)) { return(HousePlacementResult.NoQueenLoyalty); } #endregion var noHousingRegion = (NoHousingRegion)Region.Find(center, map).GetRegion(typeof(NoHousingRegion)); if (noHousingRegion != null) { return(HousePlacementResult.BadRegion); } // This holds data describing the internal structure of the house MultiComponentList mcl = MultiData.GetComponents(multiID); if (multiID >= 0x13EC && multiID < 0x1D00) { HouseFoundation.AddStairsTo(ref mcl); // this is a AOS house, add the stairs } // Location of the nortwest-most corner of the house Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z); // These are storage lists. They hold items and mobiles found in the map for further processing List <Item> items = new List <Item>(); List <Mobile> mobiles = new List <Mobile>(); // These are also storage lists. They hold location values indicating the yard and border locations. List <Point2D> yard = new List <Point2D>(), borders = new List <Point2D>(); /* RULES: * * 1) All tiles which are around the -outside- of the foundation must not have anything impassable. * 2) No impassable object or land tile may come in direct contact with any part of the house. * 3) Five tiles from the front and back of the house must be completely clear of all house tiles. * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed. * 5) No foundation tile may reside over terrain which is viewed as a road. */ for (int x = 0; x < mcl.Width; ++x) { for (int y = 0; y < mcl.Height; ++y) { int tileX = start.X + x; int tileY = start.Y + y; StaticTile[] addTiles = mcl.Tiles[x][y]; if (addTiles.Length == 0) { continue; // There are no tiles here, continue checking somewhere else } Point3D testPoint = new Point3D(tileX, tileY, center.Z); Region reg = Region.Find(testPoint, map); if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc { if (reg.IsPartOf <TempNoHousingRegion>()) { return(HousePlacementResult.BadRegionTemp); } if (reg.IsPartOf <TreasureRegion>() || reg.IsPartOf <HouseRegion>()) { return(HousePlacementResult.BadRegionHidden); } if (reg.IsPartOf <HouseRaffleRegion>()) { return(HousePlacementResult.BadRegionRaffle); } return(HousePlacementResult.BadRegion); } LandTile landTile = map.Tiles.GetLandTile(tileX, tileY); int landID = landTile.ID & TileData.MaxLandValue; StaticTile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true); Sector sector = map.GetSector(tileX, tileY); items.Clear(); for (int i = 0; i < sector.Items.Count; ++i) { Item item = sector.Items[i]; if (item.Visible && item.X == tileX && item.Y == tileY) { items.Add(item); } } mobiles.Clear(); for (int i = 0; i < sector.Mobiles.Count; ++i) { Mobile m = sector.Mobiles[i]; if (m.X == tileX && m.Y == tileY) { mobiles.Add(m); } } int landStartZ = 0, landAvgZ = 0, landTopZ = 0; map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ); bool hasFoundation = false; for (int i = 0; i < addTiles.Length; ++i) { StaticTile addTile = addTiles[i]; if (addTile.ID == 0x1) // Nodraw { continue; } TileFlag addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags; bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0); bool hasSurface = false; if (isFoundation) { hasFoundation = true; } int addTileZ = center.Z + addTile.Z; int addTileTop = addTileZ + addTile.Height; if ((addTileFlags & TileFlag.Surface) != 0) { addTileTop += 16; } if (addTileTop > landStartZ && landAvgZ > addTileZ) { return(HousePlacementResult.BadLand); // Broke rule #2 } if (isFoundation && ((TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z) { hasSurface = true; } for (int j = 0; j < oldTiles.Length; ++j) { StaticTile oldTile = oldTiles[j]; ItemData id = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue]; if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ) { return(HousePlacementResult.BadStatic); // Broke rule #2 } /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z ) * hasSurface = true;*/ } for (int j = 0; j < items.Count; ++j) { Item item = items[j]; ItemData id = item.ItemData; if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ) { if (item.Movable) { toMove.Add(item); } else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0))) { return(HousePlacementResult.BadItem); // Broke rule #2 } } /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z ) * { * hasSurface = true; * }*/ } if (isFoundation && !hasSurface) { return(HousePlacementResult.NoSurface); // Broke rule #4 } for (int j = 0; j < mobiles.Count; ++j) { Mobile m = mobiles[j]; if (addTileTop > m.Z && (m.Z + 16) > addTileZ) { toMove.Add(m); } } } for (int i = 0; i < m_RoadIDs.Length; i += 2) { if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) { return(HousePlacementResult.BadLand); // Broke rule #5 } } if (hasFoundation) { for (int xOffset = -1; xOffset <= 1; ++xOffset) { for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset) { Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset); if (!yard.Contains(yardPoint)) { yard.Add(yardPoint); } } } for (int xOffset = -1; xOffset <= 1; ++xOffset) { for (int yOffset = -1; yOffset <= 1; ++yOffset) { if (xOffset == 0 && yOffset == 0) { continue; } // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8) int vx = x + xOffset; int vy = y + yOffset; if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height) { StaticTile[] breakTiles = mcl.Tiles[vx][vy]; bool shouldBreak = false; for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i) { StaticTile breakTile = breakTiles[i]; if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface) { shouldBreak = true; } } if (shouldBreak) { continue; } } Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset); if (!borders.Contains(borderPoint)) { borders.Add(borderPoint); } } } } } } for (int i = 0; i < borders.Count; ++i) { Point2D borderPoint = borders[i]; LandTile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y); int landID = landTile.ID & TileData.MaxLandValue; if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0) { return(HousePlacementResult.BadLand); } for (int j = 0; j < m_RoadIDs.Length; j += 2) { if (landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1]) { return(HousePlacementResult.BadLand); // Broke rule #5 } } StaticTile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true); for (int j = 0; j < tiles.Length; ++j) { StaticTile tile = tiles[j]; ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2))) { return(HousePlacementResult.BadStatic); // Broke rule #1 } } Sector sector = map.GetSector(borderPoint.X, borderPoint.Y); List <Item> sectorItems = sector.Items; for (int j = 0; j < sectorItems.Count; ++j) { Item item = sectorItems[j]; if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable) { continue; } ItemData id = item.ItemData; if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2))) { return(HousePlacementResult.BadItem); // Broke rule #1 } } } List <Sector> _sectors = new List <Sector>(); List <BaseHouse> _houses = new List <BaseHouse>(); for (int i = 0; i < yard.Count; i++) { Sector sector = map.GetSector(yard[i]); if (!_sectors.Contains(sector)) { _sectors.Add(sector); if (sector.Multis != null) { for (int j = 0; j < sector.Multis.Count; j++) { if (sector.Multis[j] is BaseHouse) { BaseHouse _house = (BaseHouse)sector.Multis[j]; if (!_houses.Contains(_house)) { _houses.Add(_house); } } } } } } for (int i = 0; i < yard.Count; ++i) { foreach (BaseHouse b in _houses) { if (b.Contains(yard[i])) { return(HousePlacementResult.BadStatic); // Broke rule #3 } } /*Point2D yardPoint = yard[i]; * IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y ); * foreach ( StaticTile[] tile in eable ) * { * for ( int j = 0; j < tile.Length; ++j ) * { * if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 ) * { * eable.Free(); * return HousePlacementResult.BadStatic; // Broke rule #3 * } * } * } * eable.Free();*/ } return(HousePlacementResult.Valid); }
public Class148(Point2D position) { this.point2D_0 = position; }
public bool Contains(Point2D point) { return(this.Contains(point, 8.88178419700125E-16)); }
public Item Construct() { Item item; try { if (m_Type == typeofStatic) { item = new Static(m_ItemID); } #region Mondain's Legacy else if (m_Type == typeof(SecretSwitch)) { int id = 0; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("SecretWall")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { id = Utility.ToInt32(m_Params[i].Substring(++indexOf)); break; } } } Item wall = Decorate.FindByID(id); item = new SecretSwitch(m_ItemID, wall as SecretWall); } else if (m_Type == typeof(SecretWall)) { SecretWall wall = new SecretWall(m_ItemID); for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("MapDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { wall.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("PointDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { wall.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } } item = wall; } #endregion else if (m_Type == typeofLocalizedStatic) { int labelNumber = 0; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("LabelNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { labelNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); break; } } } item = new LocalizedStatic(m_ItemID, labelNumber); } else if (m_Type == typeofLocalizedSign) { int labelNumber = 0; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("LabelNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { labelNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); break; } } } item = new LocalizedSign(m_ItemID, labelNumber); } else if (m_Type == typeofAnkhWest || m_Type == typeofAnkhNorth) { bool bloodied = false; for (int i = 0; !bloodied && i < m_Params.Length; ++i) { bloodied = (m_Params[i] == "Bloodied"); } if (m_Type == typeofAnkhWest) { item = new AnkhWest(bloodied); } else { item = new AnkhNorth(bloodied); } } else if (m_Type == typeofMarkContainer) { bool bone = false; bool locked = false; Map map = Map.Malas; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i] == "Bone") { bone = true; } else if (m_Params[i] == "Locked") { locked = true; } else if (m_Params[i].StartsWith("TargetMap")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { map = Map.Parse(m_Params[i].Substring(++indexOf)); } } } MarkContainer mc = new MarkContainer(bone, locked); mc.TargetMap = map; mc.Description = "strange location"; item = mc; } else if (m_Type == typeofHintItem) { int range = 0; int messageNumber = 0; string messageString = null; int hintNumber = 0; string hintString = null; TimeSpan resetDelay = TimeSpan.Zero; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Range")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("WarningString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("WarningNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("HintString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { hintString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("HintNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { hintNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("ResetDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } HintItem hi = new HintItem(m_ItemID, range, messageNumber, hintNumber); hi.WarningString = messageString; hi.HintString = hintString; hi.ResetDelay = resetDelay; item = hi; } else if (m_Type == typeofWarningItem) { int range = 0; int messageNumber = 0; string messageString = null; TimeSpan resetDelay = TimeSpan.Zero; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Range")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("WarningString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("WarningNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { messageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("ResetDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { resetDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } WarningItem wi = new WarningItem(m_ItemID, range, messageNumber); wi.WarningString = messageString; wi.ResetDelay = resetDelay; item = wi; } else if (m_Type == typeofCannon) { CannonDirection direction = CannonDirection.North; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("CannonDirection")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { direction = (CannonDirection)Enum.Parse(typeof(CannonDirection), m_Params[i].Substring(++indexOf), true); } } } item = new Cannon(direction); } else if (m_Type == typeofSerpentPillar) { string word = null; Rectangle2D destination = new Rectangle2D(); for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Word")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { word = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("DestStart")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { destination.Start = Point2D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEnd")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { destination.End = Point2D.Parse(m_Params[i].Substring(++indexOf)); } } } item = new SerpentPillar(word, destination); } else if (m_Type.IsSubclassOf(typeofBeverage)) { BeverageType content = BeverageType.Liquor; bool fill = false; for (int i = 0; !fill && i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Content")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { content = (BeverageType)Enum.Parse(typeof(BeverageType), m_Params[i].Substring(++indexOf), true); fill = true; } } } if (fill) { item = (Item)Activator.CreateInstance(m_Type, new object[] { content }); } else { item = (Item)Activator.CreateInstance(m_Type); } } else if (m_Type.IsSubclassOf(typeofBaseDoor)) { DoorFacing facing = DoorFacing.WestCW; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Facing")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { facing = (DoorFacing)Enum.Parse(typeof(DoorFacing), m_Params[i].Substring(++indexOf), true); break; } } } item = (Item)Activator.CreateInstance(m_Type, new object[] { facing }); } else { item = (Item)Activator.CreateInstance(m_Type); } } catch (Exception e) { throw new Exception(String.Format("Bad type: {0}", m_Type), e); } if (item is BaseAddon) { if (item is MaabusCoffin) { MaabusCoffin coffin = (MaabusCoffin)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("SpawnLocation")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { coffin.SpawnLocation = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } } } else if (m_ItemID > 0) { List <AddonComponent> comps = ((BaseAddon)item).Components; for (int i = 0; i < comps.Count; ++i) { AddonComponent comp = (AddonComponent)comps[i]; if (comp.Offset == Point3D.Zero) { comp.ItemID = m_ItemID; } } } } else if (item is BaseLight) { bool unlit = false, unprotected = false; for (int i = 0; i < m_Params.Length; ++i) { if (!unlit && m_Params[i] == "Unlit") { unlit = true; } else if (!unprotected && m_Params[i] == "Unprotected") { unprotected = true; } if (unlit && unprotected) { break; } } if (!unlit) { ((BaseLight)item).Ignite(); } if (!unprotected) { ((BaseLight)item).Protected = true; } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is Server.Mobiles.Spawner) { Server.Mobiles.Spawner sp = (Server.Mobiles.Spawner)item; sp.NextSpawn = TimeSpan.Zero; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Spawn")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.CreaturesName.Add(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MinDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.MinDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MaxDelay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.MaxDelay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("NextSpawn")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.NextSpawn = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Count")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Count = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Team")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Team = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("HomeRange")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.HomeRange = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Running")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Running = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Group")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { sp.Group = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } } } else if (item is RecallRune) { RecallRune rune = (RecallRune)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Description")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.Description = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("Marked")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.Marked = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("TargetMap")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.TargetMap = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Target")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { rune.Target = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } } } else if (item is SkillTeleporter) { SkillTeleporter tp = (SkillTeleporter)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Skill")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Skill = (SkillName)Enum.Parse(typeof(SkillName), m_Params[i].Substring(++indexOf), true); } } else if (m_Params[i].StartsWith("RequiredFixedPoint")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Required = Utility.ToInt32(m_Params[i].Substring(++indexOf)) * 0.01; } } else if (m_Params[i].StartsWith("Required")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Required = Utility.ToDouble(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MessageString")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MessageString = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("MessageNumber")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MessageNumber = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("PointDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MapDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Creatures")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SourceEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SoundID")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Delay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is KeywordTeleporter) { KeywordTeleporter tp = (KeywordTeleporter)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Substring")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Substring = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("Keyword")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Keyword = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Range")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Range = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("PointDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MapDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Creatures")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SourceEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SoundID")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Delay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is Teleporter) { Teleporter tp = (Teleporter)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("PointDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.PointDest = Point3D.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("MapDest")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.MapDest = Map.Parse(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Creatures")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Creatures = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SourceEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SourceEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("DestEffect")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.DestEffect = Utility.ToBoolean(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("SoundID")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.SoundID = Utility.ToInt32(m_Params[i].Substring(++indexOf)); } } else if (m_Params[i].StartsWith("Delay")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { tp.Delay = TimeSpan.Parse(m_Params[i].Substring(++indexOf)); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (item is FillableContainer) { FillableContainer cont = (FillableContainer)item; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("ContentType")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { cont.ContentType = (FillableContentType)Enum.Parse(typeof(FillableContentType), m_Params[i].Substring(++indexOf), true); } } } if (m_ItemID > 0) { item.ItemID = m_ItemID; } } else if (m_ItemID > 0) { item.ItemID = m_ItemID; } item.Movable = false; for (int i = 0; i < m_Params.Length; ++i) { if (m_Params[i].StartsWith("Light")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { item.Light = (LightType)Enum.Parse(typeof(LightType), m_Params[i].Substring(++indexOf), true); } } else if (m_Params[i].StartsWith("Hue")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { int hue = Utility.ToInt32(m_Params[i].Substring(++indexOf)); if (item is DyeTub) { ((DyeTub)item).DyedHue = hue; } else { item.Hue = hue; } } } else if (m_Params[i].StartsWith("Name")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { item.Name = m_Params[i].Substring(++indexOf); } } else if (m_Params[i].StartsWith("Amount")) { int indexOf = m_Params[i].IndexOf('='); if (indexOf >= 0) { // Must supress stackable warnings bool wasStackable = item.Stackable; item.Stackable = true; item.Amount = Utility.ToInt32(m_Params[i].Substring(++indexOf)); item.Stackable = wasStackable; } } } return(item); }
public double GetDistance(Point2D point) { return(System.Math.Sqrt(this.GetDistanceSquared(point))); }
public virtual bool Contains(Point2D p) { return(Contains(p.m_X, p.m_Y)); }