示例#1
0
        /// Called for each fixture found in the query AABB.
        /// @return false to terminate the query.
        public bool ReportFixture(FixtureProxy fixtureProxy)
        {
            var fixture = fixtureProxy.fixture;

            if (_count == e_maxCount)
            {
                return false;
            }

            Body body = fixture.GetBody();
            Shape shape = fixture.GetShape();

            Transform xf;
            body.GetTransform(out xf);

            bool overlap = AABB.TestOverlap(shape, 0, _circle, 0, ref xf, ref _transform);

            if (overlap)
            {
                DrawFixture(fixture);
                ++_count;
            }

            return true;
        }
示例#2
0
 public void Init()
 {
     _hasInited    = false;
     EventGroup    = new EventGroup();
     MapConfig     = Logic.Map.Map.Deserialize(Name);
     FixedQuadTree = new FixedQuadTree <SceneObject>();
     FixedQuadTree.SetBounds(new Utility.FixedRect(-FixedMath.One * MapConfig.Width / 2, -FixedMath.One * MapConfig.Height / 2, FixedMath.One * MapConfig.Width, FixedMath.One * MapConfig.Height));
     PhysicsTree = new DynamicTree <FixtureProxy>();
     for (int i = 0; i < MapConfig.Data.Data.Count; i++)
     {
         var stageData = MapConfig.Data.Data[i];
         var aabb      = new AABB(new Vector2d(stageData.X * FixedMath.One + FixedMath.Half, stageData.Y * FixedMath.One + FixedMath.Half), FixedMath.One, FixedMath.One);
         var fp        = new FixtureProxy();
         fp.AABB    = aabb;
         fp.Fixture = new Transform2d()
         {
             p = aabb.Center, angle = 0
         };
         var nodeid = PhysicsTree.AddProxy(ref aabb, fp);
     }
     EventGroup.ListenEvent(SceneEvent.OnLoaded.ToInt(), OnLoded);
 }
示例#3
0
        private void BroadphaseHandler(ref FixtureProxy fp1, ref FixtureProxy fp2)
        {
            if (fp1.Fixture.Body.UserData is Apple && fp2.Fixture.Body.UserData.Equals("Basket"))
            {
                Apple a = (Apple)fp1.Fixture.Body.UserData;
                a.Destroy(world);
                Console.WriteLine("A: " + collectedCount);
                apples.Remove((Apple)fp1.Fixture.Body.UserData);

                if (a.IsEvil())
                {
                    collectedCount = -10;
                }
                else
                {
                    collectedCount++;
                }
            }
            else if (fp2.Fixture.Body.UserData is Apple && fp1.Fixture.Body.UserData.Equals("Basket"))
            {
                Apple a = (Apple)fp2.Fixture.Body.UserData;
                a.Destroy(world);
                Console.WriteLine("B: " + collectedCount);
                apples.Remove((Apple)fp2.Fixture.Body.UserData);
                apples.Remove((Apple)fp2.Fixture.Body.UserData);

                if (a.IsEvil())
                {
                    collectedCount = -10;
                }
                else
                {
                    collectedCount++;
                }
            }
        }
示例#4
0
 public void Setup()
 {
     fixtureProxy = new FixtureProxy();
 }