Пример #1
0
    private void AddRealSightInfo(Vector3 vPos, float fRadius)
    {
        if (false || fRadius <= 0f)
        {
            return;
        }
        Vector2 vector = new Vector2(vPos.x - this.m_BasePos.x, vPos.z - this.m_BasePos.z);
        int     radius = (int)fRadius;

        if (vector.x < 0f || vector.x >= 256f || vector.y < 0f || vector.y >= 256f)
        {
            Debug.LogError("unitsPos error!");
            return;
        }
        FogMgr.IntVector2[] vector2Mask = this.GetVector2Mask(radius);
        int num = vector2Mask.Length;

        for (int i = 0; i < num; i++)
        {
            FogMgr.IntVector2 intVector = vector2Mask[i];
            int num2 = (int)(vector.x + (float)intVector.x);
            if (num2 >= 0 && num2 < 256)
            {
                int num3 = (int)(vector.y + (float)intVector.y);
                if (num3 >= 0 && num3 < 256)
                {
                    this.m_MyRealSight[num2, num3] = 1;
                }
            }
        }
    }
Пример #2
0
    private FogMgr.IntVector2[] GetVector2Mask(int radius)
    {
        FogMgr.IntVector2[] result;
        if (this.mask.TryGetValue(radius, out result))
        {
            return(result);
        }
        int num = radius * radius;
        List <FogMgr.IntVector2> list = new List <FogMgr.IntVector2>();

        for (int i = -radius; i <= radius; i++)
        {
            for (int j = -radius; j < radius; j++)
            {
                FogMgr.IntVector2 intVector = new FogMgr.IntVector2(i, j);
                if (intVector.sqrMagnitude() <= num)
                {
                    list.Add(intVector);
                }
            }
        }
        FogMgr.IntVector2[] array = new FogMgr.IntVector2[list.Count];
        for (int k = 0; k < list.Count; k++)
        {
            array[k] = list[k];
        }
        this.mask.Add(radius, array);
        return(array);
    }