/// <summary> /// if crystal in _eval further than _curr towards _two, then are removed and added to the end of _eval /// </summary> private void PushAwayToLastOnEval() { List <Crystal> temp = new List <Crystal>(); for (int i = 0; i < _eval.Count; i++) { _eval[i].CalculateDistance(U2D.FromV3ToV2(_two.Position)); } var distFromCurr = Vector2.Distance(_curr.Position, U2D.FromV3ToV2(_two.Position)); for (int i = 0; i < _eval.Count; i++) { //if the distance is bigger tht the distace from Curr then will be removed if (_eval[i].Distance > distFromCurr) { temp.Add(_eval[i]); _eval.RemoveAt(i); i--; } } //will add the ones tht are fuehter to last on _eval so are checked last _eval.AddRange(temp); }
public bool DoesMyRegionHasWaterCrystal(Vector3 pos) { pos = U2D.FromV3ToV2(pos); var regionIndex = ReturnMyRegion(pos); return(false); }
/// <summary> /// Will return all crsytalls the Rect Lines intersect /// </summary> /// <param name="rect"></param> /// <param name="histoRegions"></param> /// <returns></returns> public List <Crystal> ReturnCrystalsRectIntersect(Rect rect, List <int> histoRegions) { List <Crystal> res = new List <Crystal>(); var crystals = GiveAllCrystalsInTheseRegionsExcludLinkRects(histoRegions); var rectlines = U2D.FromRectToLines(rect); for (int i = 0; i < crystals.Count; i++) { for (int j = 0; j < crystals[i].Lines.Count; j++) { var lineOnCrys = crystals[i].Lines[j]; for (int k = 0; k < rectlines.Count; k++) { var line = rectlines[k]; if (line.IsIntersecting((lineOnCrys))) { lineOnCrys.DebugRender(Color.grey, 10); res.Add(crystals[i]); } } } } return(res); }
/// <summary> /// Will order the _eval by weight from two. So when checking for intersection will start with the /// one tht has less wight from _two /// </summary> private bool OrderEvalByWeight() { var canI = CanPrepareLoop("OrderEvalByWeight"); if (!canI) { return(false); } //means tht another llop is running now var i = loopCount; if (loopCount < _eval.Count) { //_eval[i].CalculateWeight(_curr.Position, U2D.FromV3ToV2(_two.Position), _curr.Id); //_eval[i].CalculateWeight(U2D.FromV3ToV2(_curr.Position)); var finOrC = ReturnCorFinal(); _eval[i].CalculateWeight(finOrC, _two.Position, U2D.FromV2ToV3(_curr.Position)); loopCount++; return(true);//will cut Recursive Path intentionally, bz i need to finish this loop } else { _eval = _eval.OrderBy(a => a.CalcWeight).ToList(); ResetLoop(); return(false);//so let Recursive Keeps it course } }
// Update is called once per frame //void LateUpdate() private void Update() { if (Program.MouseListener.IsAWindowScrollableShownNow() || CamControl.IsMainMenuOn() || ScrollViewShowInventory.IsMouseOnMe || Program.IsMouseOnScrollableContent) { return; } //initiales current obj pos and rot to... InitializeObjects(); CreateTargetAndUpdate(); if (!Program.IsInputLocked && U2D.IsMouseOnScreen() && !MiniMapRTS.isOnTheLimits && BuildingPot.Control != null && BuildingPot.Control.Registro.AllBuilding.Count > 0) { ControlInput(); MouseInBorderDealer(); } AlignYInZero(); RotateScript(); rotateRTS.Update(); //CameraFOV(); }
void DebugBlackThrow() { #if UNITY_EDITOR if (!wasThrow) { if (!debugMarkedOnLand) { debugMarkedOnLand = true; //curr pos is yellow Crystal.DebugCrystal.AddGameObjInPosition(U2D.FromV2ToV3(_curr.Position), Root.yellowSphereHelp); //eval are blue //UVisHelp.CreateHelpers(_eval, Root.blueCube); //UVisHelp.CreateText(U2D.FromV2ToV3(_curr.Position), _curr.CalcWeight + ""); for (int i = 0; i < _debugLines.Count; i++) { _debugLines[i].DebugRender(Color.yellow, 100); } } wasThrow = true; //Program.gameScene.GameSpeed = 0; //throw new Exception("Debug to find why is going to blacklist"); } #endif }
/// <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))); }
/// <summary> /// Will try to reach RectC or Final and will set explorer object that will tell if are /// Buidings in the middle or not /// </summary> /// <returns></returns> private bool ExploreToFin() { var stepFinalPos = ReturnCorFinal(); // //Debug.Log("Exploring"); canIExplore = false; Line line = new Line(U2D.FromV2ToV3(_curr.Position), stepFinalPos, durationOfLines); _debugLines.Add(line); var interCount = IntersectCount(line); if (interCount == 0) { // //Debug.Log("Exploring went good "); _curr = new Crystal(stepFinalPos, H.None, "", setIdAndName: false); loop = true; //canIExplore = true;//needs to be able to keep exploring ResetExplorer(); ResetLoop(); ClearPrevLoop(); return(true); } return(false); }
public static Rect ReturnDimOnMap(List <Vector3> poly) { Rect to = U2D.FromPolyToRect(poly); to = U2D.ReturnRectYInverted(to); return(to); }
/// <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); }
private bool ReturnBridgeRoadEquality() { if (UMath.nearEqualByDistance(_curr.Position, U2D.FromV3ToV2(_two.Position), .1f)) { return(true); } return(false); }
internal static void SetResolution(string name) { SaveResolution(name); LoadAndApplyResolution(); Program.MyScreen1.OptionsWindow1.ChangeResNow(); U2D.RedoScreenRect(); }
/// <summary> /// Will tell u if is just crossing a brdige this time /// </summary> /// <param name="_curr"></param> /// <param name="crystal"></param> /// <returns></returns> private bool IsGettingIntoBridge(Crystal currP, Crystal eval) { var samePos = UMath.nearEqualByDistance(U2D.FromV2ToV3(eval.Position), _two.Position, 0.1f); if (samePos) { return(true); } return(false); }
/// <summary> /// Will order _mountainM by distance from 'compare' /// </summary> /// <param name="compare"></param> private void InitMountainM(Vector2 compare) { _mountainM.Clear(); for (int i = 0; i < _mountainPath.Count; i++) { var v3 = new Vector3(_mountainPath[i].x, m.IniTerr.MathCenter.y, _mountainPath[i].y); _mountainM.Add(new VectorM((v3), U2D.FromV2ToV3(compare))); } _mountainM = _mountainM.OrderBy(a => a.Distance).ToList(); }
void InitSeaM(Vector2 compare) { _seaM.Clear(); for (int i = 0; i < _seaPath.Count; i++) { var v3 = new Vector3(_seaPath[i].x, m.IniTerr.MathCenter.y, _seaPath[i].y); _seaM.Add(new VectorM((v3), U2D.FromV2ToV3(compare))); } _seaM = _seaM.OrderBy(a => a.Distance).ToList(); }
/// <summary> /// Bz they needs to be moved a bit away from Buildign /// </summary> /// <returns></returns> private Crystal ReturnCrystalFurtherTo(Crystal crystal, Vector3 closerTo) { float moveBy = 0.1f; var moved = Vector3.MoveTowards(U2D.FromV2ToV3(crystal.Position), Current, moveBy); crystal.Position = U2D.FromV3ToV2(moved); return(crystal); }
internal static List <General> CreateHelpers(List <Crystal> _eval, string root) { List <General> res = new List <General>(); for (int i = 0; i < _eval.Count; i++) { res.Add(General.Create(root, U2D.FromV2ToV3(_eval[i].Position))); } return(res); }
public Line(Vector3 a, Vector3 b, float duration, bool debugRender = true) { _a = U2D.FromV3ToV2(a); _b = U2D.FromV3ToV2(b); if (debugRender) { DebugRender(duration); } }
internal static List <General> CreateHelpers(List <Vector2> _seaSoul, string root) { List <General> res = new List <General>(); var list = U2D.FromListV2ToV3(_seaSoul); for (int i = 0; i < list.Count; i++) { res.Add(General.Create(root, list[i])); } return(res); }
/// <summary> /// Assign the first lot of regions /// </summary> private void AssignUnlockRegionsToNewGame() { if (_unlockRegions.Count > 0) { return; } var middleOfTown = BuildingPot.Control.Registro.AverageOfAllBuildingsNow(); var first1x1Regions = MeshController.CrystalManager1.ReturnMySurroundRegions(U2D.FromV3ToV2(middleOfTown), 1); _unlockRegions.AddRange(first1x1Regions); }
private void CreateRegion(int index, float iniX, float iniZ, float len, float hei) { Rect rect = new Rect(); rect.xMin = iniX; rect.yMin = iniZ; rect.width = len; rect.height = hei; rect = U2D.ReturnRectYInverted(rect); _crystalRegions.Add(new CrystalRegion(rect, index)); }
/// <summary> /// Will return the region index where all the Structure points are /// </summary> /// <param name="building"></param> /// <returns></returns> private List <int> ReturnRegionsOfPointsInStillElement(StillElement still) { var points = PassAnchorsGetPositionForCrystals(still.Anchors); List <int> res = new List <int>(); for (int i = 0; i < points.Count; i++) { res.Add(ReturnMyRegion(U2D.FromV3ToV2(points[i]))); } return(res.Distinct().ToList()); }
/// <summary> /// Center of the region the camera is on top of now /// </summary> /// <param name="camPos"></param> /// <returns></returns> internal Vector3 CurrentRegionPos(Vector3 camPos) { var v2 = U2D.FromV3ToV2(camPos); var index = ReturnMyRegion(v2); if (index == -1) { return(camPos); } return(U2D.FromV2ToV3(CrystalRegions[index].Region.center)); }
public static void CreateDebugLines(Rect rect, Color color, float duration = 6000f) { Vector3 NW = U2D.FromV2ToV3(new Vector2(rect.xMin, rect.yMin)); Vector3 NE = U2D.FromV2ToV3(new Vector2(rect.xMax, rect.yMin)); Vector3 SE = U2D.FromV2ToV3(new Vector2(rect.xMax, rect.yMax)); Vector3 SW = U2D.FromV2ToV3(new Vector2(rect.xMin, rect.yMax)); Debug.DrawLine(NW, NE, color, duration); Debug.DrawLine(NE, SE, color, duration); Debug.DrawLine(SE, SW, color, duration); Debug.DrawLine(SW, NW, color, duration); }
private void Recursive() { if (prevLoop == "") { //tha adding of a good point to the Route _checkPoints.Add(new CheckPoint(U2D.FromV2ToV3(_curr.Position), _curr.Type1)); if (wasThrow) { var a = 1; } if (CheckIfDone()) { CanIReach2PointAfter(); Ready(); //if (_finDoor) //{ // Crystal.DebugCrystal.ShowNow(); //} return; } CreateCryRect(); DefineHistoCrys(); DefineCrystalsOnMyRect(); } else if (prevLoop == "DefineCrystalsOnMyRect") { ClearPrevLoop(); OrderCyrstalsFromCurr(); } else if (prevLoop == "OrderCyrstalsFromCurr") { ClearPrevLoop(); DefineEvalCrystals(); AddToEvalFromRect();//i place it here so Auto Delta Routing works if (OrderEvalByWeight()) { return; } //so then is called again until I finish the loop } else if (prevLoop == "OrderEvalByWeight") { ClearPrevLoop(); //PushAwayToLastOnEval(); //InsertFinDoor(); TryReachEval(); } }
/// <summary> /// Will say if 'newPos' is on the route already /// </summary> /// <param name="newPos"></param> /// <returns></returns> bool IsOnTheRoute(Vector2 newPos) { for (int i = 0; i < _checkPoints.Count; i++) { var v2 = U2D.FromV3ToV2(_checkPoints[i].Point); if (newPos == v2) { return(true); } } return(false); }
public bool DoesMyRegionHasTerraCrystal(Vector3 pos) { pos = U2D.FromV3ToV2(pos); var regionIndex = ReturnMyRegion(pos); //tht the pos didnt fall inside any region if (regionIndex == -1) { //will act as if will have terraCrystals on it return(true); } return(_crystalRegions[regionIndex].ItHasATerraCristal()); }
public string WhatAudioIPlay(Vector3 camPos) { //todo make sure they start with out ForSaleRegionGO var v2 = U2D.FromV3ToV2(camPos); var index = ReturnMyRegion(v2); if (index == -1) { return("OutOfTerrain"); } return(CrystalRegions[index].WhatAudioIReport); }
/// <summary> /// Return the regions surrouding each point of the poly /// </summary> /// <param name="poly"></param> /// <returns></returns> private List <int> ReturnPolySurroundingRegions(List <Vector3> poly) { List <int> res = new List <int>(); for (int i = 0; i < poly.Count; i++) { var currRegion = ReturnMyRegion(U2D.FromV3ToV2(poly[i])); res.AddRange(ReturnCurrentSurroundIndexRegions(currRegion, 3)); } return(res.Distinct().ToList()); }
/// <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); }