Beispiel #1
0
    public static void Save(string filename, BusServiceAvailability busServiceAvailability)
    {
        BusData         data = new BusData(busServiceAvailability.GetStops(), busServiceAvailability.GetHourStep(), busServiceAvailability.maxDistance, busServiceAvailability.reliabilityFactor);
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Path.Combine(Application.persistentDataPath, filename + ".dat"));

        bf.Serialize(file, data);
        file.Close();
    }
Beispiel #2
0
    public void OnOKButtonClicked()
    {
        if (busServiceAvailability == null)
        {
            busServiceAvailability = GameObject.Find("BusIndicator").GetComponent <BusServiceAvailability>();
        }

        busServiceAvailability.hourStep          = int.Parse(hourStep.text);
        busTimeSlider.maxValue                   = busServiceAvailability.GetNbOfSteps() - 1;
        busServiceAvailability.maxDistance       = float.Parse(maxDistance.text);
        busServiceAvailability.reliabilityFactor = float.Parse(reliabilityFactor.text);
        busServiceAvailability.SetStops();

        UpdateTimeLabel();
    }
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            var min  = ve.MeshFilter.sharedMesh.subMeshCount;
            var mats = new Material[min];

            BusServiceAvailability busServiceAvailability = GameObject.Find("BusIndicator").GetComponent <BusServiceAvailability>();
            Vector2d latLon = GameObject.Find("CitySimulatorMap").GetComponent <AbstractMap>().WorldToGeoPosition(ve.Transform.position);

            float[] indicators = busServiceAvailability.GetPTAL((float)latLon[0], (float)latLon[1]);

            for (int i = 0; i < min; i++)
            {
                Material mat = new Material(Shader.Find("Diffuse"));
                try {
                    mat.color = probabilityToColor(indicators[busServiceAvailability.GetCurrentStep()]);
                } catch (IndexOutOfRangeException) {
                    mat.color = new Color(0.0f, 1f, 0f, 1f);
                }
                mats[i] = mat;
            }

            ve.MeshRenderer.materials = mats;
        }