private void _Selection(Vector2 orgBoxPos, Vector2 endBoxPos) { var r = new Regulus.CustomType.Rect(orgBoxPos.x, Screen.height - orgBoxPos.y, endBoxPos.x - orgBoxPos.x, -1 * ((Screen.height - orgBoxPos.y) - (Screen.height - endBoxPos.y))); var set = GameObject.FindObjectOfType <VGame.Project.FishHunter.FishSet>(); var fishs = set.Query(r); if (fishs.Length > 0) { Debug.Log("fishs.Length : " + fishs.Length); } }
public void TestMapFind() { Map map = new Map(); Rect rect = new Rect(0.5f ,5,1,10); Polygon meshs1 = new Polygon(new[]{ new Vector2(1, 1), new Vector2(2, 1), new Vector2(2, 2), new Vector2(1, 2) }); Polygon meshs2 = new Polygon(new[]{ new Vector2(1, 1), new Vector2(2, 1), new Vector2(2, 2), new Vector2(1, 2) }); Polygon meshs3 = new Polygon(new[]{ new Vector2(1, 1), new Vector2(2, 1), new Vector2(2, 2), new Vector2(1, 2) }); Polygon meshs4 = new Polygon(new[]{ new Vector2(1, 1), new Vector2(2, 1), new Vector2(2, 2), new Vector2(1, 2) }); Polygon meshs5 = new Polygon(new[]{ new Vector2(1, 1), new Vector2(2, 1), new Vector2(2, 2), new Vector2(1, 2) }); meshs2.Offset(0,2); meshs3.Offset(0, 4); meshs4.Offset(0, 6); meshs5.Offset(0, 8); IIndividual[] visables = { new Entity(meshs1), new Entity(meshs2), new Entity(meshs3), new Entity(meshs4), new Entity(meshs5) }; foreach (var visable in visables) { map.JoinStaff(visable); } IMapFinder finder = map; var results = finder.Find(rect); foreach (var visable in visables) { map.Left(visable); } Assert.AreEqual(5, results.Length); }
public Orbit(Polygon body, Vector2 velocity) { List<Vector2> points = new List<Vector2>(); points.AddRange(body.Points); var polygon = body.Clone(); polygon.Offset(velocity); points.AddRange(polygon.Points); _Rect = points.ToRect(); }
private void _UpdateBounds(float left, float top, ref Rect bounds) { bounds.Location = new Point(left, top); if (BoundsChanged != null) BoundsChanged(this, new EventArgs()); }
public PhysicalAbility(Rect bounds ,Entity owner) { _Bounds = bounds; }
public bool Contains(Rect rect) { return X <= rect.X && Y <= rect.Y && X + Width >= rect.X + rect.Width && Y + Height >= rect.Y + rect.Height; }
public bool IntersectsWith(Rect rect) { return (rect.Left <= Right) && (rect.Right >= Left) && (rect.Top <= Bottom) && (rect.Bottom >= Top); }
private void _UpdateBound() { this._Bound = this._BuildBound(this._Mesh); if (this._BoundsEvent != null) { this._BoundsEvent.Invoke(); } }
private Rect _BuildVidw() { var center = this._Mesh.Center; var hw = this._View / 2; var hh = this._View / 2; var rect = new Rect(center.X - hw, center.Y - hh, this._View, this._View); return rect; }
public void _SetBody(Polygon body) { _Mesh = body.Clone(); _Bound = this._BuildBound(this._Mesh); _DetectionRange = 1.0f + _Mesh.Points.ToRect().Width; }
public void UpdatePosition(Vector2 velocity) { if (velocity.X == 0 && velocity.Y == 0) return; this._Mesh.Offset(velocity); this._Bound = this._BuildBound(this._Mesh); if (this._BoundsEvent != null) this._BoundsEvent.Invoke(); }
IIndividual[] IMapFinder.Find(Rect bound) { var results = this._QuadTree.Query(bound); return (from r in results select r.Noumenon).ToArray(); }
public void TestRectLeftToCenter() { Rect rect = new Rect(0,1,1,1); var result = rect.LeftToCenter(); Assert.AreEqual(-0.5f, result.X); Assert.AreEqual(0.5f, result.Y); Assert.AreEqual(1, result.Width); Assert.AreEqual(1, result.Height); }