Esempio n. 1
0
        private void SetCurrentSlopeUI(SlopeLine spl)
        {
            var xdata = spl.XData;
            var s     = SlopeData.Combine(xdata.Slopes, xdata.Platforms, true);

            SetDGVDataSource(spl, s);
        }
Esempio n. 2
0
        /// <summary> 提取所有的横断面块参照的信息 </summary>
        public ExternalCmdResult SlopeWalk(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            bool cont;
            var  pl = GetSlopeLine(docMdf.acEditor, out cont);

            while (cont)
            {
                if (pl != null)
                {
                    //

                    var slpData = SlopeData.FromEntity(pl);

                    var formAddDefinition = new PropertyEditor("边坡参数", slpData);
                    //
                    var res = formAddDefinition.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        // var newSlpDa = formAddDefinition.Instance;
                        pl.UpgradeOpen();

                        //  pl.XData = slpData.ToResultBuffer();
                        pl.DowngradeOpen();
                    }
                }
                //
                pl = GetSlopeLine(docMdf.acEditor, out cont);
            }
            return(ExternalCmdResult.Commit);
        }
Esempio n. 3
0
        private static double GetCutY(SlopeData slp, SubgradeSection sec, CutMethod method, double value)
        {
            double cutY = 0;

            switch (method)
            {
            case CutMethod.从中心向外:
                if (slp.FillCut)
                {
                    cutY = sec.GetYFromElev(slp.TopElevation - value);
                    break;
                }
                else
                {
                    cutY = sec.GetYFromElev(slp.BottomElevation + value);
                    break;
                }

            case CutMethod.从坡底向上:
                cutY = sec.GetYFromElev(slp.BottomElevation + value);
                break;

            case CutMethod.从坡顶向下:
                cutY = sec.GetYFromElev(slp.TopElevation - value);
                break;

            default:     // 按绝对标高
                cutY = sec.GetYFromElev(value);
                break;
            }
            return(cutY);
        }
Esempio n. 4
0
        /// <summary> 将子边坡按指定的交点进行剪切,并返回剪切后的新的子边坡集合 </summary>
        /// <param name="data"></param>
        /// <param name="intersSeg"></param>
        /// <param name="intersPt"></param>
        public List <Slope> CutSlopeSegment(SlopeData data, Slope intersSeg, Point3d intersPt)
        {
            var slopeSegs = data.Slopes;
            var newSegs   = new List <Slope>();
            int mainLevel = intersSeg.GetMainLevel();
            // 1. 先添加交叉边坡之前的子边坡
            int sumBefore = 0;

            for (int id = 0; id < slopeSegs.Count; id++)
            {
                var slp = slopeSegs[id];
                if (slp.GetMainLevel() != mainLevel)
                {
                    newSegs.Add(slp);
                    sumBefore += 1;
                }
                else
                {
                    break;
                }
            }
            // 2. 对交叉处的子边坡进行处理
            var sumMainLevel   = slopeSegs.Count(r => r.GetMainLevel() == mainLevel); // 此子边坡中已经有多少个更细的子边坡
            int subLevelInters = intersSeg.GetSubLevel();
            // 分割后,最内侧的子边坡的Index为 n.1,最外侧的子边坡的Index为 n.9,
            int subL = 1;

            for (int i = 0; i < sumMainLevel; i++)
            {
                // 此循环的过程中改写有一个子边坡与指定的相交边坡是同一个边坡
                var seg = slopeSegs[sumBefore + i];
                if (seg.GetSubLevel() == subLevelInters)
                {
                    var seg1 = new Slope(Slope.GetIndex(mainLevel, subL), intersSeg.InnerPoint, intersPt);
                    var seg9 = new Slope(Slope.GetIndex(mainLevel, subL + 1), intersPt, intersSeg.OuterPoint);
                    SetProtectionMethod(intersSeg, seg1, seg9);
                    //
                    newSegs.Add(seg1);
                    newSegs.Add(seg9);
                    subL += 2;
                }
                else
                {
                    seg.SetIndex(mainLevel, subL);
                    newSegs.Add(seg);
                    subL += 1;
                }
            }
            // 修改最后一个的Index
            // newSegs[sumBefore + sumMainLevel].SetIndex(mainLevel, 9);

            // 3. 接着添加交叉边坡之后的子边坡
            for (int i = sumBefore + sumMainLevel; i < slopeSegs.Count; i++)
            {
                newSegs.Add(slopeSegs[i]);
            }
            return(newSegs);
        }
