示例#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
                                                   );
    }
示例#2
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);
    }
示例#3
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);
    }
示例#4
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);
    }
示例#5
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();
    }
示例#6
0
文件: Way.cs 项目: 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);
    }
示例#7
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));
    }
示例#8
0
文件: Decoration.cs 项目: Cdrix/SM
    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);
        }
    }
示例#9
0
文件: CryRect.cs 项目: naaturaz/SM
    /// <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();
    }
示例#10
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);
    }
示例#11
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);
    }
示例#12
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
 }
示例#13
0
    /// <summary>
    /// Creates a Plane for the base of the Strcuture
    /// </summary>
    void CreateBasePlane()
    {
        var locPoly = UPoly.ScalePoly(Anchors, 0.04f);

        basePlane = CreatePlane.CreatePlan(Root.createPlane, ReturnMatBase(), raiseFromFloor: 0.08f, container: transform);
    }