Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        int     spawnCount = m_boxesPerX * m_boxesPerY * m_boxesPerZ;
        Vector3 delta      = (m_maxSpawn - m_minSpawn);

        delta = new Vector3(delta.x / m_boxesPerX, delta.y / m_boxesPerY, delta.z / m_boxesPerZ);
        float   rmv        = ((1.0f - m_shrinkBox) / 2.0f);
        Vector3 lowOffset  = delta * rmv;
        Vector3 highOffset = delta - lowOffset;

        for (int i = 0; i < spawnCount; ++i)
        {
            int     xLoc     = i % m_boxesPerX;
            int     yLoc     = (i / m_boxesPerX) % m_boxesPerY;
            int     zLoc     = i / (m_boxesPerX * m_boxesPerY);
            Vector3 xyzDelta = new Vector3(xLoc * delta.x, yLoc * delta.y, zLoc * delta.z);

            GameObject   made    = MakeAt(RandVec(m_minSpawn + lowOffset + xyzDelta, m_minSpawn + highOffset + xyzDelta), gameObject, "RandomPlacement|" + i);
            MeshCollider p       = made.AddComponent <MeshCollider>();
            GameObject   trigger = HelperFuncs.MakeAt(m_ringTriggerPrefab, Vector3.zero, 1.0f, made, "Trigger|" + i);
            trigger.GetComponent <MeshCollider>().sharedMesh = p.sharedMesh;
        }
    }