Esempio n. 5
0
 /// <summary> 提取指定边坡集合中的所有的防护形式(挂网喷锚_6 与 挂网喷锚_9 并不会合并) </summary>
 public static string[] GetProtectionTypes(IEnumerable <SlopeData> slopeDatas)
 {
     return(slopeDatas
            .SelectMany(r => SlopeData.Combine(r.Slopes, r.Platforms, false))
            .Select(r => r.ProtectionMethod)
            .Where(r => !string.IsNullOrEmpty(r))
            .Distinct()
            .ToArray());
 }
Esempio n. 6
0
        /// <summary> 在两个相邻的边坡之间计算其每一个子边坡所占的宽度与几何面积 </summary>
        /// <param name="backStation"></param>
        /// <param name="backSlope">此属性不会为 null,如果某桩号某一侧没有边坡对象(是几何图形都没有,而不是因为挡墙覆盖而没有)时,则此属性的值为<seealso cref="SlopeData"/>的默认实例对象</param>
        /// <param name="frontStation">其值可能为null,表示没有此边坡对象(是几何图形都没有,而不是因为挡墙覆盖而没有)</param>
        /// <param name="frontSlope">此属性不会为 null,如果某桩号某一侧没有边坡对象(是几何图形都没有,而不是因为挡墙覆盖而没有)时,则此属性的值为<seealso cref="SlopeData"/>的默认实例对象</param>
        public SlopeSegsGeom(double backStation, SlopeData backSlope, double frontStation, SlopeData frontSlope)
        {
            _backStation = backStation;
            _backSlope   = backSlope;

            _frontStation = frontStation;
            _frontSlope   = frontSlope;
            //
            _stationWidth  = Math.Abs(backStation - frontStation);
            _middleStation = (backStation + frontStation) / 2;
            ConstructSlopeSystem();
        }
Esempio n. 7
0
    public void SaveGeoMap()
    {
        if (activeEditorHexTiles == null)
        {
            Debug.LogError("Unable to Save");
            return;
        }
        else if (activeEditorHexTiles.Count == 0)
        {
            Debug.LogError("Unable to Save");
            return;
        }


        Dictionary <Hex, Material>  hexMaterials     = new Dictionary <Hex, Material>();
        Dictionary <Hex, Sprite>    hexSprites       = new Dictionary <Hex, Sprite>();
        Dictionary <Hex, bool>      hexWalkableFlags = new Dictionary <Hex, bool>();
        Dictionary <Hex, MapHeight> hexHeights       = new Dictionary <Hex, MapHeight>();
        Dictionary <Hex, SlopeData> hexSlopeDatas    = new Dictionary <Hex, SlopeData>();

        foreach (var tile in activeEditorHexTiles)
        {
            Hex      tileHex      = tile.Key;
            var      tileData     = tile.Value.data;
            Material tileMaterial = tileData.hexMaterial;
            Debug.Assert(tileMaterial != null, "Material null on the editor hex data", tileData);
            Sprite tileSprite = tileData.sprite;
            Debug.Assert(tileSprite != null, "Sprite null on the editor hex data", tileData);
            bool      tileWalkableFlag = tileData.walkable;
            MapHeight tileHeight       = tileData.heightLevel;
            SlopeData slopeData        = new SlopeData()
            {
                isSlope        = tileData.isSlope,
                heightSide_0tr = tileData.heightSide_TopRight,
                heightSide_1r  = tileData.heightSide_Right,
                heightSide_2dr = tileData.heightSide_DownRight,
                heightSide_3dl = tileData.heightSide_DownLeft,
                heightSide_4l  = tileData.heightSide_Left,
                heightSide_5tl = tileData.heightSide_TopLeft
            };

            hexMaterials.Add(tileHex, tileMaterial);
            hexSprites.Add(tileHex, tileSprite);
            hexWalkableFlags.Add(tileHex, tileWalkableFlag);
            hexHeights.Add(tileHex, tileHeight);
            hexSlopeDatas.Add(tileHex, slopeData);
        }

        editingMap.InitMap(hexMaterials, hexSprites, hexWalkableFlags, hexHeights, hexSlopeDatas, mapProportions);
        //var serializedObj = new UnityEditor.SerializedObject(editingMap);
        //serializedObj.ApplyModifiedProperties();
        EditorUtility.SetDirty(editingMap);
    }
