コード例 #1
0
ファイル: TrafficSystem.cs プロジェクト: farizekber/Test
    void Start()
    {
        if (Instance != this)
        {
            return;
        }

        if (m_randomVehicleSpawnPerNode && Application.isPlaying)
        {
            TrafficSystemPiece[] roadPieces = GameObject.FindObjectsOfType <TrafficSystemPiece>();

            for (int rIndex = 0; rIndex < roadPieces.Length; rIndex++)
            {
                float rand = Random.Range(0.0f, 1.0f);
//				Debug.Log("rand (" + rand + ") <= m_randomVehicleSpawnChancePerNode (" + m_randomVehicleSpawnChancePerNode + ")");
                if (rand <= m_randomVehicleSpawnChancePerNode && CanSpawn())
                {
                    int randVehicleIndex = Random.Range(0, m_vehiclePrefabs.Count);
                    roadPieces[rIndex].SpawnRandomVehicle(m_vehiclePrefabs[randVehicleIndex]);
                }
            }
        }

        if (!m_followCameraScript)
        {
            if (transform.GetComponent <TrafficSystemFollowCamera>())
            {
                m_followCameraScript = transform.GetComponent <TrafficSystemFollowCamera>();
            }
        }
    }
コード例 #2
0
    void Start()
    {
        if(Instance != this)
            return;

        if(m_randomVehicleSpawnPerNode && Application.isPlaying)
        {
            TrafficSystemPiece[] roadPieces = GameObject.FindObjectsOfType<TrafficSystemPiece>();

            for(int rIndex = 0; rIndex < roadPieces.Length; rIndex++)
            {
                float rand = Random.Range(0.0f, 1.0f);
        //				Debug.Log("rand (" + rand + ") <= m_randomVehicleSpawnChancePerNode (" + m_randomVehicleSpawnChancePerNode + ")");
                if(rand <= m_randomVehicleSpawnChancePerNode)
                {
                    int randVehicleIndex = Random.Range(0, m_vehiclePrefabs.Count);
                    roadPieces[rIndex].SpawnRandomVehicle( m_vehiclePrefabs[randVehicleIndex] );
                }
            }
        }

        if(!m_followCameraScript)
            if(transform.GetComponent<TrafficSystemFollowCamera>())
                m_followCameraScript = transform.GetComponent<TrafficSystemFollowCamera>();
    }