Esempio n. 1
0
    public void AddOnRegistro()
    {
        if (HType == H.BullDozer)
        {
            return;
        }

        //so the rect for collision is bigger
        //to address SpawnPoint not falling into another build
        var scale = UPoly.ScalePoly(Bounds, 0.2f);

        //var scale = Anchors;

        //startin satge is save on ReSaveStartinStage()
        BuildingPot.Control.Registro.AddBuildToAll(this, scale, Category, transform.position,
                                                   Inventory,
                                                   PeopleDict,
                                                   LandZone1,
                                                   rotationFacerIndex: RotationFacerIndex, materialKey: MaterialKey,
                                                   instructionP: Instruction, BookedHome1: BookedHome1,
                                                   dispatch: Dispatch1, Families: Families,
                                                   dollarsPay: DollarsPay,
                                                   anchors: Anchors, dock: Dock1, root: RootBuilding
                                                   );
    }
Esempio n. 2
0
    /// <summary>
    /// Will create the poly small. on the direction and will find if is coliiding with another
    /// </summary>
    /// <param name="dir"></param>
    /// <returns></returns>
    private List <Vector3> ReturnPolyToEval(Tile dir)
    {
        var x   = m.SubDivide.XSubStep;
        var z   = m.SubDivide.ZSubStep;
        var pos = new Vector3();

        if (dir == Tile.N)
        {
            pos = new Vector3(transform.position.x, transform.position.y, transform.position.z + z);
        }
        else if (dir == Tile.S)
        {
            pos = new Vector3(transform.position.x, transform.position.y, transform.position.z - z);
        }
        else if (dir == Tile.W)
        {
            pos = new Vector3(transform.position.x - x, transform.position.y, transform.position.z);
        }
        else if (dir == Tile.E)
        {
            pos = new Vector3(transform.position.x + x, transform.position.y, transform.position.z);
        }
        //UVisHelp.CreateHelpers(pos, Root.blueCube);
        return(UPoly.CreatePolyFromVector3(pos, 0.01f, 0.01f));
    }
Esempio n. 3
0
File: Router.cs Progetto: Cdrix/SM
    /// <summary>
    /// Add Current hit point but first needs to move it away from buiding
    /// </summary>
    void AddCurrentHit()
    {
        Dir[] dirsSimpleMap = new Dir[] { Dir.N, Dir.E, Dir.S, Dir.W };
        float moveBy        = _person.PersonDim * 2;

        Vector3[] moveAway = new Vector3[]
        {
            new Vector3(0, 0, moveBy), new Vector3(moveBy, 0, 0),
            new Vector3(0, 0, -moveBy), new Vector3(-moveBy, 0, 0)
        };
        Dir buildWasHitOn = UDir.TellMeWhenHitLanded(currBuilding.Anchors, vectorHit.HitPoint);

        //is needed here so it moves foward along the side and not to the cloeset that coluld be accross the biuilding
        Vector3 otherAnchorOnSide = UPoly.FindOtherCornerOnSide(currBuilding.Anchors, buildWasHitOn, closestAnchorToOrigin);
        var     sideAnchors       = ReturnFirstAndLast(_fin, otherAnchorOnSide, closestAnchorToOrigin);

        anchorOnSideClosestToFin = sideAnchors[0];//the anchor on the side is closer to _fin

        for (int i = 0; i < dirsSimpleMap.Length; i++)
        {
            if (dirsSimpleMap[i] == buildWasHitOn)
            {
                //is moving the vector hit away given the direction
                Vector3 t = vectorHit.HitPoint + moveAway[i];
                t.y = m.IniTerr.MathCenter.y;//so is on same Y value

                t = Sanitize(t);
                //_person.DebugList.Add(UVisHelp.CreateText(t, hitCurrentAdded.ToString()));
                _checkPoints.Add(new CheckPoint(t));
                return;
            }
        }
    }
