Exemple #1
0
    private void MoveShot()
    {
        QRegion region = new QRegion(ShotRect());

        timerCount++;

        QRect shotR = ShotRect();

        if (shotR.Intersects(TargetRect()))
        {
            autoShootTimer.Stop();
            Emit.Hit();
            Emit.CanShoot(true);
        }
        else if (shotR.X() > Width() || shotR.Y() > Height() ||
                 shotR.Intersects(BarrierRect()))
        {
            autoShootTimer.Stop();
            Emit.Missed();
            Emit.CanShoot(true);
        }
        else
        {
            region = region.Unite(shotR);
        }

        Update(region);
    }
Exemple #2
0
 private PointRegionQuadtree(uint depth, uint maximumDepth, uint bucketSize, QRegion region)
 {
     this.depth        = depth;
     this.maximumDepth = maximumDepth;
     this.bucketSize   = bucketSize;
     this.region       = region;
 }
Exemple #3
0
 private RegionQuadtree(uint depth, uint maximumDepth, QRegion region, T regionData)
 {
     this.depth        = depth;
     this.maximumDepth = maximumDepth;
     this.region       = region;
     this.data         = regionData;
 }
Exemple #4
0
    private void moveShot()
    {
        QRegion region = new QRegion(shotRect());

        timerCount++;

        QRect shotR = shotRect();

        if (shotR.Intersects(targetRect()))
        {
            autoShootTimer.Stop();
            Emit.hit();
            Emit.canShoot(true);
        }
        else if (shotR.X() > Width() || shotR.Y() > Height())
        {
            autoShootTimer.Stop();
            Emit.missed();
            Emit.canShoot(true);
        }
        else
        {
            region = region.Unite(new QRegion(shotR));
        }

        Update(region);
    }
Exemple #5
0
    private void moveShot()
    {
        QRegion region = new QRegion(shotRect());

        timerCount++;

        QRect shotR = shotRect();

        if (shotR.X() > Width() || shotR.Y() > Height())
        {
            autoShootTimer.Stop();
        }
        else
        {
            region = region.Unite(new QRegion(shotR));
        }
        Update(region);
    }
Exemple #6
0
        public void Subdivide()
        {
            QRegion child0Region = CalculateChildRegion((QQuadrant)0);

            children[0] = new RegionQuadtree <T> (
                depth + 1,
                maximumDepth,
                child0Region,
                CalculateChildData(child0Region)
                );
            QRegion child1Region = CalculateChildRegion((QQuadrant)1);

            children[1] = new RegionQuadtree <T> (
                depth + 1,
                maximumDepth,
                child1Region,
                CalculateChildData(child1Region)
                );
            QRegion child2Region = CalculateChildRegion((QQuadrant)2);

            children[2] = new RegionQuadtree <T> (
                depth + 1,
                maximumDepth,
                child2Region,
                CalculateChildData(child2Region)
                );
            QRegion child3Region = CalculateChildRegion((QQuadrant)3);

            children[3] = new RegionQuadtree <T> (
                depth + 1,
                maximumDepth,
                child3Region,
                CalculateChildData(child3Region)
                );

            foreach (QVector2D point in points)
            {
                InsertInChild(point, data);
            }
            points.Clear();
            InsertInChild(subdivisionPoint, subdivisionPointData);
        }
    private void CreateQuadtree()
    {
        QVector2D origin   = new QVector2D(quadtreeOrigin.x, quadtreeOrigin.y);
        QVector2D halfSize = new QVector2D(quadtreeHalfSize.x, quadtreeHalfSize.y);
        QRegion   region   = new QRegion(origin, halfSize);

        switch (quadtreeType)
        {
        case QuadtreeType.RegionQuadtree:
            quadtree = new RegionQuadtree <byte> (quadtreeMaxDepth, region, RED);
            break;

        case QuadtreeType.PointQuadtree:
            quadtree = new PointQuadtree <byte> (quadtreeMaxDepth, region);
            break;

        case QuadtreeType.PointRegionQuadtree:
            quadtree = new PointRegionQuadtree <byte> (quadtreeMaxDepth, quadtreeBucketSize, region);
            break;
        }
    }
Exemple #8
0
 public static Rectangle convertQRegionToRectangle(QRegion qRegion)
 {
     return(new Rectangle(qRegion.X, qRegion.Y, qRegion.Width, qRegion.Height));
 }
 private PointQuadtree(uint depth, uint maximumDepth, QRegion region)
 {
     this.depth        = depth;
     this.maximumDepth = maximumDepth;
     this.region       = region;
 }
 public PointQuadtree(uint maximumDepth, QRegion region) : this(0, maximumDepth, region)
 {
 }
Exemple #11
0
 public PointRegionQuadtree(uint maximumDepth, uint bucketSize, QRegion region) : this(0, maximumDepth, bucketSize, region)
 {
 }
Exemple #12
0
 private T CalculateChildData(QRegion childRegion)
 {
     return((childRegion.ContainsPoint(subdivisionPoint)) ? subdivisionPointData : data);
 }
Exemple #13
0
 public RegionQuadtree(uint maximumDepth, QRegion region, T regionData) : this(0, maximumDepth, region, regionData)
 {
 }