示例#1
0
    Vector4 GetSingleFogAreaInfo(Vector2Int pos)
    {
        if (!PosValid(pos))
        {
            Debug.LogError("坐标越界,无法获取迷雾散开信息");
            return(Vector4.zero);
        }

        var atVerticalStreetLeft  = mapConfigData.PosAtVerticalWideStreetLeft(pos.x);
        var atVerticalStreetRight = mapConfigData.PosAtVerticalWideStreetRight(pos.x);

        var atHorizontalStreetUp   = mapConfigData.PosAtHorizontalWideStreetUp(pos.y);
        var atHorizontalStreetDown = mapConfigData.PosAtHorizontalWideStreetDown(pos.y);



        var     offsetX = 0f;
        var     offsetY = 0f;
        Vector2 size    = FogNormalSize;

        if (atVerticalStreetLeft)
        {
            offsetX = FogWideStreetOffset.x;
            size.x  = FogWideStreetXLength;
        }
        else if (atVerticalStreetRight)
        {
            offsetX = -FogWideStreetOffset.x;
            size.x  = FogWideStreetXLength;
        }

        if (atHorizontalStreetDown)
        {
            offsetY = FogWideStreetOffset.y;
            size.y  = FogWideStreetYLength;
        }
        else if (atHorizontalStreetUp)
        {
            offsetY = -FogWideStreetOffset.y;
            size.y  = FogWideStreetYLength;
        }

        //var atLeft = pos.x == 0;
        //var atRight = pos.x == mapConfigData.MapWidth - 1;
        //var atUp = pos.y == mapConfigData.MapHeight - 1;
        //var atDown = pos.y == 0;
        //var outwallX = mapConfigData.OuterWallSize.x * outwallValue;
        //var outwallY = mapConfigData.OuterWallSize.y * outwallValue;

        //if (atLeft)
        //{
        //    offsetX += -outwallX / 2;
        //    size.x += outwallX;
        //}
        //else if (atRight)
        //{
        //    offsetX += outwallX / 2;
        //    size.x += outwallX;
        //}

        //if (atUp)
        //{
        //    offsetY += outwallY / 2;
        //    size.y += outwallY;
        //}
        //else {
        //    offsetY += -outwallY / 2;
        //    size.y += outwallY;
        //}



        var buildPos = mapGenerator.GetBuildPos(pos);

        return(new Vector4(buildPos.x + offsetX, buildPos.y + offsetY, size.x, size.y));
    }