Esempio n. 4
0
    private void DefineFarmNWandSE()
    {
        var poly = UPoly.RetTerrainPoly(_min, _max, Dir.SWtoNE);

        _NW = poly[0];
        _SE = poly[2];
    }
Esempio n. 5
0
    private void CreateBasePlane()
    {
        var dimen = _fieldFarm.SpaceBtwPlants - 0.5f;

        var locPoly   = UPoly.CreatePolyFromVector3(transform.position, dimen, dimen);
        var basePlane = CreatePlane.CreatePlan(Root.createPlane, Root.matFarmSoil, raiseFromFloor: 0.08f, container: transform);

        basePlane.UpdatePos(locPoly);
    }
Esempio n. 6
0
    /// <summary>
    /// This method handles and deals with the if is to big or if a side is to small
    /// Then calls the method that Colors the Preview
    /// </summary>
    void ChecksCollSizeCallsColor()
    {
        //doing this bz the poly on X and Z really in real term will collide with next one that why
        //is reduced a bit so it can allow right next ones to be placed
        List <Vector3> localOnScreenPoly = UPoly.ScalePoly(OnScreenPoly, reduceOnXLocalOnScreenPoly);

        List <Vector3> localSoilList = RetuFillPolyRealY(localOnScreenPoly[0], localOnScreenPoly[2], Mathf.Abs(m.SubDivide.XSubStep),
                                                         Mathf.Abs(m.SubDivide.ZSubStep), true);

        //too big
        bool isToBig = false;

        if (localSoilList.Count > maxSizeOfFarm)
        {
            isToBig = true;
        }

        //too small
        bool isToSmall = false;

        if (!isToBig)
        {
            float xDiff = Mathf.Abs(localOnScreenPoly[0].x - localOnScreenPoly[1].x);
            float zDiff = Mathf.Abs(localOnScreenPoly[0].z - localOnScreenPoly[3].z);
            if (xDiff < minSideLenght || zDiff < minSideLenght)
            {
                if (HType != H.Road)//this means that road can have any small size
                {
                    isToSmall = true;
                }
            }
        }

        //is colliding
        bool isColliding = false;

        if (!isToBig && !isToSmall)
        {
            isColliding = BuildingPot.Control.Registro.IsCollidingWithExisting(localOnScreenPoly);
        }

        bool isEvenFarm = false;

        if (!isColliding && !isToBig && !isToSmall)
        {
            isEvenFarm = CheckIfIsEven(localSoilList, 0.01f);
        }

        if (isEvenFarm)
        {
            isEvenFarm = ItIsOnRange();
        }

        //only using isEvenFarm bz if any bfeore is false. EvenFarm will be false too
        SetFarmOkAndHandleColor(isEvenFarm);
    }
Esempio n. 7
0
    private List <Crystal> ReturnScaledAnchors(Vector3[] anchors, string myIDP)
    {
        List <Crystal> res = new List <Crystal>();

        anchors = UPoly.ScalePoly(anchors, scale);

        for (int i = 0; i < anchors.Length; i++)
        {
            res.Add(new Crystal(anchors[i], H.Obstacle, myIDP, setIdAndName: false));
        }
        return(res);
    }
Esempio n. 8
0
    /// <summary>
    /// Moves all the building to the new spot
    /// </summary>
    /// <param name="randIniPos"></param>
    /// <param name="bData"></param>
    private static void MoveAllBuildingsToNewSpot(BuildingData bData, Vector3 spot, List <Vector3> list)
    {
        difference = spot - UPoly.MiddlePoint(list);

        for (int i = 0; i < bData.All.Count; i++)
        {
            var newPos = bData.All[i].IniPos + difference;
            //its is important to get the newPOs in the closest vertex so is aling with new buildings to
            //spawn by user
            //newPos = m.Vertex.FindClosestVertex(newPos, m.AllVertexs.ToArray());
            bData.All[i].IniPos = newPos;
        }
    }
