IEnumerator DeactivatePieceOnDelay(BuiltPathPiece deactivateBPP, PathedArea pArea) { yield return(new WaitForSeconds(0.5f)); if (pArea.thisAreaFormat == AreaFormat.Procedural) { deactivateBPP.DeactivateToPool(); } else { //Deactivate fixed area pArea.fixedAreaObject.SetActive(false); //Also deactivate any connected areas for (int i = 0; i < pArea.connectionPieces.Count; i++) { PathPoolGroup ppGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == pArea.connectionPieces[i].areaTo); if (ppGroup != null && ppGroup != currentPathPoolGroup) { ppGroup.pathFirstLeftPiece.DeactivateToPool(); ppGroup.pathFirstRightPiece.DeactivateToPool(); } } } }
public void BuildFixedArea(PathPoolGroup areaPoolGroup) { PlayerEntersNewArea(areaPoolGroup.thisPathedArea); //Activates fixed object areaPoolGroup.thisPathedArea.fixedAreaObject.SetActive(true); //Most likely need to re-position with this also for when town is rebuilt }
public BuiltPathPiece GetValidBPPForPathedArea(PathedArea pArea) { //Find the related group PathPoolGroup ppGroup = allPathedAreas.Find(x => x.thisPathedArea == pArea); //Get a random available piece from that group BuiltPathPiece availablePiece = GetProceduralBPPForGroup(ppGroup); //Return the piece return(availablePiece); }
public void MoveToNewArea(AreaTypes aType) { currentPathPoolGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == aType); if (currentPathPoolGroup == null) { Debug.LogError("Invalid area type set as starting area."); } else { currentPathPoolGroup.Fixed_SetupLocalReferences(); } }
public void SetStartingArea(AreaTypes areaType) { currentPathPoolGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == areaType); if (currentPathPoolGroup == null) { Debug.LogError("Invalid area type set as starting area."); } else { pathBuilder.BuildFixedArea(currentPathPoolGroup); pathBuilder.BuildExtensionsToFixedArea(); currentPathPoolGroup.Fixed_SetupLocalReferences(); currentBuiltPathPiece = currentPathPoolGroup.thisPathedArea.startBPP; } }
public void ActivatePathPiece_InConnectedArea(PathedArea pArea, BuiltPathPiece bppRef, bool isLeft, bool isRight) { PathPoolGroup thisGroup = allPathedAreas.Find(x => x.thisPathedArea == pArea); if (isLeft) { thisGroup.pathFirstLeftPiece = bppRef; } else if (isRight) { thisGroup.pathFirstRightPiece = bppRef; } bppRef.ActivateFromPool(); }
public void SetupAllStartData(List <PathPoolGroup_Data> ppg_Data) { for (int i = 0; i < ppg_Data.Count; i++) { PathPoolGroup pa = allPathedAreas.Find(x => x.thisPPGData.pathPoolGroupID == ppg_Data[i].pathPoolGroupID); if (pa != null) { pa.thisPPGData = ppg_Data[i]; pa.SetupPoolGroup(); } } /* * DeactivateAllPoolPieces(); * SetStartingArea(AreaTypes.Town); */ }
//Alternate version required for connection pieces also? public BuiltPathPiece GetProceduralBPPForGroup(PathPoolGroup pathPoolGroup) { List <BuiltPathPiece> allActivePieces = pathPoolGroup.GetOnlyInactivePoolPieces(); if (allActivePieces.Count > 0) { //This loop sucks [TODO] make better bool loopForever = true; do { bool pieceFailed = false; int rand = Random.Range(0, allActivePieces.Count); for (int i = 0; i < pathPoolGroup.thisPathedArea.connectionPieces.Count; i++) { if (pathPoolGroup.thisPathedArea.connectionPieces[i].thisConnectionPiece == allActivePieces[rand]) { if (pathPoolGroup.thisPathedArea.connectionPieces[i].minPosToOffer <= pathBuilder.currentPathProgress) { return(allActivePieces[rand]); } else { pieceFailed = true; } } } if (allActivePieces[rand].isActive == false && pieceFailed == false) { return(allActivePieces[rand]); } } while (loopForever); return(null); } else { Debug.LogWarning("No inactive bpp found for group " + pathPoolGroup.thisPathedArea.thisAreaType); return(null); } }