Exemple #1
0
    /// <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)));
    }
Exemple #2
0
    public static Rect ReturnDimOnMap(List <Vector3> poly)
    {
        Rect to = U2D.FromPolyToRect(poly);

        to = U2D.ReturnRectYInverted(to);
        return(to);
    }
Exemple #3
0
    /// <summary>
    /// Will add a poly with the seq NW, NE, SE, SW to the _allBuilding List. then will call UpdateCurrentVertexRect()
    /// Adds the file to Registro All that is the save list to file of buildings
    /// </summary>
    public void AddBuildToAll(Building build, List <Vector3> poly, Ca categ, Vector3 iniPosition,
                              Inventory inventory,
                              List <string> PeopleDict,
                              List <VectorLand> LandZone1,
                              List <Vector3> polyHoriz       = null,
                              List <Vector3> tilePosVert     = null, List <Vector3> tilePosHor = null, List <Vector3> planesOnAirPos = null,
                              Vector3 tileScale              = new Vector3(), List <int> parts = null,
                              H dominantSide                 = H.None, H startingStage = H.None, int rotationFacerIndex        = -1, string materialKey = "",
                              List <Vector3> planesOnSoilPos = null, List <int> partsOnSoil = null, Vector3 min                = new Vector3(),
                              Vector3 max                     = new Vector3(), H instructionP = H.None, BookedHome BookedHome1 = null,
                              Dispatch dispatch               = null, Family[] Families       = null,
                              int dollarsPay                  = 0,
                              List <Vector3> anchors          = null, Dock dock = null, string root = "",
                              BuildersManager buildersManager = null
                              )
    {
        // 12 hours to find this OMG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // I was creating the recatblgele and not inverting Y.. then I invert Y but didint inverted in
        //IsColliding() chet !!!! And i knew it bz i inverted the big rectangle...
        //with the rectangles inverted works like a charm... we have to do it bz im using North as bigger
        //and south as less... in the Rect cordinates is the other way around

        //this is the usual poly will be filled for eg regular structures only use this one.
        //For ways is the vertic bound
        var to = ReturnDimOnMap(poly);

        Rect toHoriz = new Rect();

        if (polyHoriz != null)
        {
            toHoriz = U2D.FromPolyToRect(polyHoriz);
            toHoriz = U2D.ReturnRectYInverted(toHoriz);
        }

        //ading to All
        RegFile regFile = new RegFile(build, to, categ, iniPosition,
                                      inventory,
                                      PeopleDict, LandZone1,
                                      toHoriz, tilePosVert: tilePosVert, tilePosHor: tilePosHor,
                                      planesOnAirPos: planesOnAirPos, tileScale: tileScale, partsOnAir: parts, dominantSide: dominantSide, startingStage: startingStage, rotationFacerIndex: rotationFacerIndex,
                                      materialKey: materialKey, planesOnSoilPos: planesOnSoilPos, partsOnSoil: partsOnSoil, min: min, max: max,
                                      instructionP: instructionP, bookedHome: BookedHome1, dispatch: dispatch, familes: Families,
                                      dollarsPay: dollarsPay,
                                      anchors: anchors, dock: dock, root: root,
                                      buildersManager: buildersManager);

        //UVisHelp.CreateHelpers(anchors, Root.blueCube);
        AddToAll(regFile);
        AddToBuilderManager(build.MyId);

        AddSpecToList(categ);
        if (_locHoverVert.Count > 0)
        {
            UpdateCurrentVertexRect(_locHoverVert);
        }
        //use on the drawing debug functionalitie only:
        //toDraw.Add(to);
        //toDraw.Add(toHoriz);
    }
Exemple #4
0
    /// <summary>
    /// Syas if param is on terrain
    ///
    /// Needs to be Testet
    /// </summary>
    public static bool IsOnTerrain(Vector3 a)
    {
        Rect terra = U2D.FromPolyToRect(Program.gameScene.controllerMain.MeshController.wholeMalla);

        terra = U2D.ReturnRectYInverted(terra);//must be inverted to be on same Y values

        if (terra.Contains(new Vector2(a.x, a.z)))
        {
            return(true);
        }

        return(false);
    }
Exemple #5
0
Fichier : Way.cs Projet : Cdrix/SM
    List <Rect> CreateRects(List <PreviewWay> prevP)
    {
        List <Rect> res = new List <Rect>();

        for (int i = 0; i < _indexesOfEdgesShore.Count; i++)
        {
            List <Vector3> boundPoint = prevP[_indexesOfEdgesShore[i]].GetBounds();
            boundPoint = UPoly.ScalePoly(boundPoint, 0.3f);

            Rect boundRect = U2D.FromPolyToRect(boundPoint);
            boundRect = U2D.ReturnRectYInverted(boundRect);
            res.Add(boundRect);
        }
        return(res);
    }