Esempio n. 8
0
    private static void GetHeightLevels(DoubleSlopeDirection doubleSlopeDirection, SlopeData slopeData, out int bottomLevel, out int upperLevel)
    {
        switch (doubleSlopeDirection)
        {
        case DoubleSlopeDirection.UDEFINDED:
            bottomLevel = 0;
            upperLevel  = 0;
            Debug.LogError("The double slope direction is undefined. You may want to use the simple slope directions instead");
            break;

        case DoubleSlopeDirection.TOP_LEFT:
            bottomLevel = GeographicTile.GetValueOfHeight(slopeData.heightSide_1r);
            upperLevel  = GeographicTile.GetValueOfHeight(slopeData.heightSide_4l);
            break;

        case DoubleSlopeDirection.TOP:
            bottomLevel = GeographicTile.GetValueOfHeight(slopeData.heightSide_2dr);
            upperLevel  = GeographicTile.GetValueOfHeight(slopeData.heightSide_5tl);
            break;

        case DoubleSlopeDirection.TOP_RIGHT:
            bottomLevel = GeographicTile.GetValueOfHeight(slopeData.heightSide_3dl);
            upperLevel  = GeographicTile.GetValueOfHeight(slopeData.heightSide_0tr);
            break;

        case DoubleSlopeDirection.DOWN_RIGHT:
            bottomLevel = GeographicTile.GetValueOfHeight(slopeData.heightSide_4l);
            upperLevel  = GeographicTile.GetValueOfHeight(slopeData.heightSide_1r);
            break;

        case DoubleSlopeDirection.DOWN:
            bottomLevel = GeographicTile.GetValueOfHeight(slopeData.heightSide_5tl);
            upperLevel  = GeographicTile.GetValueOfHeight(slopeData.heightSide_2dr);
            break;

        case DoubleSlopeDirection.DOWN_LEFT:
            bottomLevel = GeographicTile.GetValueOfHeight(slopeData.heightSide_0tr);
            upperLevel  = GeographicTile.GetValueOfHeight(slopeData.heightSide_3dl);
            break;

        default:
            bottomLevel = 0;
            upperLevel  = 0;
            Debug.LogError("The double slope direction is undefined. You may want to use the simple slope directions instead");
            break;
        }
    }
Esempio n. 9
0
        /// <summary> 将一侧边坡中的所有子边坡进行缝合 </summary>
        /// <param name="slpDt"></param>
        /// <param name="dir"></param>
        /// <returns>如果成功缝合,则返回 true,如果此侧边坡中原来就没有被分割,则返回 false</returns>
        private bool MergeSlope(SlopeData slpDt, MergeProtectionDirection dir)
        {
            bool merged           = false;
            var  newSlopes        = new List <Slope>();
            var  lastSubSlopeSegs = new List <Slope>();

            if (slpDt.Slopes.Count > 0)
            {
                int lastMainLevel = slpDt.Slopes[0].GetMainLevel();
                foreach (var s in slpDt.Slopes)
                {
                    if (s.GetMainLevel() != lastMainLevel)
                    {
                        // 先处理上一级子边坡中的所有更细子边坡
                        if (lastSubSlopeSegs.Count > 0)
                        {
                            var mergedSlope = MergeSubSlopes(lastSubSlopeSegs, slpDt.FillCut, dir);
                            merged = true;
                            newSlopes.Add(mergedSlope);
                            lastSubSlopeSegs = new List <Slope>();
                        }
                        //
                        lastMainLevel = s.GetMainLevel();
                    }
                    if (s.GetSubLevel() != 0)
                    {
                        SlopeLine.EraseText(s, _docMdf.acDataBase);
                        lastSubSlopeSegs.Add(s);
                    }
                    else
                    {
                        // 将本级子边坡添加进来
                        newSlopes.Add(s);
                    }
                }
                // 处理最后一级的多个细子边坡
                if (lastSubSlopeSegs.Count > 0)
                {
                    var mergedSlope = MergeSubSlopes(lastSubSlopeSegs, slpDt.FillCut, dir);
                    merged = true;
                    newSlopes.Add(mergedSlope);
                }
            }
            slpDt.Slopes = newSlopes;
            return(merged);
        }
