コード例 #1
0
    /// <summary>
    /// 删除一个楼梯区间的楼梯
    /// </summary>
    private static void DeleteStairAreaStair(int Layer, int Start, int End)
    {
        bool     haveStair           = false;
        int      distance            = 0;
        RoomGrid deleteStairRoomGrid = null;

        for (int unit = Start; unit <= End; unit++)
        {
            RoomGrid R = FindRoomGrid(new Int2(unit, Layer), XYSYS.RoomGrid);
            if (R != null && R.HaveStair())
            {
                if (haveStair == false)
                {
                    distance            = DistanceGold(R);
                    haveStair           = true;
                    deleteStairRoomGrid = R;
                }
                else if (deleteStairRoomGrid != null)
                {
                    int d = DistanceGold(R);
                    //删除距离近的楼梯
                    if (d <= distance)
                    {
                        R.RemovStair();
                    }
                    else
                    {
                        deleteStairRoomGrid.RemovStair();
                        deleteStairRoomGrid = R;
                        distance            = d;
                    }
                }
            }
        }
    }
コード例 #2
0
 /// <summary>
 /// 确认该区间是否需要楼梯,需要则计算楼梯的位置
 /// </summary>
 public static bool CheckStairPoint(int Layer, int Start, int End, ref Int2 StairPoint)
 {
     StairPoint = Int2.zero;
     for (int unit = Start; unit <= End; unit++)
     {
         RoomGrid R = FindRoomGrid(new Int2(unit, Layer), XYSYS.RoomGrid);
         if (R != null && R.HaveStair())
         {
             return(false);
         }
     }
     //计算需要楼梯的位置
     StairPoint = GetBestStairPoint(Layer, Start, End);
     return(true);
 }