void Awake()
 {
     logSeriesId       = LoggerAssembly.GetLogSeriesId();
     globalParam       = FindObjectOfType <FlashPedestriansGlobalParameters>();
     flashInformer     = FindObjectOfType <FlashPedestriansInformer>();
     freeMessageWindow = FindObjectOfType <FlashFreeMessageWindowController>();
 }
Example #2
0
    /// <summary>
    /// Awakes the script.
    /// </summary>
    void Awake()
    {
        // Get the global parameters of Flash Pedestrians
        pedGlobalParameters = GetComponentInParent <FlashPedestriansGlobalParameters>();

        // Fill the cache with pedestrians
        for (int i = 0; i < initialNumberOfPedestriansInCache; i++)
        {
            GameObject newAgent = Instantiate(pedGlobalParameters.pedestrianObject, Vector3.zero, Quaternion.identity) as GameObject;
            newAgent.transform.SetParent(this.transform, true);
            pedestrianCache.Enqueue(newAgent);
        }

        // Get the stations that are around the spawner
        Collider[] coll = Physics.OverlapSphere(this.transform.position, radiousToCheckStations, 1 << LayerMask.NameToLayer("Stations"));

        List <StationController> aux = new List <StationController>();

        foreach (Collider C in coll)
        {
            aux.Add(C.GetComponent <StationController>());
        }

        stationsNearThisSpawner = aux.ToArray();

        //Debug.Log(this.gameObject.name +  " has found " + stationsNearThisSpawner.Length
        //    + " stations nearby");

        // Get the itinerary controller
        flashInformer = FindObjectOfType <FlashPedestriansInformer>();

        // Get the destinations
        destinationPoints = FindObjectsOfType <FlashPedestriansDestination>();
    }
 void Awake()
 {
     logSeriesId  = LoggerAssembly.GetLogSeriesId();
     globalParam  = FindObjectOfType <FlashPedestriansGlobalParameters>();
     pedInformer  = FindObjectOfType <FlashPedestriansInformer>();
     stationStats = FindObjectOfType <StationStatistics>();
     spawners     = FindObjectsOfType <FlashPedestriansSpawner>();
 }
Example #4
0
    /// <summary>
    /// Start method.
    /// </summary>
    void Start()
    {
        //Everytime a new bikeStation is spawned, add 1 to the total amount of bikestations
        bikeStationNum = bikeStationAmt;
        bikeStationAmt = bikeStationAmt + 1;

        //Save the original material (for later use in MarkOutOfBikes)
        originalMaterial = this.GetComponent <MeshRenderer>().material;

        nextTimeToInform = deltaTimeToInform;

        floatingNumber = this.GetComponentInChildren <TextMesh>();

        objectData = this.GetComponent <ObjectData>();

        controlPanel = GameObject.Find("ObjectControlPanelUI");

        flashInformer = FindObjectOfType <FlashPedestriansInformer>();

        RegisterBikeStationInInformer();

        isSelected = true;
    }
Example #5
0
    /// <summary>
    /// Awakes the script.
    /// </summary>
    void Awake()
    {
        Debug.Log("Initializing pedestrian spawner...");

        // Get the time controller
        timeCtrl = FindObjectOfType <TimeController>();

        // Get the camera controller
        cameraCtrl = FindObjectOfType <CameraControl>();

        // Get the global parameters of Flash Pedestrians
        pedGlobalParameters = GetComponentInParent <FlashPedestriansGlobalParameters>();

        // Get the heatmap controller
        heatmapCtrl = FindObjectOfType <HeatmapLayer.HeatmapController>();

        // Fill the cache with pedestrians
        for (int i = 0; i < initialNumberOfPedestriansInCache; i++)
        {
            //Random.Range(0, pedGlobalParameters.pedestrianObject.Length)
            GameObject newAgent = Instantiate(pedGlobalParameters.pedestrianObject,
                                              Vector3.zero, Quaternion.identity) as GameObject;

            newAgent.transform.SetParent(this.transform, true);
            pedestrianCache.Enqueue(newAgent);
        }

        // Get the stations that are around the spawner
        Collider[] coll = Physics.OverlapSphere(this.transform.position, radiousToCheckStations, 1 << LayerMask.NameToLayer("Stations"));

        List <StationController> aux = new List <StationController>();

        foreach (Collider C in coll)
        {
            aux.Add(C.GetComponent <StationController>());
        }

        stationsNearThisSpawner = aux.ToArray();

        // Set the spawning points around the spawner
        spawningPoints = new Vector3[numberOfSpawningPoints];
        for (int i = 0; i < numberOfSpawningPoints; i++)
        {
            Vector3 point = new Vector3(
                this.transform.position.x + Random.Range(-radiousToPutSpawningPoints, radiousToPutSpawningPoints),
                0f,
                this.transform.position.z + Random.Range(-radiousToPutSpawningPoints, radiousToPutSpawningPoints));

            //Move the spawning point to the closest point in the walkable navmesh
            UnityEngine.AI.NavMeshHit hit;

            UnityEngine.AI.NavMesh.SamplePosition(point, out hit, 1000.0f,
                                                  1 << UnityEngine.AI.NavMesh.GetAreaFromName("footway") | 1 << UnityEngine.AI.NavMesh.GetAreaFromName("residential")
                                                  | 1 << UnityEngine.AI.NavMesh.GetAreaFromName("cycleway") | 1 << UnityEngine.AI.NavMesh.GetAreaFromName("Pedestrian")
                                                  | 1 << UnityEngine.AI.NavMesh.GetAreaFromName("step") | 1 << UnityEngine.AI.NavMesh.GetAreaFromName("TrafficRoads")
                                                  | 1 << UnityEngine.AI.NavMesh.GetAreaFromName("Walkable"));

            point = hit.position;

            spawningPoints[i] = point;

            //Visualize the spawner
            var spawner = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
            spawner.transform.parent     = this.transform;
            spawner.transform.localScale = new Vector3(2f, 0.1f, 2f);

            spawner.gameObject.name = "SpawningPoint" + i;

            if (spawningMaterial != null)
            {
                spawner.GetComponent <MeshRenderer>().material = spawningMaterial;
            }

            if (!visualizeSpawners)
            {
                spawner.GetComponent <MeshRenderer>().enabled = false;
            }

            spawner.transform.position = point;
        }

        //Debug.Log(this.gameObject.name +  " has found " + stationsNearThisSpawner.Length
        //    + " stations nearby");

        // Get the itinerary controller
        flashInformer = FindObjectOfType <FlashPedestriansInformer>();

        // Get the destinations
        destinations = FindObjectsOfType <FlashPedestriansDestination>();
    }
 void Awake()
 {
     logSeriesId = LoggerAssembly.GetLogSeriesId();
     stationUI   = FindObjectOfType <FlashStationUIController>();
     pedInformer = FindObjectOfType <FlashPedestriansInformer>();
 }