Esempio n. 10
0
        /// <summary> 根据两个断面的边坡对象,来计算其各自所占的边坡区域(几何计算,无关于防护方式) </summary>
        /// <param name="backStation"></param>
        /// <param name="backSlopeData"></param>
        /// <param name="frontStation"></param>
        /// <param name="frontSlopeData"></param>
        /// <param name="backSlopeInfo"></param>
        /// <param name="backPlatformInfo"></param>
        /// <param name="frontSlopeInfo"></param>
        /// <param name="frontPlatformInfo"></param>
        private static void ExpandSlope(double backStation, SlopeData backSlopeData,
                                        double frontStation, SlopeData frontSlopeData,
                                        ref Dictionary <double, SlopeSegInfo> backSlopeInfo, ref Dictionary <double, SlopeSegInfo> backPlatformInfo,
                                        ref Dictionary <double, SlopeSegInfo> frontSlopeInfo, ref Dictionary <double, SlopeSegInfo> frontPlatformInfo)
        {
            double length;
            double area;

            // 1. 从后往前算
            var ssg = new SlopeSegsGeom(backStation, backSlopeData, frontStation, frontSlopeData);

            foreach (var bSlope in backSlopeData.Slopes)
            {
                ssg.GetBackSlopeLengthAndArea(bSlope, out length, out area);
                var ssi = backSlopeInfo[bSlope.Index];
                ssi.FrontStation = backStation + length;
                ssi.FrontArea    = area;
            }
            foreach (var bPltfm in backSlopeData.Platforms)
            {
                ssg.GetBackPlatformLengthAndArea(bPltfm, out length, out area);
                var ssi = backPlatformInfo[bPltfm.Index];
                ssi.FrontStation = backStation + length;
                ssi.FrontArea    = area;
            }
            // 2. 从前往后算
            ssg = new SlopeSegsGeom(frontStation, frontSlopeData, backStation, backSlopeData);
            foreach (var fSlope in frontSlopeData.Slopes)
            {
                ssg.GetBackSlopeLengthAndArea(fSlope, out length, out area);
                var ssi = frontSlopeInfo[fSlope.Index];
                ssi.BackStation = frontStation - length;
                ssi.BackArea    = area;
            }
            foreach (var fPltfm in frontSlopeData.Platforms)
            {
                ssg.GetBackPlatformLengthAndArea(fPltfm, out length, out area);
                var ssi = frontPlatformInfo[fPltfm.Index];
                ssi.BackStation = frontStation - length;
                ssi.BackArea    = area;
            }
        }
