示例#1
0
    private void Awake()
    {
        if (PlayerPrefs.HasKey("exitid"))
        {
            id = PlayerPrefs.GetInt("exitid") + 1;
            PlayerPrefs.SetInt("exitid", id);
        }
        else
        {
            PlayerPrefs.SetInt("exitid", id);
        }
        numSpawnRoads = GameObject.FindGameObjectsWithTag("Respawn").Length;

        Dictionary <int, float> weightedSpawnRatesDict = SimSettings.getDictionary();
        float weight;

        if (weightedSpawnRatesDict.TryGetValue(id + numSpawnRoads, out weight))
        {
            exitRate = (int)weight;
        }
        else
        {
            exitRate = 1;
        }
    }
示例#2
0
    void Start()
    {
        twoLanePathGenerator = FindObjectOfType <TwoLanePathGenerator>();
        if (direction == LightDirection.North)
        {
            carDirection = new Vector3(0, 0, 0);
        }
        if (direction == LightDirection.East)
        {
            carDirection = new Vector3(0, 0, 270);
        }
        if (direction == LightDirection.South)
        {
            carDirection = new Vector3(0, 0, 180);
        }
        if (direction == LightDirection.West)
        {
            carDirection = new Vector3(0, 0, 90);
        }


        //create unique ID for spawn road so weighted rate can get assigned



        //setup generation for cars
        //On timer call Spawn()
        Dictionary <int, float> weightedSpawnRatesDict = SimSettings.getDictionary();
        float weight;

        if (weightedSpawnRatesDict.TryGetValue(id, out weight))
        {
            spawnRate = weight / Application.targetFrameRate;
        }
        else
        {
            spawnRate = 10.0f / Application.targetFrameRate;
        }

        if (PlayerPrefs.GetString("sim_name") == "LargeTwoLaneGrid")
        {
            print("large two lane");
            spawnRate *= 2;
        }

        InvokeRepeating("Spawn", 0.0f, spawnRate);
    }