コード例 #1
0
    /// <summary>
    /// For pedestrians that are subscribed, checks the new information on the
    /// routing system and reacts accordingly, finding any new optimal route.
    /// </summary>
    internal bool CheckNewRoutingInfo()
    {
        bool itineraryChanged = false;

        if (goingToStation)
        {
            // Find a better itinerary
            Itinerary newItinerary = flashInformer.FindBestItinerary(this.transform.position, routing.destination, StationsNearCurrentPosition(), profile.travelPreference);

            if (!routing.itinerary.Equals(newItinerary))
            {
                // Spread the rumour
                if (flashInformer.globalParam.rumoursEnabled)
                {
                    SpreadItineraryRumour(routing.itinerary, newItinerary);
                }

                //The itinerary has changed (the pedestrian redid its route)
                goingToStation = false;

                UpdateInfoBalloon();

                navAgent.enabled = false;
                ResetStopIndex();
                routing          = new FlashPedestriansRouting(routing.destination, newItinerary);
                itineraryChanged = true;
                WalkToNextPoint();

                return(true);
            }
        }

        return(itineraryChanged);
    }
コード例 #2
0
    /// <summary>
    /// Recomputes a new route in the itinerary from a certain point.
    /// </summary>
    /// <param name="stationsNearby">List os stations nearby (null by default).</param>
    private void RedoRouteFromCurrentPosition(StationController[] stationsNearby = null)
    {
        UpdateInfoBalloon();

        navAgent.enabled = false;
        ResetStopIndex();

        if (stationsNearby != null)
        {
            routing = new FlashPedestriansRouting(routing.destination,
                                                  flashInformer.FindBestItinerary(this.transform.position, routing.destination, stationsNearby, profile.travelPreference));
        }
        else
        {
            //In this case, the pedestrian will find the nearby stations from its point
            routing = new FlashPedestriansRouting(routing.destination,
                                                  flashInformer.FindBestItinerary(this.transform.position, routing.destination, StationsNearCurrentPosition(), profile.travelPreference));
        }

        if (routing != null)
        {
            if (routing.itinerary != null)
            {
                stations = routing.itinerary.WayPoints;
            }
        }
    }
コード例 #3
0
    /// <summary>
    /// Check a new rumour that comes from another pedestrian.
    /// </summary>
    /// <param name="rumour">Tuple containing the old itinerary (Item1) followed by the pedestrian spreading the rumour and the new alternative taken (Item2). </param>
    public void CheckItineraryRumour(Tuple <Itinerary, Itinerary> rumour)
    {
        // Check if the pedestrian is not subscribed to the app,
        // if the rumour is concerning its own itinerary,
        // if the pedestrian will believe the rumour and
        // if the pedestrian is going to a station.
        if (profile.chanceOfSubscription + flashInformer.globalParam.percOfPedSubscribed > 1.0f &&
            routing.itinerary.Equals(rumour.Item1) &&
            profile.chanceOfBelievingRumours + flashInformer.globalParam.percOfPedSusceptibleToRumours > 1.0f &&
            goingToStation)
        {
            //Trusting the rumour and changing the route
            goingToStation   = false;
            navAgent.enabled = false;
            ResetStopIndex();
            routing = new FlashPedestriansRouting(routing.destination, rumour.Item2);
            WalkToNextPoint();

            //Change in visualization (for testing purposes)
            if (visualizeRumoursCaught && materialForRumourCaught != null)
            {
                LODGroup lodgroup = GetComponent <LODGroup>();
                LOD[]    lods;

                if (lodgroup != null)
                {
                    lods = lodgroup.GetLODs();

                    foreach (LOD L in lods)
                    {
                        Renderer[] renderers = L.renderers;
                        foreach (Renderer R in renderers)
                        {
                            R.material = materialForRumourCaught;
                        }
                    }
                }
            }
        }
    }