Exemple #1
0
    private bool IsPlanetInCamera(int planetIndex, [NotNull] IAABBox cameraBox, [NotNull] QuadTreeLeaf visitedLeaf)
    {
        var planetData   = visitedLeaf.GetPlanetData(planetIndex);
        var cameraTop    = cameraBox.GetY() + cameraBox.GetHeight() / 2f;
        var cameraBottom = cameraTop - cameraBox.GetHeight();
        var cameraLeft   = cameraBox.GetX() - cameraBox.GetWidth() / 2f;
        var cameraRight  = cameraLeft + cameraBox.GetWidth();

        if ((cameraTop >= planetData.Y && cameraBottom <= planetData.Y) &&
            (cameraLeft <= planetData.X && cameraRight >= planetData.X))
        {
            return(true);
        }

        return(false);
    }
Exemple #2
0
 public bool IsIntersect(IAABBox other)
 {
     return((Math.Abs(mX - other.GetX()) * 2 < (mWidth + other.GetWidth())) &&
            (Math.Abs(mY - other.GetY()) * 2 < (mHeight + other.GetHeight())));
 }
Exemple #3
0
 public bool IsIntersect(IAABBox other)
 {
     return((Math.Abs(GetX() - other.GetX()) * 2 < (GetWidth() + other.GetWidth())) &&
            (Math.Abs(GetY() - other.GetY()) * 2 < (+other.GetHeight())));
 }
Exemple #4
0
        public PlanetData GetPlanetData(int index)
        {
            // ReSharper disable once PossibleNullReferenceException
            var data     = mPlanetRawData[index];
            var score    = data / mConstants.GetCellsInSector();
            var posLocal = data - score * mConstants.GetMaxPlanetScore();
            var posLocY  = posLocal / mConstants.GetSectorSideSize();
            var posLocX  = posLocal - posLocY * mConstants.GetSectorSideSize();

            return(new PlanetData(mBox.GetX() - mBox.GetWidth() / 2 + posLocX, mBox.GetY() + mBox.GetHeight() / 2 - posLocY, score));
        }