Esempio n. 9
0
    /// <summary>
    /// Will return the build or way hitt by mouse position
    /// </summary>
    /// <returns></returns>
    private Transform ReturnBuildinHit()
    {
        //used to be UPoly.RayCastAll()
        Transform clicked = UPoly.RayCastLayer(Input.mousePosition, 10).transform;//10: personBlock

        //Removed bz was pulling the Previews of the Buildiggs and in that way will select that building
        ////try ways then
        //if (clicked == null)
        //{
        //    clicked = UPoly.RayCastLayer(Input.mousePosition, 12).transform;//12: way
        //}

        return(clicked);
    }
Esempio n. 10
0
File: SubPolyr.cs Progetto: Cdrix/SM
    //Return the subpolygons selected ... this are fake subpolygons... a bunch of them
    public List <Vector3> SubPolygonsSelected(int cols, int rows, ref List <Vector3> objsHitTerrain,
                                              Vector3 iniHit, SubDivider subDivide, int rotationFacer, bool isMouseOnTerrain,
                                              Vertexer vertex, UPoly poly, List <Vector3> currentHoverVertices)
    {
        List <Vector3> subPolys = new List <Vector3>();

        subPolys = CreateListSelected(ref objsHitTerrain, cols, rows, iniHit, subDivide, isMouseOnTerrain,
                                      vertex, poly, currentHoverVertices);
        //print(cols + ".c||r."+rows+ " ini:."+iniHit);
        //print(objsHitTerrain.Count + " objsHitTerrain.cou");
        //print(subPolys.Count + " subPolys.coun");
        //List<Vector3> firstRow = ReturnFirstRow(subPolys, rotationFacer);
        return(subPolys);
    }
Esempio n. 11
0
    /// <summary>
    /// This is how I send the farm to registro that later if user wants will be saved on file
    /// </summary>
    void AddFarmToRegistro()
    {
        //doing this bz the poly on X is a bit off
        List <Vector3> localOnScreenPoly = UPoly.ScalePoly(OnScreenPoly, reduceOnXLocalOnScreenPoly);
        var            middleOfGameObj   = MiddlePos(localOnScreenPoly);

        //this is the call when it add the collider rectangle to the world and save the RegFile in Registro
        BuildingPot.Control.Registro.AddBuildToAll(this, localOnScreenPoly, Category, middleOfGameObj,
                                                   Inventory,
                                                   PeopleDict,
                                                   LandZone1,
                                                   planesOnAirPos: soil, tileScale: Program.gameScene.ScaleSmallRoadUnitFarm,
                                                   anchors: Anchors);
    }
Esempio n. 12
0
    private void ConformRect()
    {
        var poly = Registro.FromALotOfVertexToPolyMathCenterY(_eaten);

        //ShowDebug(poly, Root.blueCube);

        //expanding the rect
        //Expands this rect a bit to be linked to others thru with .Contain
        poly = UPoly.ScalePoly(poly, _rectForcedGrow);

        _rect = Registro.FromALotOfVertexToRect(poly);
        UVisHelp.CreateDebugLines(_rect, Color.yellow);

        FinalizeBaseProps();
    }
Esempio n. 13
0
File: Way.cs Progetto: 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);
    }
