public override GameObject GetNextDestination() { if ((ImportantPictures.Count <= 0 && !groupData.LeaderIsAlive) || FatigueLevel >= FatigueManager.Level.MOLTO_STANCO) { return(GetPlaneOfExit()); } bool skipDestination = Random.Range(0, 100) < ChanceSkipDestination; if (LookInBackward()) { if (skipDestination || VisitedPictures.Contains(nextDestination.GetComponentInParent <PictureInfo>())) { LookNextIndex(); return(nextDestination); } return(nextDestination); } if (LookNextIndex() || LookNextIndex(0)) { if (skipDestination || VisitedPictures.Contains(nextDestination.GetComponentInParent <PictureInfo>())) { return(GetNextDestination()); } return(nextDestination); } return(GetPlaneOfExit()); }
public override GameObject GetNextDestination() { if ((ImportantPictures.Count <= 0 && groupData.LeaderIsAlive) || FatigueLevel >= FatigueManager.Level.MOLTO_STANCO) { return(GetPlaneOfExit()); } if (picturesToWatch.MoveNext()) { if (VisitedPictures.Contains(picturesToWatch.Current)) { return(GetNextDestination()); } GameObject pictureGrid = picturesToWatch.Current.GetComponentInChildren <GridSystem>().gameObject; return(pictureGrid); } if (ImportantPictures.Count > 0) { PictureInfo importantPicture = ImportantPictures[ImportantPictures.Count - 1]; ImportantPictures.Remove(importantPicture); return(importantPicture.GetComponentInChildren <GridSystem>().gameObject); } return(GetPlaneOfExit()); }
public override void ReceiveLeaderChoice(GameObject leaderDestination) { if (leaderDestination.CompareTag("Uscita")) { Debug.Log(name + ": ricevuta nuova destinazione del leader (despota)", leaderDestination); Destination = leaderDestination; if (DestinationPrePause != null) { InPausa = false; ImportantIgnoratePicture.Add(DestinationPrePause.GetComponentInParent <PictureInfo>()); lastDestinationLeader = null; DestinationPrePause = null; } UpdateDestinationPointForNoChoiceExit(); GoToDestinationPoint(); return; } if (!VisitedPictures.Contains(leaderDestination.GetComponentInParent <PictureInfo>())) { if (DestinationPrePause) { ImportantIgnoratePicture.Add(DestinationPrePause.GetComponentInParent <PictureInfo>()); } lastDestinationLeader = leaderDestination.GetComponentInParent <PictureInfo>(); } }
public override GameObject GetNextDestination() { if (ImportantPictures.Count <= 0 && !groupData.LeaderIsAlive || FatigueLevel >= FatigueManager.Level.MOLTO_STANCO) { return(GetPlaneOfExit()); } if (MoveToNextPicOnCurrentWall() || MoveToNextPicOnAnotherWall()) { bool skipNewDestination = Random.Range(0, 100) < ChanceSkipDestination; if (skipNewDestination) { return(GetNextDestination()); } } else { return(GetPlaneOfExit()); } if (VisitedPictures.Contains(picsOnCurrentWall.Current)) { return(GetNextDestination()); } return(GetPlaneOfCurrentPicture()); }
private List <GameObject> GetWallsClosestToCurrent() { List <GameObject> intersectsWalls = new List <GameObject>(); foreach (GameObject wall in walls) { if (wall == currentWall) { continue; } Bounds currentWallBounds = currentWall.GetComponent <MeshRenderer>().bounds; Bounds wallBounds = wall.GetComponent <MeshRenderer>().bounds; if (currentWallBounds.Intersects(wallBounds)) { picturesOnWalls[wall].RemoveAll((pic) => VisitedPictures.Contains(pic)); if (picturesOnWalls[wall].Count > 0) { if (picturesOnWalls[wall][0].index - CurrentPictureIndex < maxDiffNextPicIndexInClosestWall) { intersectsWalls.Add(wall); } } } } utilitySort.picturesOnWalls = picturesOnWalls; intersectsWalls.Sort(utilitySort.SortByIndexPictureInWalls); return(intersectsWalls); }
private bool NextPictureIsInClosestWall() { List <GameObject> wallsIntersectCurrentWall = GetWallsClosestToCurrent(); if (wallsIntersectCurrentWall.Count > 0) { GameObject wallWithMinPicIndex = wallsIntersectCurrentWall[0]; picturesOnWalls[wallWithMinPicIndex].RemoveAll((pic) => VisitedPictures.Contains(pic)); PictureInfo picWithMinIndex = picturesOnWalls[wallWithMinPicIndex][0]; if (picWithMinIndex.index >= CurrentPictureIndex) { currentWall = wallWithMinPicIndex; return(true); } } return(false); }
private bool MoveToNextPicOnAnotherWall() { walls.Remove(currentWall); walls.RemoveAll(( GameObject wall ) => picturesOnWalls[wall].Count <= 0); walls.RemoveAll(( GameObject wall ) => picturesOnWalls[wall][0].index < CurrentPictureIndex); utilitySort.picturesOnWalls = picturesOnWalls; walls.Sort(utilitySort.SortByIndexPictureInWalls); if (NextPictureIsInClosestWall() || NextPictureIsInDetachedWall()) { picturesOnWalls[currentWall].RemoveAll((pic) => VisitedPictures.Contains(pic)); picsOnCurrentWall = picturesOnWalls[currentWall].GetEnumerator(); picsOnCurrentWall.MoveNext(); RefreshCurrentPictureIndex(); return(true); } return(false); }
private GameObject GetMostClosePicture() { if (picturePlanes.Count <= 0) { return(GetPlaneOfExit()); } utilitySort.transform = transform; picturePlanes.Sort(utilitySort.Distanza); GameObject mostClosePicturePlane = picturePlanes[0]; picturePlanes.Remove(mostClosePicturePlane); if (VisitedPictures.Contains(mostClosePicturePlane.GetComponentInParent <PictureInfo>()) || mostClosePicturePlane.GetComponentInParent <PictureInfo>().index <= CurrentPictureIndex) { return(GetMostClosePicture()); } return(mostClosePicturePlane); }