/// <summary> /// Will tell u if te way btw 2 points is clear. Of buidllings or obj that block, like house, /// </summary> bool IsWayClear(Vector3 origin, Vector3 destinyRealAnchor, Building buildP = null) { if (buildP == null) { buildP = currBuilding; } //by default will compare to cuurrentBuilding float howFar = _person.PersonDim / 4; //* 1.5f; destinyAwayFromBuild = MoveAnchorAwayFromBuild(destinyRealAnchor, buildP.Anchors, howFar, howFar); VectorHit vH = FindGeneralBuildingOnMyWay(origin, destinyAwayFromBuild); bool firstStep = false; if (vH == null) { firstStep = true; } else { firstStep = !IsCollidingWithBuildingThatBlockNear(vH, origin, destinyAwayFromBuild); } return(firstStep); }
/// <summary> /// Was created so we can descrimanate if a buildings is far or close enougnt that we care, /// if is far enought we dont carre /// /// If builidg is further than end then is false,, if builidg is closer than end /// then I called here IsCollidingWithBuildingThatBlock() /// </summary> bool IsCollidingWithBuildingThatBlockNear(VectorHit vectorHit, Vector3 start, Vector3 end) { var distBtwStartAndEnd = Vector3.Distance(start, end); General g = null; if (BuildingPot.Control.Registro.AllBuilding.ContainsKey(vectorHit.HitMyId)) { g = BuildingPot.Control.Registro.AllBuilding[vectorHit.HitMyId]; } if (g == null) { if (Program.gameScene.controllerMain.TerraSpawnController.AllRandomObjList.Contains(vectorHit.HitMyId)) { g = Program.gameScene.controllerMain.TerraSpawnController.AllRandomObjList[vectorHit.HitMyId]; } } if (g == null) { return(false); } //needs to compared with the hit point of that building.. since if is a big building will cause bugg //since transform.position could be further than distBtwStartAndEnd... var distBtwStartAndBuild = Vector3.Distance(start, vectorHit.HitPoint); if (distBtwStartAndBuild > distBtwStartAndEnd) { return(false); } return(IsCollidingWithBuildingThatBlock(vectorHit.HitMyId, g)); }
/// <summary> /// Will return the route to follow a Person from point ini to fin /// When this is call make sure u validated both points are not insede /// any building /// /// This is recursive is called and called again from its methods until _fin is reached /// </summary> void PlotRoute() { if (_checkPoints.Count == 0) { AddFirst(); } vectorHit = FindGeneralBuildingOnMyWay(_current, _fin); if (vectorHit == null) { AddLastAndDone(); return; } if (vectorHit.HitMyId != "") { SetCurrentBuilding(); if (IsCollidingWithBuildingThatBlockNear(vectorHit, _current, _fin)) { SetAnchors(); HandleCollision(); } else { AddLastAndDone(); } } else { AddLastAndDone(); } }