Esempio n. 14
0
    //initializes the List Vector3 wholeMalla, nextStart, and zLot by ref
    //in this class initializes  the fields,StepX , StepZ, Columns, Rows
    public void InitializeMallaStats(Vector3[] vertices, ref List <Vector3> wholeMalla,
                                     ref Vector3 nextStart, ref float zLot)
    {
        if (StepX != 0)
        {
            return;
        }
        if (vertices == null)
        {
            return;
        }

        wholeMalla = UPoly.ReturnWholeMallaAs1Poly(Program.gameScene.controllerMain.MeshController.Vertices);
        nextStart  = wholeMalla[0];
        zLot       = wholeMalla[0].z;

        //UVisHelp.CreateHelpers(wholeMalla[0], Root.redSphereHelp);
        //UVisHelp.CreateHelpers(wholeMalla[2], Root.redSphereHelp);

        _lenght = wholeMalla[0].x - wholeMalla[1].x;
        _height = wholeMalla[3].z - wholeMalla[0].z;

        _mathCenter = m.Vertex.BuildVertexWithXandZ((wholeMalla[0].x + wholeMalla[1].x) / 2,
                                                    (wholeMalla[3].z + wholeMalla[0].z) / 2);


        float epsi = 0.001f;

        for (int i = 0; i < vertices.Length; i++)
        {
            bool eq = UMath.nearlyEqual(vertices[i].x, wholeMalla[0].x, epsi);
            if (eq)
            {
                Columns++;
            }

            eq = UMath.nearlyEqual(vertices[i].z, wholeMalla[0].z, epsi);
            if (eq)
            {
                Rows++;
            }
        }
        StepX = _lenght / Columns;
        StepZ = _height / Rows;

        //print("Columns:" + Columns);
        //print("Rows:" + Rows);
    }
Esempio n. 15
0
    /// <summary>
    /// Makes poly on way seamless on terrain. This has hard coded values
    /// </summary>
    private List <Vector3> RectifyPolyScale(H hTypeP, List <Vector3> polyP)
    {
        float onX = RectifyOnX;
        float onZ = RectifyOnZ;

        if (hTypeP == H.Trail || hTypeP == H.BridgeTrail)
        {
            onX = RectifyOnX;
            onZ = RectifyOnZ;
        }
        if (/*hTypeP == H.Road ||*/ hTypeP == H.BridgeRoad)
        {
            onX *= 5;
            onZ *= 5;
        }
        return(UPoly.ScalePoly(polyP, onX, onZ));
    }
Esempio n. 16
0
File: Way.cs Progetto: Cdrix/SM
    /// <summary>
    /// Returns planes dim from the Starting point of topleft
    /// </summary>
    protected List <Vector3> ReturnPlanesDim(Vector3 topLefts)
    {
        List <Vector3> res = new List <Vector3>();

        res = UPoly.RetSubMeshPoly(topLefts, Program.gameScene.controllerMain.MeshController.AllVertexs, WideSquare);

        //if is a bridge Y will be  _firstWayPoint.y + _secondWayPoint.y) / 2
        if (HType.ToString().Contains(H.Bridge.ToString()))
        {
            for (int i = 0; i < res.Count; i++)
            {
                Vector3 t = res[i];
                t.y    = (_firstWayPoint.y + _secondWayPoint.y) / 2;
                res[i] = t;
            }
        }
        return(res);
    }
Esempio n. 17
0
    private bool SelectSellRegion()
    {
        if (!Input.GetMouseButtonUp(0))
        {
            return(false);
        }

        List <string> names   = new List <string>();
        var           clicked = UPoly.RayCastLayer(Input.mousePosition, 10).transform;

        if (clicked != null && clicked.name.Contains("ForSaleRegion"))
        {
            var sell = clicked.GetComponent <ForSaleRegionGO>();
            sell.ClickOnMe();
            return(true);
        }
        return(false);
    }
Esempio n. 18
0
    /// <summary>
    /// Will try to select a person. Person selection has more importantce than
    /// building selection and priority
    /// </summary>
    /// <returns>Will retrun true if a person was selected</returns>
    private bool SelectPerson()
    {
        Transform clicked = UPoly.RayCastLayer(Input.mousePosition, 11).transform;

        if (clicked != null)
        {
            ManagerReport.AddInput("Selected person: " + clicked.name);

            PersonSelect = clicked.GetComponent <Person>();
            _personWindow.Show(PersonSelect);

            UnselectingBuild();

            _buildingWindow.Hide();
            return(true);
        }
        _personWindow.Hide();
        return(false);
    }
