Beispiel #1
0
    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());
    }
Beispiel #2
0
    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());
    }
Beispiel #3
0
    private void CheckLeaderDestination()
    {
        if (lastDestinationLeader.CompareTag("Empty Space"))
        {
            Destination = lastDestinationLeader.gameObject;
        }
        else
        {
            Destination = lastDestinationLeader.GetComponentInChildren <GridSystem>().gameObject;
        }

        bool IgnoreDestination = ImportantIgnoratePicture.Contains(Destination.GetComponentInParent <PictureInfo>());

        if (!IgnoreDestination)
        {
            if (Destination.GetComponent <GridSystem>().HaveAvailablePoint())
            {
                if (!Destination.CompareTag("Empty Space"))
                {
                    VisitedPictures.Add(Destination.GetComponentInParent <PictureInfo>());
                }
            }
            else
            {
                InPausa = true;

                DestinationPrePause = Destination;
                Destination         = GetMostCloseEmptySpace(groupData.leader.GetComponent <BotVisitData>().destinationPoint.transform);
            }
        }

        lastDestinationLeader = null;
        UpdateDestinationPoint();
        GoToDestinationPoint();
    }
Beispiel #4
0
    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>();
        }
    }
Beispiel #5
0
    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());
    }
Beispiel #6
0
    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);
    }
Beispiel #7
0
    private void CheckDestinationFromPause()
    {
        if (DestinationPrePause != null && DestinationPrePause.GetComponent <GridSystem>().HaveAvailablePoint())
        {
            if (!Destination.CompareTag("Empty Space"))
            {
                VisitedPictures.Add(Destination.GetComponentInParent <PictureInfo>());
            }

            timedelta           = 0;
            Destination         = DestinationPrePause;
            DestinationPrePause = null;
            InPausa             = false;
            UpdateDestinationPoint();
            GoToDestinationPoint();
        }
    }
Beispiel #8
0
    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);
    }
Beispiel #9
0
    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);
    }
Beispiel #10
0
    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);
    }