Пример #1
0
    float GetMaxXDeep()
    {
        float deepMaxX = maxX;

        if (_otherPositionBoundry != null)
        {
            float otherDeepMaxX = _otherPositionBoundry.GetMaxXDeep();
            if (otherDeepMaxX < deepMaxX)
            {
                deepMaxX = otherDeepMaxX;
            }
        }
        return(deepMaxX);
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        _minX = minX;
        _maxX = maxX;
        _minY = minY;
        _maxY = maxY;
        _minZ = minZ;
        _maxZ = maxZ;

        // check if this is linked to another PositionBoundry
        // if so, we'll check those values for smaller boundries
        if (otherPositionBoundry != null)
        {
            _otherPositionBoundry = (PositionBoundry)otherPositionBoundry.GetComponent("PositionBoundry");
            if (_otherPositionBoundry != null)
            {
                float otherMinX = _otherPositionBoundry.GetMinXDeep();
                float otherMaxX = _otherPositionBoundry.GetMaxXDeep();
                float otherMinY = _otherPositionBoundry.GetMinYDeep();
                float otherMaxY = _otherPositionBoundry.GetMaxYDeep();
                float otherMinZ = _otherPositionBoundry.GetMinZDeep();
                float otherMaxZ = _otherPositionBoundry.GetMaxZDeep();
                if (otherMinX > _minX)
                {
                    _minX = otherMinX;
                }
                if (otherMaxX < _maxX)
                {
                    _maxX = otherMaxX;
                }
                if (otherMinY > _minY)
                {
                    _minY = otherMinY;
                }
                if (otherMaxY < _maxY)
                {
                    _maxY = otherMaxY;
                }
                if (otherMinZ > _minZ)
                {
                    _minZ = otherMinZ;
                }
                if (otherMaxZ < _maxZ)
                {
                    _maxZ = otherMaxZ;
                }
            }
        }

        // check the values, and give some warning if things are borked
        if (_minX > _maxX)
        {
            Debug.LogWarning("PositionBoundry: object " + name + " calculated a minX value of " + minX + " and maxX value of " + maxX + ". Position may get messed up.");
        }
        if (_minY > _maxY)
        {
            Debug.LogWarning("PositionBoundry: object " + name + " calculated a minY value of " + minY + " and maxY value of " + maxY + ". Position may get messed up.");
        }
        if (_minZ > _maxZ)
        {
            Debug.LogWarning("PositionBoundry: object " + name + " calculated a minZ value of " + minX + " and maxZ value of " + maxZ + ". Position may get messed up.");
        }
    }