Esempio n. 11
0
        private void ChangeSelectedSlopeProtection(ISlopeSeg baseSeg)
        {
            var changedSlp      = dgv.Tag as SlopeLine;
            var changedXdata    = changedSlp.XData;
            var seperateFillCut = checkBox_SeperateFillCut.Checked; // 在统一修改时区分填方与挖方

            //
            foreach (SlopeLine slp in listBox_slopes.SelectedItems)
            {
                var xdata = slp.XData;
                if (!seperateFillCut || changedXdata.FillCut == xdata.FillCut)
                {
                    var slopes = SlopeData.Combine(slp.XData.Slopes, slp.XData.Platforms, false);
                    foreach (var s in slopes)
                    {
                        if (s.Type == baseSeg.Type && s.Index == baseSeg.Index)
                        {
                            s.ProtectionMethod = baseSeg.ProtectionMethod;
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary> 从边坡线所绑定的防护方式的文字对象来设置防护 </summary>
        public ExternalCmdResult FlushProtection(DocumentModifier docMdf, SelectionSet impliedSelection)
        {
            _docMdf = docMdf;
            SQUtils.SubgradeEnvironmentConfiguration(docMdf);
            // var allSections = ProtectionUtils.GetAllSections(docMdf);
            var slopeLines = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: true);

            // 从文字中提取边坡防护方式的数据
            foreach (var slp in slopeLines)
            {
                var xdata   = slp.XData;
                var slpSegs = SlopeData.Combine(xdata.Slopes, xdata.Platforms, sort: false);
                foreach (var s in slpSegs)
                {
                    SlopeLine.ExtractProtectionFromText(s, _docMdf.acDataBase);
                }
                // 将数据保存下来
                slp.Pline.UpgradeOpen();
                slp.FlushXData();
                slp.Pline.DowngradeOpen();
            }
            return(ExternalCmdResult.Commit);
        }
Esempio n. 13
0
 /// <summary> 构造函数 </summary>
 /// <param name="station"></param>
 /// <param name="slopeLine">此参数的值可能为 null ,表示此桩号断面上没有对应边坡 </param>
 public SlopeExpands(double station, SlopeLine slopeLine, bool onLeft)
 {
     //
     Station      = station;
     SlopeInfo    = new Dictionary <double, SlopeSegInfo>();
     PlatformInfo = new Dictionary <double, SlopeSegInfo>();
     if (slopeLine != null)
     {
         XData = slopeLine.XData;
     }
     else
     {
         XData = new SlopeData(station, onLeft);
     }
     // ConstructSlopeSegInfo();
     foreach (var sd in XData.Slopes)
     {
         SlopeInfo.Add(sd.Index, new SlopeSegInfo(0, 0, 0, 0));
     }
     foreach (var sd in XData.Platforms)
     {
         PlatformInfo.Add(sd.Index, new SlopeSegInfo(0, 0, 0, 0));
     }
 }
Esempio n. 14
0
        /// <summary> 根据前后边坡对象构造二维边坡系统 </summary>
        private void ConstructSlopeSystem()
        {
            double backBaseHeight = Math.Abs(_backSlope.RetainingWallHeight);

            // 后方边坡
            double innerLength  = backBaseHeight; // 斜坡长度
            double outterLength = innerLength;    // 斜坡长度

            var backSign = _backSlope.FillCut ? -1 : 1;

            _backSlopePoints = new Dictionary <double, Point2d[]>();
            var segs = SlopeData.Combine(_backSlope.Slopes, _backSlope.Platforms, true);

            foreach (var bs in segs)
            {
                if (bs.Type == SlopeSegType.边坡)
                {
                    outterLength = innerLength + bs.Length;
                    _backSlopePoints.Add(bs.Index,
                                         new Point2d[]
                                         { new Point2d(_backStation, backSign * innerLength), new Point2d(_backStation, backSign * outterLength) });
                    innerLength = outterLength;
                }
                else
                {
                    // Point2d[] 数组中两个值是相同的
                    _backSlopePoints.Add(-bs.Index,
                                         new Point2d[]
                                         { new Point2d(_backStation, backSign * innerLength), new Point2d(_backStation, backSign * innerLength) });
                }
            }
            //_maxBackSlopeIndex = _backSlope.Slopes.Count > 0 ? _backSlope.Slopes.Last().Index : 0;
            // _backEdge = _maxBackSlopeIndex > 0 ? _backSlopePoints[_maxBackSlopeIndex][1] : new Point2d(_backStation, 0);
            _backEdge = new Point2d(_backStation, backSign * outterLength);

            // 前方边坡
            var    frontSign       = _frontSlope.FillCut ? -1 : 1;
            double frontBaseHeight = Math.Abs(_frontSlope.RetainingWallHeight);

            innerLength       = frontBaseHeight;
            outterLength      = innerLength;
            _frontSlopePoints = new Dictionary <double, Point2d[]>();

            segs = SlopeData.Combine(_frontSlope.Slopes, _frontSlope.Platforms, true);
            foreach (var bs in segs)
            {
                if (bs.Type == SlopeSegType.边坡)
                {
                    outterLength = innerLength + bs.Length;
                    _frontSlopePoints.Add(bs.Index,
                                          new Point2d[]
                    {
                        new Point2d(_frontStation, frontSign * innerLength), new Point2d(_frontStation, frontSign * outterLength)
                    });
                    innerLength = outterLength;
                }
                else
                {
                    // Point2d[] 数组中两个值是相同的
                    _frontSlopePoints.Add(-bs.Index,
                                          new Point2d[]
                                          { new Point2d(_frontStation, frontSign * innerLength), new Point2d(_frontStation, frontSign * innerLength) });
                }
            }
            //_maxFrontSlopeIndex = _frontSlope.Slopes.Count > 0 ? _frontSlope.Slopes.Last().Index : 0;

            // _frontEdge = _maxFrontSlopeIndex > 0 ? _frontSlopePoints[_maxFrontSlopeIndex][1] : new Point2d(_frontStation, 0);
            _frontEdge = new Point2d(_frontStation, frontSign * outterLength);


            // 开口线
            _开口线 = new Line2d(_backEdge, _frontEdge);
        }
Esempio n. 15
0
        /// <summary> 某一个断面边坡中,与指定防护相匹配的子边坡的信息 </summary>
        /// <param name="sd"></param>
        /// <param name="se"></param>
        /// <param name="protectionMethod"></param>
        /// <param name="matchedSlopes">在此断面中,与指定防护相匹配的子边坡的 Index</param>
        /// <param name="matchedPlatforms">在此断面中,与指定防护相匹配的子平台的 Index</param>
        /// <param name="backEdgeStation">在此断面中,指定防护方式所占据的最小的桩号位置</param>
        /// <param name="frontEdgeStation">在此断面中,指定防护方式所占据的最大的桩号位置</param>
        /// <param name="area">在此断面中,指定防护方式在断面左右所占据的总面积</param>
        /// <returns></returns>
        private ProtectionRange IdentifyProtectionRange(SlopeData sd, SlopeExpands se, string protectionMethod,
                                                        out List <double> matchedSlopes, out List <double> matchedPlatforms, out double backEdgeStation,
                                                        out double frontEdgeStation, out double area)
        {
            var rg = ProtectionRange.None;

            matchedSlopes    = new List <double>();
            matchedPlatforms = new List <double>();
            frontEdgeStation = AllStations[0];
            backEdgeStation  = AllStations[AllStations.Length - 1];
            area             = 0;
            //
            bool allSlopes = sd.Slopes.Count > 0;

            foreach (var s in sd.Slopes)
            {
                if (s.ProtectionMethod != protectionMethod)
                {
                    allSlopes = false;
                }
                else
                {
                    var ssinfo = se.SlopeInfo[s.Index];
                    backEdgeStation  = Math.Min(backEdgeStation, ssinfo.BackStation);
                    frontEdgeStation = Math.Max(frontEdgeStation, ssinfo.FrontStation);
                    area            += ssinfo.BackArea + ssinfo.FrontArea;
                    matchedSlopes.Add(s.Index);
                }
            }

            bool allPlatform = sd.Platforms.Count > 0;

            foreach (var p in sd.Platforms)
            {
                if (p.ProtectionMethod != protectionMethod)
                {
                    allPlatform = false;
                }
                else
                {
                    var ssinfo = se.PlatformInfo[p.Index];
                    backEdgeStation  = Math.Min(backEdgeStation, ssinfo.BackStation);
                    frontEdgeStation = Math.Max(frontEdgeStation, ssinfo.FrontStation);
                    area            += ssinfo.BackArea + ssinfo.FrontArea;
                    matchedPlatforms.Add(p.Index);
                }
            }

            if (allSlopes)
            {
                if (allPlatform)
                {
                    rg = ProtectionRange.AllSection;
                }
                else if (matchedPlatforms.Count > 0)
                {
                    rg = ProtectionRange.AllSlopes | ProtectionRange.PartialPlatforms;
                }
                else
                {
                    rg = ProtectionRange.AllSlopes;
                }
            }
            else if (allPlatform)
            {
                if (allSlopes)
                {
                    rg = ProtectionRange.AllSection;
                }
                else if (matchedSlopes.Count > 0)
                {
                    rg = ProtectionRange.AllPlatforms | ProtectionRange.PartialSlopes;
                }
                else
                {
                    rg = ProtectionRange.AllPlatforms;
                }
            }
            // 说明既没有全边坡,也没有全平台
            else if (matchedSlopes.Count > 0 && matchedPlatforms.Count == 0)
            {
                rg = ProtectionRange.PartialSlopes;
            }
            else if (matchedPlatforms.Count > 0 && matchedSlopes.Count == 0)
            {
                rg = ProtectionRange.PartialPlatforms;
            }
            else if (matchedPlatforms.Count > 0 && matchedSlopes.Count > 0)
            {
                rg = ProtectionRange.PartialPlatforms | ProtectionRange.PartialSlopes;
            }
            else
            {
                rg = ProtectionRange.None;
            }
            return(rg);
        }
Esempio n. 16
0
    private static void GetTheDirectionAndTypeOfSlope(SlopeData slopeData, out bool isSimpleSlope, out SimpleSlopeDirection simpleSlopeDirection, out DoubleSlopeDirection doubleSlopeDirection)
    {
        doubleSlopeDirection = DoubleSlopeDirection.UDEFINDED;
        simpleSlopeDirection = SimpleSlopeDirection.UNDEFINED;

        var topRight_h  = slopeData.heightSide_0tr;
        var right_h     = slopeData.heightSide_1r;
        var downRight_h = slopeData.heightSide_2dr;
        var downLeft_h  = slopeData.heightSide_3dl;
        var left_h      = slopeData.heightSide_4l;
        var topLeft_h   = slopeData.heightSide_5tl;


        bool simple_TopRight  = topRight_h != right_h && topRight_h != left_h && left_h == downRight_h && left_h == downLeft_h && right_h == topLeft_h;
        bool simple_Right     = right_h != topRight_h && right_h != left_h && left_h == downLeft_h && left_h == topLeft_h && topRight_h == downRight_h;
        bool simple_DownRight = downRight_h != right_h && downRight_h != left_h && left_h == topRight_h && left_h == topLeft_h && right_h == downLeft_h;
        bool simple_DownLeft  = downLeft_h != left_h && downLeft_h != right_h && right_h == topRight_h && right_h == topLeft_h && left_h == downRight_h;
        bool simple_Left      = left_h != downLeft_h && left_h != right_h && right_h == topRight_h && right_h == downRight_h && downLeft_h == topLeft_h;
        bool simple_TopLeft   = topLeft_h != left_h && topLeft_h != right_h && right_h == downLeft_h && right_h == downRight_h && left_h == topRight_h;


        bool double_TopRight  = topRight_h == right_h && right_h != downRight_h && right_h != left_h && left_h == downLeft_h && downRight_h == topLeft_h;
        bool double_DownRight = right_h == downRight_h && right_h != downLeft_h && right_h != left_h && left_h == topLeft_h && downLeft_h == topRight_h;
        bool double_Down      = downRight_h == downLeft_h && downRight_h != right_h && downRight_h != topLeft_h && right_h == left_h && topLeft_h == topRight_h;
        bool double_DownLeft  = downLeft_h == left_h && downLeft_h != downRight_h && downLeft_h != right_h && right_h == topRight_h && downRight_h == topLeft_h;
        bool double_TopLeft   = left_h == topLeft_h && left_h != downLeft_h && left_h != right_h && right_h == downRight_h && downLeft_h == topRight_h;
        bool double_Top       = topLeft_h == topRight_h && topLeft_h != right_h && topLeft_h != downLeft_h && downLeft_h == downRight_h && right_h == left_h;


        if (simple_TopRight)
        {
            simpleSlopeDirection = SimpleSlopeDirection.TOP_RIGHT;
            isSimpleSlope        = true;
            return;
        }
        else if (simple_Right)
        {
            simpleSlopeDirection = SimpleSlopeDirection.RIGHT;
            isSimpleSlope        = true;
            return;
        }
        else if (simple_DownRight)
        {
            simpleSlopeDirection = SimpleSlopeDirection.DOWN_RIGHT;
            isSimpleSlope        = true;
            return;
        }
        else if (simple_DownLeft)
        {
            simpleSlopeDirection = SimpleSlopeDirection.DOWN_LEFT;
            isSimpleSlope        = true;
            return;
        }
        else if (simple_Left)
        {
            simpleSlopeDirection = SimpleSlopeDirection.LEFT;
            isSimpleSlope        = true;
            return;
        }
        else if (simple_TopLeft)
        {
            simpleSlopeDirection = SimpleSlopeDirection.TOP_LEFT;
            isSimpleSlope        = true;
            return;
        }


        else if (double_TopRight)
        {
            doubleSlopeDirection = DoubleSlopeDirection.TOP_RIGHT;
            isSimpleSlope        = false;
            return;
        }
        else if (double_DownRight)
        {
            doubleSlopeDirection = DoubleSlopeDirection.DOWN_RIGHT;
            isSimpleSlope        = false;
            return;
        }
        else if (double_Down)
        {
            doubleSlopeDirection = DoubleSlopeDirection.DOWN;
            isSimpleSlope        = false;
            return;
        }
        else if (double_DownLeft)
        {
            doubleSlopeDirection = DoubleSlopeDirection.DOWN_LEFT;
            isSimpleSlope        = false;
            return;
        }
        else if (double_TopLeft)
        {
            doubleSlopeDirection = DoubleSlopeDirection.TOP_LEFT;
            isSimpleSlope        = false;
            return;
        }
        else if (double_Top)
        {
            doubleSlopeDirection = DoubleSlopeDirection.TOP;
            isSimpleSlope        = false;
            return;
        }

        else
        {
            throw new System.Exception($"The slope tile doest't have a valid format! it's values are; \n" +
                                       $"Top right:{ topRight_h}\nRight:{right_h}\nDown right:{downRight_h}\nDown left:{downLeft_h}\nLeft:{left_h}\nTop left:{topLeft_h}");
        }
    }