List <CheckPoint> validCheckPoints = new List <CheckPoint>(); //checkpoint validated they will be used for last result private void DeltaQualityCheck() { for (int i = 0; i < bucketCheckPoints.Count - 1; i++) { //if is not the same if (!UMath.nearEqualByDistance(bucketCheckPoints[i].Point, bucketCheckPoints[i + 1].Point, 0.1f)) { if (!RouterManager.IsWaterOrMountainBtw(bucketCheckPoints[i].Point, bucketCheckPoints[i + 1].Point)) { validCheckPoints.Add(bucketCheckPoints[i]); } //if is in water wont add the current one else { RestartDeltaRouter(bucketCheckPoints[i].Point); Init(); deltaRouted = false; return; } } } //add the last one validCheckPoints.Add(bucketCheckPoints[bucketCheckPoints.Count - 1]); DoneDelta(); }
void TryDirect(Vector3 fromP, Vector3 toP) { if (!RouterManager.IsWaterOrMountainBtw(fromP, toP)) { ConformValidResult(fromP, toP); } else { _currentTo = toP; TryDeltaRoute(_from, _currentTo); } }
/// <summary> /// Defines the last good position from the origin to that prime /// in this case the prime is not seeing or use directly bz 'positionsToCheck' was created /// using the prime position already /// </summary> private void ThrowRays() { int lastI = -1; for (int i = 0; i < positionsToCheck.Count; i++) { if (!RouterManager.IsWaterOrMountainBtw(currentOrigin, positionsToCheck[i])) { lastI = i; break; } } DefineLastCurrent(lastI); }
private void TryDirectBoth() { if (!RouterManager.IsWaterOrMountainBtw(_from, _endABot)) { ConformValidResult(_from, _endABot); } else if (!RouterManager.IsWaterOrMountainBtw(_from, _endBBot)) { ConformValidResult(_from, _endBBot); } else { _currentTo = _endABot; TryDeltaRoute(_from, _currentTo); } }
/// <summary> /// Created so the player doesnt pass thru river terrain tht is unenven /// </summary> /// <param name="lastI">Last index was good</param> private void DefineLastCurrent(int lastI) { if (lastI != -1) { currentLast = positionsToCheck[lastI]; if (lastI + 1 < positionsToCheck.Count) { //IMPORTANT here am checking if the one before is visible if (!RouterManager.IsWaterOrMountainBtw(positionsToCheck[lastI + 1], currentOrigin)) { //the middle btw the last good and the one before currentLast = (positionsToCheck[lastI] + positionsToCheck[lastI + 1]) / 2; } } } }
/// <summary> /// Move each point towards is target and throw Ray agaisnt the other to see if can /// see it already /// </summary> private void MoveEachOneAloneAndThrowRayAndConformRoute() { Vector3 aMove = _deltaRoute.AnyA; Vector3 bMove = _deltaRoute.AnyB; //will keep mpving them towards target until they can see eachother without water on midle while (RouterManager.IsWaterOrMountainBtw(aMove, bMove)) { aMove = Vector3.MoveTowards(aMove, _deltaRoute.TargetA, step / 2); bMove = Vector3.MoveTowards(bMove, _deltaRoute.TargetB, step / 2); loopCounts++; //this address probblem of inifitnie loop //for some reason in void DefineDeltaRoute() somehting is not working fine. //if a river is on middle should never have 2 points with good on the same side if (loopCounts > 100) { loopCounts = 0; _isDeltaRoutable = false; Stop(); break; } } //push away a bit towards target. To avoid infinite recursion on certain spots aMove = Vector3.MoveTowards(aMove, _deltaRoute.TargetA, step); bMove = Vector3.MoveTowards(bMove, _deltaRoute.TargetB, step); _deltaRoute.BestA = AssignIniPositionIfNotInBuild(aMove, _deltaRoute.TargetA); _deltaRoute.BestB = AssignIniPositionIfNotInBuild(bMove, _deltaRoute.TargetB); _deltaRoute.ConformRoute(); // _person.DebugList.Add( UVisHelp.CreateHelpers(_deltaRoute.BestA, Root.redSphereHelp)); // _person.DebugList.Add(UVisHelp.CreateHelpers(_deltaRoute.BestB, Root.redSphereHelp)); }