Exemple #6
0
    /// <summary>
    /// If the object pass is colliding with any rectangle of the currentBuilding List returns true
    /// </summary>
    /// <param name="poly">Object being place on terrain</param>
    /// <returns></returns>
    public bool IsCollidingWithExisting(List <Vector3> poly)
    {
        ///////////////////////////////////////////////////////////**********************************************
        // 12 hours to find this OMG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // I was creating the recatblgele and not inverting Y.. then I invert Y but didint inverted in
        //IsColliding() cheat !!!! And i knew it bz i inverted the big rectangle...
        //with the rectangles inverted works like a charm... we have to do it bz im using North as bigger
        //and south as leess... in the Rect cordinates is the other way arounds
        Rect polyPass = U2D.FromPolyToRect(poly);

        polyPass = U2D.ReturnRectYInverted(polyPass);
        curr     = polyPass;

        //make hover bigger  4 hours  BUGGGGGGGGGGGGGGGGGGGGGGGGGG
        //for (int i = 0; i < _hover.Count; i++)
        //{
        //    if (_hover[i].IsCollidingWithMe(polyPass))
        //    {
        //        return true;
        //    }
        //}

        //have to changed to be always colliding instead we can check that all are not colliding
        //this is to correct a bugg where u can click really fast and structures will build on top
        //of wach others

        bool res   = true;
        int  count = 0;

        for (int i = 0; i < _allRegFile.Count; i++)
        {
            if (!_allRegFile[i].IsCollidingWithMe(polyPass))
            {
                count++;
            }
            else
            {
                var a = 1;
            }
        }

        //if all the obj are not colliding then...
        if (count == _allRegFile.Count)
        {
            res = false;
        }
        return(res);
    }
Exemple #7
0
    private bool IntersectMyRouteArea(Rect other, int index)
    {
        List <Vector3> e = Elements[index].Poly;

        //means doesnt have Anchors set.. for ex Ways like road
        if (e.Count == 0)
        {
            return(false);
        }

        Rect a = U2D.ReturnRectYInverted(U2D.FromPolyToRect(e));

        if (a.Overlaps(other))
        {
            return(true);
        }
        return(false);
    }
Exemple #8
0
    bool IsCurrInsideOldHome(Crystal c)
    {
        bool isInside = false;

        var oldHome = Brain.GetBuildingFromKey(_person.Brain.MoveToNewHome.OldHomeKey);

        if (oldHome != null && oldHome != _person.Home)
        {
            var oldHomRect = U2D.FromPolyToRect(oldHome.Anchors);
            oldHomRect = U2D.ReturnRectYInverted(oldHomRect);
            isInside   = oldHomRect.Contains(_curr.Position);
        }

        if (isInside)
        {
            //Debug.Log("Inside build");
        }

        return(isInside);
    }
Exemple #9
0
    /// <summary>
    /// The poly pass shoud be really really small like a point. to this be effcective
    /// Created to find what is coliiding with a Tile
    /// </summary>
    /// <param name="poly"></param>
    /// <returns></returns>
    public H IsCollidingWithWhat(List <Vector3> poly)
    {
        ///////////////////////////////////////////////////////////**********************************************
        // 12 hours to find this OMG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        // I was creating the recatblgele and not inverting Y.. then I invert Y but didint inverted in
        //IsColliding() cheat !!!! And i knew it bz i inverted the big rectangle...
        //with the rectangles inverted works like a charm... we have to do it bz im using North as bigger
        //and south as leess... in the Rect cordinates is the other way arounds
        Rect polyPass = U2D.FromPolyToRect(poly);

        polyPass = U2D.ReturnRectYInverted(polyPass);
        curr     = polyPass;

        for (int i = 0; i < _allRegFile.Count; i++)
        {
            if (_allRegFile[i].IsCollidingWithMe(polyPass))
            {
                return(_allRegFile[i].HType);
            }
        }

        return(H.None);
    }
Exemple #10
0
    private Structure inside;//the structure current point is inside
    /// <summary>
    /// Returns true if inside a Registro.Structures... sets 'inside' as the building the 't' is in
    /// </summary>
    /// <param name="t"></param>
    /// <returns></returns>
    bool IAmInsideABuildNow(Vector3 t)
    {
        var  pos      = t;
        var  p2       = new Vector2(pos.x, pos.z);
        var  allBuild = BuildingPot.Control.Registro.Structures.ToArray();
        bool res      = false;
        Rect rect     = new Rect();

        for (int i = 0; i < allBuild.Length; i++)
        {
            rect = U2D.ReturnRectYInverted(U2D.FromPolyToRect(allBuild[i].Value.Anchors));
            if (rect.Contains(p2))
            {
                inside = allBuild[i].Value;
                res    = true;
                Program.gameScene.AddToMainScreen("Router point inside building:" + allBuild[i].Key);

                //Debug.Log("Router point inside building:" + allBuild[i].Key);
                //throw new Exception("Router point inside building:" + allBuild[i].Key);
            }
        }
        return(res);
    }
Exemple #11
0
    public static bool IsOnTerrainManipulateTerrainSize(Vector3 a, float manipulateBy)
    {
        //bz kkeeps getting smaller
        //if (terrainPolyScaled == null)
        //{
        //bz was referencing that List
        var array = Program.gameScene.controllerMain.MeshController.wholeMalla.ToArray();

        terrainPolyScaled = UPoly.ScalePoly(array.ToList(), manipulateBy);
        //}

        Rect terra = U2D.FromPolyToRect(terrainPolyScaled);

        terra = U2D.ReturnRectYInverted(terra);//must be inverted to be on same Y values
        UVisHelp.CreateDebugLines(terra, Color.yellow);

        if (terra.Contains(new Vector2(a.x, a.z)))
        {
            return(true);
        }

        return(false);
    }