Пример #1
0
    /// <summary>
    /// Processes the map.
    /// </summary>
    /// <exception cref='UnityException'>
    /// Is thrown when level is missing boundary indicator objects
    /// </exception>
    public static void processMap()
    {
        if (processedFlag == true) return; // do nothing if already processed
        processedFlag = true;

        // verify that boundary object exists
        if (GameObject.Find(TL_BOUNDARY) == null ||
                GameObject.Find(BR_BOUNDARY) == null) {
            throw new UnityException("Missing 1 or more boundary indicator objects (add them): "+
                    TL_BOUNDARY + "," + BR_BOUNDARY);
        }

        // first use the level boundary game objects
        Vector3 position;

        position = GameObject.Find(TL_BOUNDARY).transform.position;
        float minX = position.x;
        float maxY = position.z;
        position = GameObject.Find(BR_BOUNDARY).transform.position;
        float maxX = position.x;
        float minY = position.z;

        mapInfo = new LevelInfo(minX, maxX, minY, maxY);

        // go through each wall/obstacle
        foreach (GameObject obj in GameObject.FindGameObjectsWithTag(WALL_TAG)) {
            mapInfo.addStaticObject(obj.transform.position, obj.GetComponent<Collider>().bounds.size);
        }
    }