Esempio n. 19
0
    // Use this for initialization
    void Start()
    {
        camera = USearch.FindCurrentCamera();

        Malla     = (Malla)General.Create(Root.malla, container: Program.ClassContainer.transform);
        Poly      = new UPoly();
        subDivide = new SubDivider();
        Vertex    = new Vertexer();
        iniTerr   = new InitializerTerrain();

        iniTerr.Initializer(ref Vertices, ref mesh);
        iniTerr.InitializeMallaStats(Vertices, ref wholeMalla, ref nextStart, ref zLot);

        SubPolyr  = new SubPolyr();
        subMesh   = new SubMeshData();
        IsLoading = true;

        //bz is static and if a new game is started needs to clean up and start again
        CrystalManager1 = new CrystalManager();
    }
Esempio n. 20
0
    private void Init()
    {
        var scaledAnchors = UPoly.ScalePoly(_building.Anchors, .025f);

        _lines = U2D.FromPolyToLines(scaledAnchors);
        RemoveSpwnPointLine();
        FindPositionToSpwnDecor();

        SpawnDecorObj();
        //AddToBatchMesh();

        //SpawnHalloween();

        if (_building.HType.ToString().Contains("WoodHouse") ||
            _building.HType.ToString().Contains("BrickHouse") ||
            _building.HType.ToString().Contains("Shack"))
        {
            _randomUV = new RandomUV(_building.Geometry.gameObject, _building.HType);
        }
    }
Esempio n. 21
0
File: Way.cs Progetto: Cdrix/SM
    /// <summary>
    /// Defined a 3d  rectangle with current selection: onScreenPoly. Defines firstCorner and secondCorner too,
    /// _dir too
    /// </summary>
    /// <returns></returns>
    public void CreateWay()
    {
        //print("1st way p." + _firstWayPoint);
        //print("2st  way p corn." + _secondWayPoint);

        if (firstCorner == new Vector2())
        {
            firstCorner    = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y);
            _firstWayPoint = ClosestSubMeshVert;
        }
        else if (firstCorner != new Vector2())
        {
            secondCorner    = new Vector2(UInput.TransformedMPos.x, UInput.TransformedMPos.y);
            _secondWayPoint = UPoly.RayCastTerrain(secondCorner).point;
            _secondWayPoint = m.Vertex.FindClosestVertex(_secondWayPoint, m.CurrentHoverVertices.ToArray());
            //direction was dragged on terrain
            _dir         = UDir.ReturnDragDir(_firstWayPoint, _secondWayPoint);
            onScreenPoly = UPoly.RetTerrainPoly(_firstWayPoint, _secondWayPoint, _dir);
        }
    }
Esempio n. 22
0
File: SubPolyr.cs Progetto: Cdrix/SM
    //create one subpoly based on where we hit the terrain
    List <Vector3> CreateOneSubPoly(Vector3 hitPointOnSubPoly, bool isMouseOnTerrain, Vertexer vertex,
                                    SubDivider subDivide, UPoly poly, List <Vector3> currentHoverVertices)
    {
        //print(isMouseOnTerrain + "isMouseOnTerrain");
        List <Vector3> subPoly = new List <Vector3>();

        if (isMouseOnTerrain)
        {
            Vector3 firstVertex = vertex.FindClosestVertex(hitPointOnSubPoly, currentHoverVertices.ToArray());

            Dir     quadrant     = vertex.FindVertexQuadrant(firstVertex, hitPointOnSubPoly);
            Vector3 lefTopVertex = vertex.FindTopLeftVertex(firstVertex, quadrant,
                                                            subDivide.XSubStep, subDivide.ZSubStep, currentHoverVertices.ToArray());

            subPoly = UPoly.FindPoly(lefTopVertex, subDivide.XSubStep, subDivide.ZSubStep,
                                     vertex, currentHoverVertices.ToArray());
            //UVisHelp.CreateHelpers(subPoly, Root.blueCube);
        }
        return(subPoly);
    }
