示例#1
0
文件: Way.cs 项目: Cdrix/SM
    void UpdateBigBoxesPrev()
    {
        InitializeBigBoxPrev();

        float diffYVertic = UMath.ReturnDiffBetwMaxAndMin(_verticPathNew, H.Y);
        float diffYHoriz  = UMath.ReturnDiffBetwMaxAndMin(_horPathNew, H.Y);
        float biggestDiff = UMath.ReturnMax(diffYVertic, diffYHoriz);

        List <float> yS = UList.ReturnAxisList(_verticPathNew, H.Y);

        yS.AddRange(UList.ReturnAxisList(_horPathNew, H.Y));
        float maxY = UMath.ReturnMax(yS);

        if (_dominantSide == H.Vertic)
        {
            var locVertBound = MakeListYVal(BoundsVertic, maxY);
            verticBigBox.UpdatePos(locVertBound, biggestDiff + 0.5f);
            verticBigBox.CheckAndSwitchColor(_isWayOK);
        }
        else if (_dominantSide == H.Horiz)
        {
            var locHorBound = MakeListYVal(BoundsHoriz, maxY);
            horizBigBox.UpdatePos(locHorBound, biggestDiff + 0.5f);
            horizBigBox.CheckAndSwitchColor(_isWayOK);
        }
        //this is for all but bridges and DraggableSquare. Dominant Side here is None
        else if (_dominantSide == H.None && !HType.ToString().Contains("Bridge") && Category != Ca.DraggableSquare)
        {
            UpdateBigBoxesPrevForAllButBridges(maxY, biggestDiff);
        }

        TogglePrevBigBoxesVisible();
    }
示例#2
0
文件: Registro.cs 项目: Cdrix/SM
    /// <summary>
    /// Taken a list of vectors 3 will find NW, NE, and SW and from there will create a new rectangle
    /// Returns a rectangle in our system where North is on the higher Y value always
    ///
    /// Y val flipped at the end
    /// </summary>
    public static Rect FromALotOfVertexToRect(List <Vector3> list)
    {
        List <float> xS = UList.ReturnAxisList(list, H.X);
        List <float> zS = UList.ReturnAxisList(list, H.Z);

        float minX = UMath.ReturnMinimum(xS);
        float maxX = UMath.ReturnMax(xS);

        float minZ = UMath.ReturnMinimum(zS);
        float maxZ = UMath.ReturnMax(zS);

        //Poly List that only need a valid NW, NE, and SW
        Vector3 NW = new Vector3(minX, 0, maxZ);
        Vector3 NE = new Vector3(maxX, 0, maxZ);
        Vector3 SE = new Vector3(maxX, 0, minZ);
        Vector3 SW = new Vector3(minX, 0, minZ);

        List <Vector3> poly = new List <Vector3>()
        {
            NW, NE, SE, SW
        };

        //here i find the Rect from this poly and then
        // I invert the Y of the recatangle... other wise this big rectangle
        //is not overlapping anything will be far off in the Cordinates...
        //Due to North(up) is bigger here say 100,, and South(down) less say 0 all this on World Z axis
        //As long as MeshManager Hover Current Vertices is big as is its now 9 Lots (each lot 5x5 real polys)
        //the Rect of the buildings will work flawlessly
        return(U2D.ReturnRectYInverted(U2D.FromPolyToRect(poly)));
    }
示例#3
0
文件: Way.cs 项目: Cdrix/SM
    /// <summary>
    /// If the minimun of the both path is higher than _minHeightToSpawn is true
    /// </summary>
    bool FindIFWayAboveWater()
    {
        bool  res      = false;
        float minYVert = 0;
        float minYHor  = 0;

        if (_verticPathNew.Count > 0)
        {
            var vertYs = UList.ReturnAxisList(_verticPathNew, H.Y);
            minYVert = UMath.ReturnMinimum(vertYs);
            if (minYVert > _minHeightToSpawn)
            {
                res = true;
            }
        }
        if (_horPathNew.Count > 0)
        {
            var horYs = UList.ReturnAxisList(_horPathNew, H.Y);
            minYHor = UMath.ReturnMinimum(horYs);
            if (minYHor > _minHeightToSpawn)
            {
                res = true;
            }
        }
        if (_verticPathNew.Count > 0 && _horPathNew.Count > 0)
        {
            var min = UMath.ReturnMinimum(minYVert, minYHor);
            if (min > _minHeightToSpawn)
            {
                res = true;
            }
        }

        return(res);
    }
示例#4
0
文件: SubPolyr.cs 项目: Cdrix/SM
    //Returns first row list based on the rotation facer
    private List <Vector3> ReturnFirstRow(List <Vector3> listSelected, int rotationFacer)
    {
        List <Vector3> res = new List <Vector3>();

        if (rotationFacer == 0)
        {
            List <float> allZ = UList.ReturnAxisList(listSelected, H.Z);
            float        zMax = UMath.ReturnMax(allZ);
            res = FirstRowLoop(listSelected, zMax, H.Z);
        }
        else if (rotationFacer == 1)
        {
            List <float> allX = UList.ReturnAxisList(listSelected, H.X);
            float        xMax = UMath.ReturnMax(allX);
            res = FirstRowLoop(listSelected, xMax, H.X);
        }
        else if (rotationFacer == 2)
        {
            List <float> allZ = UList.ReturnAxisList(listSelected, H.Z);
            float        zMin = UMath.ReturnMinimum(allZ);
            res = FirstRowLoop(listSelected, zMin, H.Z);
        }
        else if (rotationFacer == 3)
        {
            List <float> allX = UList.ReturnAxisList(listSelected, H.X);
            float        xMin = UMath.ReturnMinimum(allX);
            res = FirstRowLoop(listSelected, xMin, H.X);
        }
        return(res);
    }