Esempio n. 23
0
    /// <summary>
    /// Will return position if 'oringin' was not contained in a building ...
    /// other wise will recurse keep moving towards target... until a spot is find it that
    /// is not contained in a building or 'origin' is equals 'target'
    /// </summary>
    public Vector3 AssignIniPositionIfNotInBuild(Vector3 origin, Vector3 target)
    {
        var personBounds = UPoly.CreatePolyFromVector3(origin, _person.PersonDim, _person.PersonDim);

        //if bound collide will recurse
        if (BuildingPot.Control.Registro.IsCollidingWithExisting(personBounds))
        {
            //if both are the same they the origin was moved all the way untli the target
            //so no more recursion is needed... i couldnt find a point where was not building
            //this is covering a infinite loop, should nt happen ever
            if (UMath.nearEqualByDistance(origin, target, 0.1f))
            {
                throw new Exception("origin reach target on AssignIniPositionIfNotInBuild() DeltaRouter");
            }

            origin = Vector3.MoveTowards(origin, target, 0.04f);
            origin = AssignIniPositionIfNotInBuild(origin, target);
        }
        return(origin);
    }
Esempio n. 24
0
File: Animal.cs Progetto: Cdrix/SM
    /// <summary>
    /// Returns Random position from origin. If fell inside a building will find another spot
    /// until is in a clear zone
    /// If origin is not specified will assume is CamControl.CAMRTS.hitFront.point the center of terrain
    /// </summary>
    /// <param name="howFar">How far will go</param>
    Vector3 AssignAnimalRandomIniPosition(Vector3 origin, Rect area, float howFar, float animalDim)
    {
        float x           = UMath.Random(-howFar, howFar);
        float z           = UMath.Random(-howFar, howFar);
        var   originMoved = new Vector3(origin.x + x, origin.y, origin.z + z);
        var   _bounds     = UPoly.CreatePolyFromVector3(originMoved, animalDim, animalDim);

        if (!area.Contains(new Vector2(originMoved.x, originMoved.z)) ||
            Spawner.CollideWithExistingAnimal(originMoved, Id, animalDim)
            )
        {
            aniCount++;
            if (aniCount > 1000)
            {
                return(new Vector3());
            }
            originMoved = AssignAnimalRandomIniPosition(origin, area, howFar, animalDim);
        }
        return(originMoved);
    }
Esempio n. 25
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="ini"></param>
    /// <param name="end"></param>
    /// <param name="minimuSize">must have one side with a mimunum side like 10f
    /// this is to allow Mountain Routing to happen</param>
    /// <param name="grow">The grow of the rect on scale to make sure contain first and last </param>
    public CryRect(Vector3 ini, Vector3 end, float grow, bool minimuSize = true, float debugDuration = 20f)
    {
        _a = U2D.FromV3ToV2(ini);

        var poly = Registro.FromALotOfVertexToPolyMathCenterY(new List <Vector3>()
        {
            ini, end
        });

        poly = UPoly.ScalePoly(poly, grow);

        _theRect = Registro.FromALotOfVertexToRect(poly);
        _c       = U2D.FromV3ToV2(end);

        _b = FindB();
        _d = FindD();

        //so Rect Grows
        //so way routing works
        //PushThemAway();

        if (minimuSize)
        {
            //when calling this is really importat bz this solved the Mountain Routing problem
            //Dec 26 2015
            ApplyMinimumSize();
        }

        var newPoly =
            new List <Vector3>()
        {
            U2D.FromV2ToV3(_a), U2D.FromV2ToV3(_b),
            U2D.FromV2ToV3(_c), U2D.FromV2ToV3(_d)
        };

        _theRect = Registro.FromALotOfVertexToRect(newPoly);

        //RectifyCorners(poly);
        UVisHelp.CreateDebugLines(TheRect, Color.magenta, debugDuration);
        SetCrystals();
    }