示例#5
0
    /// <summary>
    /// Return the diff btw max value and min value
    /// </summary>
    public static float ReturnDiffBetwMaxAndMin(List <Vector3> list, H axis)
    {
        float res = 0;

        if (axis == H.Y)
        {
            List <float> yS  = UList.ReturnAxisList(list, axis);
            float        min = ReturnMinimum(yS);
            float        max = ReturnMax(yS);
            res = Mathf.Abs(Mathf.Abs(max) - Mathf.Abs(min));
        }
        return(res);
    }
示例#6
0
文件: UList.cs 项目: naaturaz/SM
    /// <summary>
    /// Find the common values of the 'list' on the 'axis' passed.
    /// For ex: is used to find all the values of Y in the mesh
    ///
    /// Will order by if 'order' was specified
    /// </summary>
    /// <param name="axis"></param>
    /// <param name="list"></param>
    /// <returns></returns>
    public static List <float> FindXAxisCommonValues(List <Vector3> list, H order)
    {
        if (order == H.Descending)
        {
            list = list.OrderByDescending(a => a.x).ToList();
        }
        else if (order == H.Ascending)
        {
            list = list.OrderBy(a => a.x).ToList();
        }

        var res = UList.ReturnAxisList(list, H.X);

        res = res.Distinct().ToList();

        return(res);
    }
示例#7
0
文件: Way.cs 项目: Cdrix/SM
    bool TellMeIfTopOnesAreEven(List <Vector3> list)
    {
        List <float> yS           = UList.ReturnAxisList(list, H.Y);
        float        planesOnAirY = FindPlanesOnAirHeight();

        for (int i = 0; i < list.Count; i++)
        {
            if (list[i].y > planesOnAirY)
            {
                float diff = Mathf.Abs(planesOnAirY - list[i].y);
                if (diff > _maxDiffAllowOnTerrainForARoad)
                {
                    return(false);
                }
            }
        }
        return(true);
    }
示例#8
0
文件: UPoly.cs 项目: Cdrix/SM
    //will even many polys in Y. this Method has a bug that
    //put all vertices toghether
    public List <Vector3> EvenInYManyPolys(List <Vector3> manyPoly, ref Vector3[] vertices, ref bool isToEven,
                                           float maxHeightForEven, ref float minY)
    {
        float maxY = UMath.ReturnMax(UList.ReturnAxisList(manyPoly, H.Y));

        minY = UMath.ReturnMinimum(UList.ReturnAxisList(manyPoly, H.Y));
        float heightDiff = maxY - minY;

        if (heightDiff >= maxHeightForEven)
        {
            isToEven = false;
            return(manyPoly);
        }

        isToEven = true;
        //print(heightDiff + " heightDiff");

        for (int i = 0; i < manyPoly.Count; i++)
        {
            Vector3 newModifiedYPos = manyPoly[i];
            newModifiedYPos.y = minY;
            manyPoly[i]       = newModifiedYPos;
        }

        float epsilon = 0.1f;

        for (int i = 0; i < vertices.Length; i++)
        {
            for (int j = 0; j < manyPoly.Count; j++)
            {
                //if this are the same in X and Z we are updating
                bool x = UMath.nearlyEqual(vertices[i].x, manyPoly[j].x, epsilon);
                bool z = UMath.nearlyEqual(vertices[i].z, manyPoly[j].z, epsilon);
                if (x && z)
                {   //updating the whole vertices matrix
                    vertices[i] = manyPoly[j];
                }
            }
        }
        return(manyPoly);
    }
示例#9
0
文件: Registro.cs 项目: Cdrix/SM
    /// <summary>
    /// This one use Y as MathCenter
    /// </summary>
    /// <param name="list"></param>
    /// <returns></returns>
    public static List <Vector3> FromALotOfVertexToPolyMathCenterY(List <Vector3> list)
    {
        List <float> xS = UList.ReturnAxisList(list, H.X);
        List <float> zS = UList.ReturnAxisList(list, H.Z);

        float minX = UMath.ReturnMinimum(xS);
        float maxX = UMath.ReturnMax(xS);

        float minZ = UMath.ReturnMinimum(zS);
        float maxZ = UMath.ReturnMax(zS);

        //Poly List that only need a valid NW, NE, and SW
        SMe m = new SMe();
        //throwing rays so we keep the exact Y values
        Vector3 NW = new Vector3(minX, m.IniTerr.MathCenter.y, maxZ);
        Vector3 NE = new Vector3(maxX, m.IniTerr.MathCenter.y, maxZ);
        Vector3 SE = new Vector3(maxX, m.IniTerr.MathCenter.y, minZ);
        Vector3 SW = new Vector3(minX, m.IniTerr.MathCenter.y, minZ);

        return(new List <Vector3>()
        {
            NW, NE, SE, SW
        });
    }