Esempio n. 26
0
    /// <summary>
    /// Returns Random position from origin. If fell inside a building will find another spot
    /// until is in a clear zone
    ///
    /// If origin is not specified will use MeshController.AllVertexs.Count
    ///
    /// Will throw new Exception("Cant be use if MeshController.AllVertexs.Count == 0");
    /// </summary>
    /// <param name="howFar">How far will go</param>
    Vector3 AssignRandomIniPosition(Vector3 origin = new Vector3(), float howFar = 1)
    {
        if (origin == new Vector3())
        {
            origin = ReturnIniPos();
        }

        //so origin is not changed in every recursive
        if (originalPoint == new Vector3())
        {
            originalPoint = origin;
            origin        = ReturnRandomPos(origin, howFar);
        }
        else
        {
            origin = ReturnRandomPos(originalPoint, howFar);
        }
        //will add one unit to how far so can move further
        //doesnt matter that is positive bz in ReturnRandomPos goes in the range of the same number negative and positive
        howFar += .1f;//.1f

        //to check if the poly ard it is free of obstacles
        var polyToCheck = UPoly.CreatePolyFromVector3(origin, 1f, 1f);//1, 1

        if (MeshController.CrystalManager1.IntersectAnyLine(polyToCheck, origin) || !IsOnTerrain(origin) ||
            !ComplyWithTerraRules(origin))
        {
            secCount++;
            if (secCount > 1000)
            {
                throw new Exception("Infinite loop terraSpawContrl");
            }
            //UVisHelp.CreateText(origin, "R" + "");
            origin = AssignRandomIniPosition(origin, howFar);
        }

        originalPoint = new Vector3();
        secCount      = 0;
        return(origin);
    }
Esempio n. 27
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);
    }
Esempio n. 28
0
    /// <summary>
    /// Updates the Big Box when is behaving as a Cursor
    /// </summary>
    public void UpdateCursor()
    {
        //update submesh vert
        UpdateClosestSubMeshVert();
        if (UMath.nearEqualByDistance(ClosestVertOld, ClosestSubMeshVert, 0.01f))
        {
            return;
        }
        UpdateClosestVertexAndOld();

        //creates poly
        var locPoly = UPoly.CreateSubMeshPoly(ClosestSubMeshVert, prevWideSquares);

        locPoly = UPoly.ScalePoly(locPoly, -0.04f);//a bit smaller is not colliding with every edge

        UpdatePos(locPoly, 0.75f);

        bool isEven    = AreAllPointsEven(locPoly, 0.01f);
        bool isCollide = CheckIfColliding(locPoly);
        bool isOnFloor = IsOnTheFloor(locPoly);

        //if is even not coll and is on floor
        CheckAndSwitchColor(isEven && !isCollide && isOnFloor);
    }
Esempio n. 29
0
File: SubPolyr.cs Progetto: Cdrix/SM
    /// Creates a list for the selected sub polygons given the columns and rows
    List <Vector3> CreateListSelected(ref List <Vector3> objsHitTerrain, int columns, int rows, Vector3 iniHit,
                                      SubDivider subDivide, bool isMouseOnTerrain, Vertexer vertex, UPoly poly, List <Vector3> currentHoverVertices)
    {
        objsHitTerrain = UMesh.ReturnThePos(iniHit, subDivide.XSubStep, subDivide.ZSubStep, columns, rows);

        List <Vector3> res = new List <Vector3>();

        for (int i = 0; i < objsHitTerrain.Count; i++)
        {
            res = UList.AddOneListToList(res, CreateOneSubPoly(objsHitTerrain[i], isMouseOnTerrain, vertex,
                                                               subDivide, poly, currentHoverVertices));
        }
        //still needs to eliminate duplicates

        return(res);
    }
Esempio n. 30
0
 //pushing them way from building center
 private List <Vector3> PassAnchorsGetPositionForCrystals(List <Vector3> anchors)
 {
     //pushing them way from building center
     return(UPoly.ScalePoly(anchors, polyScale));//0.04
 }