asmrobot
2019-10-29 f25f89101a98ad815c0ae2d25e1a8dc35d53a5dd
format state machine
1 files added
14 files modified
611 ■■■■■ changed files
libs/ZTImage.dll patch | view | raw | blame | history
src/RichCreator.Editor/Tools/MapEditor.xaml 8 ●●●●● patch | view | raw | blame | history
src/RichCreator.Editor/Tools/MapEditor.xaml.cs 444 ●●●●● patch | view | raw | blame | history
src/RichCreator.Utility/PathFinding/DijkstraFinding/Dijkstra.cs 14 ●●●● patch | view | raw | blame | history
src/RichCreator.Utility/Structs/HousePathInfo.cs 27 ●●●●● patch | view | raw | blame | history
src/RichCreator.Utility/Structs/ZTLinePoint.cs 2 ●●● patch | view | raw | blame | history
src/RichCreator.Utility/Structs/ZTPoint.cs 34 ●●●●● patch | view | raw | blame | history
src/RichCreator.Utility/Structs/ZTPolygon.cs 33 ●●●●● patch | view | raw | blame | history
src/RichCreator.Utility/Structs/ZTRectangle.cs 6 ●●●● patch | view | raw | blame | history
src/RichCreator.Utility/Utilitys/GeometryHelper.cs 4 ●●●● patch | view | raw | blame | history
src/RichCreator.sln 2 ●●● patch | view | raw | blame | history
src/RichCreator/PathFinding/Dijkstra.cs 14 ●●●● patch | view | raw | blame | history
src/RichCreator/StateMachines/KillMonsterStateMachine.cs 8 ●●●● patch | view | raw | blame | history
src/RichCreator/StateMachines/MoveState.cs 2 ●●● patch | view | raw | blame | history
src/test/Program.cs 13 ●●●●● patch | view | raw | blame | history
libs/ZTImage.dll
Binary files differ
src/RichCreator.Editor/Tools/MapEditor.xaml
@@ -17,8 +17,6 @@
            <Grid>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,4,0,0">
                    
                    <TextBlock Text="参数:" Margin="22 0 0 0" VerticalAlignment="Center" />
                    <TextBox Width="45" x:Name="tagNumber" Text="0" VerticalContentAlignment="Center"/>
@@ -28,9 +26,12 @@
                        <ComboBoxItem>寻路点</ComboBoxItem>
                        <ComboBoxItem>巡逻线</ComboBoxItem>
                        <ComboBoxItem>寻路线</ComboBoxItem>
                        <ComboBoxItem>测试起终点 </ComboBoxItem>
                    </ComboBox>
                    <Button Content="清空定位点" Margin="5 0" Click="ClearPosition_Click" />
                    <TextBlock VerticalAlignment="Center">除定位点外,其它物体右键删除。</TextBlock>
                    <Button Content="清空寻路起始和终点" Margin="5 0" Click="ClearStartEndPoint_Click" />
                    <Button Content="测试寻路" Margin="5 0" Click="TestFindPath_Click" />
                </StackPanel>
@@ -45,10 +46,11 @@
        
        <ScrollViewer x:Name="scrollViewer" Grid.Row="1"    HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" >
            <Canvas x:Name="mainContainer" HorizontalAlignment="Left" VerticalAlignment="Top" MouseMove="SourceImage_MouseMove"  MouseDown="SourceImage_MouseDown" PreviewMouseUp="SourceImage_MouseUp" MouseUp="SourceImage_MouseUp">
            <Canvas x:Name="mainContainer" HorizontalAlignment="Left" VerticalAlignment="Top"  MouseLeftButtonDown="SourceImage_MouseDown" MouseMove="SourceImage_MouseMove"  PreviewMouseLeftButtonUp="SourceImage_MouseUp">
                <Image x:Name="SourceImage" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top"  />
                <Canvas x:Name="HouseInfoLayer" />
                <Canvas x:Name="LocationPointLayer" IsHitTestVisible="False"/>
                <Canvas x:Name="StartEndPointLayer" IsHitTestVisible="False"/>
                <!--<Polyline StrokeThickness="1" Stroke="Black"    Opacity="0.5">
                    <Polyline.Points>10,50 180,50 180,150 </Polyline.Points>
src/RichCreator.Editor/Tools/MapEditor.xaml.cs
@@ -29,15 +29,16 @@
            InitializeComponent();
        }
        // 寻路信息
        private HousePathInfo housePathInfo = null;
        private bool isinit = false;//是否加载图片
        private HousePathInfo housePathInfo = null;//房间信息
        private bool moveable = false;//可移动的
        private Line tempLine = null;
        private Polyline tempPolyline = null;
        private Line tempLine = null;//临时线
        private Polyline tempPolyline = null;//临时障碍物
        private System.Drawing.Image image = null;// 当前图像
        private List<ZTPoint> startEndFindPathPoint = new List<ZTPoint>();//测试寻路起点和终点
        // 当前图像
        private System.Drawing.Image image;
        #region 事件
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
@@ -68,7 +69,7 @@
            this.image = source.Bitmap;
            SetImage();
        }
        /// <summary>
        /// 复制JSON
        /// </summary>
@@ -76,8 +77,13 @@
        /// <param name="e"></param>
        private void CopyJSON_Click(object sender, RoutedEventArgs e)
        {
            if (!isinit)
            {
                return;
            }
            string json = this.housePathInfo.ToJsonString();
            Clipboard.SetDataObject(json, true);
            MessageBox.Show("copy success");
        }
        /// <summary>
@@ -87,43 +93,63 @@
        /// <param name="e"></param>
        private void CreateFromJSON_Click(object sender, RoutedEventArgs e)
        {
            //SerializeInput input = new SerializeInput();
            //if (input.ShowDialog() != true)
            //{
            //    return;
            //}
            if (!isinit)
            {
                MessageBox.Show("请先加载图片");
                return;
            }
            //FindPathInfo pi = FindPathInfo.FromJsonString(input.ColorString);
            SerializeInput input = new SerializeInput();
            if (input.ShowDialog() != true)
            {
                return;
            }
            var info = ZTImage.Json.JsonParser.ToObject<HousePathInfo>(input.ColorString);
            if (info == null)
            {
                return;
            }
            //依次加载,障碍物,定位点,寻路点,巡逻线,寻路线
            //加载障碍物
            for (int i = 0; i < info.Obstacles.Count; i++)
            {
                Polygon polygon=CreateObstacleUI(info.Obstacles[i]);
                this.HouseInfoLayer.Children.Add(polygon);
            }
            //加载定位点
            for (int i = 0; i < info.LocationPoints.Count; i++)
            {
                Canvas lp = CreateLocationPointUI(info.LocationPoints[i]);
                this.HouseInfoLayer.Children.Add(lp);
            }
            //加载寻路点
            for (int i = 0; i < info.FindPathPoints.Count; i++)
            {
                Canvas fp = CreateFindPathPointUI(info.FindPathPoints[i]);
                this.HouseInfoLayer.Children.Add(fp);
            }
            ////生成网格
            //this.rectWidth.Text = pi.Width.ToString();
            //this.rectHeight.Text = pi.Height.ToString();
            //GenericRect(pi.Width, pi.Height, pi.RowCount, pi.ColCount);
            //加载巡逻线
            for (int i = 0; i < info.LoopLines.Count; i++)
            {
                Line llline = CreateLoopLineUI(info.LoopLines[i]);
                this.HouseInfoLayer.Children.Add(llline);
            }
            //加载寻路线
            for (int i = 0; i < info.FindPathLines.Count; i++)
            {
                Line fpline = CreateFindPathLineUI(info.FindPathLines[i]);
                this.HouseInfoLayer.Children.Add(fpline);
            }
            ////生成顶点
            //for (int i = 0; i < pi.Vertexs.Count; i++)
            //{
            //    SetVertexUI(pi.Vertexs[i]);
            //}
            ////生成连线
            //for (int i = 0; i < pi.Edges.Count; i++)
            //{
            //    GenericEdge(pi.Edges[i].StartIndex);
            //    SetEdge(pi.Edges[i].EndIndex);
            //}
            //this.PositionOverflowLayer.Children.Clear();
            ////生成定位点
            //for (int i = 0; i < pi.Positions.Count; i++)
            //{
            //    AddLocationPoint(pi.Positions[i].X, pi.Positions[i].Y, pi.Positions[i].Parameter);
            //}
            this.housePathInfo = info;
        }
        /// <summary>
@@ -133,8 +159,48 @@
        /// <param name="e"></param>
        private void ClearPosition_Click(object sender, RoutedEventArgs e)
        {
            if (!isinit)
            {
                return;
            }
            this.LocationPointLayer.Children.Clear();
            this.housePathInfo.ClearLocationPosiltion();
        }
        /// <summary>
        /// 清空寻路测试点的起点和终点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClearStartEndPoint_Click(object sender, RoutedEventArgs e)
        {
            if (!isinit)
            {
                return;
            }
            this.StartEndPointLayer.Children.Clear();
            this.startEndFindPathPoint.Clear();
        }
        /// <summary>
        /// 测试寻路
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TestFindPath_Click(object sender, RoutedEventArgs e)
        {
            if (this.startEndFindPathPoint.Count < 2)
            {
                MessageBox.Show("请选择测试的起点和终点");
            }
            ZTPoint start = this.startEndFindPathPoint[0];
            ZTPoint end = this.startEndFindPathPoint[1];
            List<ZTPoint> path=this.housePathInfo.FindPath(start, end);
            //todo:绘制路径
        }
@@ -145,6 +211,10 @@
        /// <param name="e"></param>
        private void SourceImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!isinit)
            {
                return;
            }
            //是否添加障碍物
            OperateActionD op = (OperateActionD)(slOperate.SelectedIndex);
            Int32 number = TypeConverter.StringToInt(this.tagNumber.Text, 0);
@@ -184,28 +254,33 @@
            else if (op == OperateActionD.LoopLine)
            {
                //循环线
                ZTPoint llPoint = GetFindPathPoint(new ZTPoint((Int32)point.X,(Int32)point.Y));
                if (llPoint != ZTPoint.Empty)
                ZTPoint llPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
                if (!llPoint.Equals(ZTPoint.Empty))
                {
                    tempLine = CreateTempLoopLineUI(llPoint);
                    this.HouseInfoLayer.Children.Add(tempLine);
                    moveable = true;
                }
                }
            }
            else if (op == OperateActionD.FindPathLine)
            {
                //寻路线
                ZTPoint fpPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
                if (fpPoint != ZTPoint.Empty)
                if (!fpPoint.Equals(ZTPoint.Empty))
                {
                    tempLine = CreateTempFindPathLineUI(fpPoint);
                    this.HouseInfoLayer.Children.Add(tempLine);
                    moveable = true;
                }
            }
            else if (op == OperateActionD.StartEndPoint)
            {
                //画寻路起始和终点
                ZTPoint sepoint = new ZTPoint((Int32)point.X, (Int32)point.Y);
                Canvas lseControl = CreateStartEndPointUI(sepoint);
                this.StartEndPointLayer.Children.Add(lseControl);
                this.startEndFindPathPoint.Add(sepoint);
            }
        }
        /// <summary>
@@ -215,6 +290,10 @@
        /// <param name="e"></param>
        private void SourceImage_MouseMove(object sender, MouseEventArgs e)
        {
            if (!isinit)
            {
                return;
            }
            OperateActionD op = (OperateActionD)(slOperate.SelectedIndex);
            Point point = GetPosition(e);
            if (op == OperateActionD.LoopLine)
@@ -248,7 +327,7 @@
                tempLine.Y2 = point.Y;
            }
        }
        /// <summary>
        /// 鼠标提起
        /// </summary>
@@ -256,6 +335,10 @@
        /// <param name="e"></param>
        private void SourceImage_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (!isinit)
            {
                return;
            }
            OperateActionD op = (OperateActionD)(slOperate.SelectedIndex);
            Point point = GetPosition(e);
@@ -273,7 +356,7 @@
                }
                ZTPoint startPoint = (ZTPoint)tempLine.Tag;
                ZTPoint centerPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
                if (centerPoint != ZTPoint.Empty)
                if (!centerPoint.Equals(ZTPoint.Empty))
                {
                    ZTLinePoint ll = new ZTLinePoint(startPoint, centerPoint);
                    if (this.housePathInfo.AddLoopLine(ll))
@@ -300,7 +383,7 @@
                }
                ZTPoint startPoint = (ZTPoint)tempLine.Tag;
                ZTPoint centerPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
                if (centerPoint != ZTPoint.Empty)
                if (!centerPoint.Equals(ZTPoint.Empty))
                {
                    ZTLinePoint fp = new ZTLinePoint(startPoint, centerPoint);
                    if (this.housePathInfo.AddFindPathLine(fp))
@@ -321,7 +404,7 @@
                {
                    //首次画
                    this.points.Add(point);
                    this.tempPolyline=CreateTempObstacleUI(point);
                    this.tempPolyline = CreateTempObstacleUI(point);
                    this.tempLine = CreateObstacleLineUI(new ZTPoint((Int32)point.X, (Int32)point.Y));
                    moveable = true;
@@ -333,22 +416,24 @@
                    if (IsLastPoint(point))
                    {
                        //判断是否跟最后一个点重合,如果重合则不处理
                        //判断是否只有两个点,如果是则不处理
                        return;
                    }
                    if (IsFirstPoint(point))
                    if (IsFirstPoint(point) && this.points.Count > 2)
                    {
                        //到起点,完成,画折线,向houseinfo里添加障碍物
                        Polygon polygon = CreateObstacleUI();
                        this.HouseInfoLayer.Children.Add(polygon);
                        //到起点,完成,向houseinfo里添加障碍物 ,画折线,
                        ZTPoint[] obstaclePoints = new ZTPoint[this.points.Count];
                        for (int i = 0; i < this.points.Count; i++)
                        {
                            obstaclePoints[i] = new ZTPoint((Int32)this.points[i].X, (Int32)this.points[i].Y);
                        }
                        this.housePathInfo.AddObstacle(new ZTPolygon(obstaclePoints));
                        ZTPolygon ztpolygon = new ZTPolygon(obstaclePoints);
                        this.housePathInfo.AddObstacle(ztpolygon);
                        Polygon polygon = CreateObstacleUI(ztpolygon);
                        this.HouseInfoLayer.Children.Add(polygon);
                        this.HouseInfoLayer.Children.Remove(tempPolyline);
                        tempPolyline = null;
@@ -373,72 +458,7 @@
            }
        }
        /// <summary>
        /// 计算当前鼠标位置和颜色
        /// </summary>
        /// <param name="e"></param>
        /// <param name="point"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        private Point GetPosition(MouseEventArgs e)
        {
            Point point = e.GetPosition(this.scrollViewer);
            Int32 x = (Int32)Math.Round(this.scrollViewer.HorizontalOffset + point.X);
            Int32 y = (Int32)Math.Round(this.scrollViewer.VerticalOffset + point.Y);
            return new Point(x, y);
        }
        private List<Point> points = new List<Point>();
        /// <summary>
        /// 是否第一个点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private bool IsFirstPoint(Point point)
        {
            Point temp =this.points[0];
            if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// 是否最后一个点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private bool IsLastPoint(Point point)
        {
            Point temp = this.points[this.points.Count-1];
            if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// 操作类型
        /// </summary>
        public enum OperateActionD
        {
            Obstacle = 0,//障碍物
            LocationPoint,//定位点
            FindPathPoint,//寻路点
            LoopLine,//循环线
            FindPathLine,//寻路线
        }
        #endregion
        #region createUI
@@ -453,7 +473,12 @@
            this.SourceImage.Source = t;
            mainContainer.Width = image.Width;
            mainContainer.Height = image.Height;
            this.housePathInfo = new HousePathInfo();
            this.housePathInfo = new HousePathInfo(image.Width, image.Height);
            System.Threading.ThreadPool.QueueUserWorkItem((obj) =>
            {
                System.Threading.Thread.Sleep(1000);
                isinit = true;
            });
        }
@@ -470,9 +495,9 @@
            Canvas main = new Canvas();
            main.Tag = point;
            Canvas.SetLeft(main,point.Point.X);
            Canvas.SetLeft(main, point.Point.X);
            Canvas.SetTop(main, point.Point.Y);
            Rectangle rect = new Rectangle();
            Canvas.SetLeft(rect, -10);
            Canvas.SetTop(rect, -10);
@@ -483,7 +508,7 @@
            rect.Fill = new SolidColorBrush(Colors.Red);
            rect.Opacity = 0.5f;
            main.Children.Add(rect);
            Ellipse elli = new Ellipse();
            Canvas.SetLeft(elli, -2);
            Canvas.SetTop(elli, -2);
@@ -493,7 +518,7 @@
            elli.StrokeThickness = 1;
            elli.Fill = new SolidColorBrush(Colors.Black);
            main.Children.Add(elli);
            TextBlock tb = new TextBlock();
            tb.Text = point.Parameter.ToString();
            tb.FontSize = 9;
@@ -502,7 +527,7 @@
            return main;
        }
        /// <summary>
        /// 创建寻路点UI
        /// </summary>
@@ -545,7 +570,7 @@
            return main;
        }
        /// <summary>
        /// 寻路点右击
        /// </summary>
@@ -572,9 +597,9 @@
            {
                this.HouseInfoLayer.Children.Remove(c);
            }
        }
        /// <summary>
        /// 创建巡逻线UI
        /// </summary>
@@ -596,7 +621,7 @@
            edgeLine.StrokeEndLineCap = PenLineCap.Square;
            edgeLine.StrokeStartLineCap = PenLineCap.Round;
            return edgeLine;
        }
@@ -650,7 +675,7 @@
            edgeLine.StrokeDashCap = PenLineCap.Triangle;
            edgeLine.StrokeEndLineCap = PenLineCap.Square;
            edgeLine.StrokeStartLineCap = PenLineCap.Round;
            return edgeLine;
        }
@@ -670,8 +695,8 @@
            edgeLine.X2 = linePoint.X2;
            edgeLine.Y2 = linePoint.Y2;
            return edgeLine;
        }
@@ -720,8 +745,8 @@
            edgeLine.X2 = point.X;
            edgeLine.Y2 = point.Y;
            return edgeLine;
        }
@@ -747,22 +772,52 @@
        /// 创建障碍物UI
        /// </summary>
        /// <returns></returns>
        private Polygon CreateObstacleUI()
        private Polygon CreateObstacleUI(ZTPolygon ztpolygon)
        {
            //<!--<Polygon StrokeThickness="1" Stroke="Black"    Opacity="0.5">
            //        <Polygon.Points>10,50 180,50 180,150 </Polygon.Points>
            //    </Polygon>-->
            Polygon polygon = new Polygon();
            polygon.Tag = ztpolygon;
            polygon.MouseRightButtonUp += Polygon_MouseRightButtonUp;
            polygon.StrokeThickness = 1;
            polygon.Stroke = new SolidColorBrush(Colors.Black);
            polygon.Fill= new SolidColorBrush(Colors.Black);
            polygon.Fill = new SolidColorBrush(Colors.Black);
            polygon.Opacity = 0.7f;
            for (int i = 0; i < this.points.Count; i++)
            {
                polygon.Points.Add(this.points[i]);
            }
            return polygon;
        }
        /// <summary>
        /// 障碍物右键删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Polygon_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            Polygon c = sender as Polygon;
            if (c == null)
            {
                return;
            }
            ZTPolygon ztp = default(ZTPolygon);
            try
            {
                ztp = (ZTPolygon)c.Tag;
            }
            catch
            {
                return;
            }
            if (this.housePathInfo.RemoveObstacle(ztp))
            {
                this.HouseInfoLayer.Children.Remove(c);
            }
        }
@@ -803,15 +858,114 @@
                    return temp;
                }
            }
            return default(ZTPoint);
            return ZTPoint.Empty;
        }
        /// <summary>
        /// 创建起始和终止寻路点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private Canvas CreateStartEndPointUI(ZTPoint point)
        {
            Canvas main = new Canvas();
            main.Tag = point;
            Canvas.SetLeft(main, point.X);
            Canvas.SetTop(main, point.Y);
            Rectangle rect = new Rectangle();
            Canvas.SetLeft(rect, -10);
            Canvas.SetTop(rect, -10);
            rect.Width = 20;
            rect.Height = 20;
            rect.Stroke = new SolidColorBrush(Colors.Green);
            rect.StrokeThickness = 1;
            rect.Fill = new SolidColorBrush(Colors.Green);
            rect.Opacity = 0.5f;
            main.Children.Add(rect);
            Ellipse elli = new Ellipse();
            Canvas.SetLeft(elli, -2);
            Canvas.SetTop(elli, -2);
            elli.Width = 4;
            elli.Height = 4;
            elli.Stroke = new SolidColorBrush(Colors.Black);
            elli.StrokeThickness = 1;
            elli.Fill = new SolidColorBrush(Colors.Black);
            main.Children.Add(elli);
            return main;
        }
        #endregion
        #region Tools
        //private bool PointInRang(Point)
        /// <summary>
        /// 计算当前鼠标位置和颜色
        /// </summary>
        /// <param name="e"></param>
        /// <param name="point"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        private Point GetPosition(MouseEventArgs e)
        {
            Point point = e.GetPosition(this.scrollViewer);
            Int32 x = (Int32)Math.Round(this.scrollViewer.HorizontalOffset + point.X);
            Int32 y = (Int32)Math.Round(this.scrollViewer.VerticalOffset + point.Y);
            return new Point(x, y);
        }
        private List<Point> points = new List<Point>();
        /// <summary>
        /// 是否第一个点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private bool IsFirstPoint(Point point)
        {
            Point temp = this.points[0];
            if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
            {
                return true;
            }
            return false;
        }
        /// <summary>
        /// 是否最后一个点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private bool IsLastPoint(Point point)
        {
            Point temp = this.points[this.points.Count - 1];
            if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
            {
                return true;
            }
            return false;
        }
        #endregion
        /// <summary>
        /// 操作类型
        /// </summary>
        public enum OperateActionD
        {
            Obstacle = 0,//障碍物
            LocationPoint,//定位点
            FindPathPoint,//寻路点
            LoopLine,//循环线
            FindPathLine,//寻路线
            StartEndPoint,//测试起终点
        }
    }
}
src/RichCreator.Utility/PathFinding/DijkstraFinding/Dijkstra.cs
@@ -41,8 +41,8 @@
                return new List<ZTPoint>();
            }
            var s = nodes.Where(x => x.Name == start).ToList();
            var u = nodes.Where(x => x.Name != start).ToList();
            var s = nodes.Where(x => x.Name.Equals(start)).ToList();
            var u = nodes.Where(x => !x.Name.Equals( start)).ToList();
            s.ForEach(x =>
            {
@@ -103,11 +103,11 @@
        private Edge GetEdgeByTwoNode(Node start, Node end)
        {
            var edge = edges.FirstOrDefault(x => x.Start == start.Name && x.End == end.Name);
            var edge = edges.FirstOrDefault(x => x.Start .Equals( start.Name) && x.End .Equals( end.Name));
            if (edge == null)
            {
                edge = edges.FirstOrDefault(x => x.Start == end.Name && x.End == start.Name);
                edge = edges.FirstOrDefault(x => x.Start .Equals( end.Name) && x.End.Equals( start.Name));
            }
            return edge;
@@ -142,7 +142,7 @@
        /// <returns></returns>
        private Node GetNodeByName(ZTPoint nodeName)
        {
            return nodes.FirstOrDefault(x => x.Name == nodeName);
            return nodes.FirstOrDefault(x => x.Name.Equals(nodeName));
        }
        /// <summary>
@@ -152,7 +152,7 @@
        {
            edges.ForEach(edge =>
            {
                if (nodes.All(x => x.Name != edge.Start))
                if (nodes.All(x => !x.Name.Equals(edge.Start)))
                {
                    nodes.Add(new Node()
                    {
@@ -160,7 +160,7 @@
                    });
                }
                if (nodes.All(x => x.Name != edge.End))
                if (nodes.All(x => !x.Name.Equals(edge.End)))
                {
                    nodes.Add(new Node()
                    {
src/RichCreator.Utility/Structs/HousePathInfo.cs
@@ -94,16 +94,16 @@
        /// </summary>
        /// <param name="obstacle"></param>
        /// <returns></returns>
        public void RemoveObstacle(ZTPolygon obstacle)
        public bool RemoveObstacle(ZTPolygon obstacle)
        {
            Int32 index = 0;
            if (!ExistsObstacle(out index, obstacle))
            {
                return;
                return true;
            }
            this.Obstacles.RemoveAt(index);
            return;
            return true;
        }
        /// <summary>
@@ -134,7 +134,7 @@
        /// <returns></returns>
        public bool AddLocationPosition(ParametersPoint point)
        {
            if (this.LocationPoints.Exists((p) => { return point.Point == p.Point; }))
            if (this.LocationPoints.Exists((p) => { return point.Point.Equals(p.Point); }))
            {
                return false;
            }
@@ -204,7 +204,7 @@
            index = 0;
            for (int i = 0; i < this.FindPathPoints.Count; i++)
            {
                if (this.FindPathPoints[i] == point)
                if (this.FindPathPoints[i].Equals(point))
                {
                    index = i;
                    return true;
@@ -225,7 +225,7 @@
            {
                return false;
            }
            if (line.P1 == line.P2)
            if (line.P1 .Equals( line.P2))
            {
                return false;
            }
@@ -331,7 +331,7 @@
        {
            for (int i = 0; i < this.LoopLines.Count; i++)
            {
                if (this.LoopLines[i].P1 == point || this.LoopLines[i].P2 == point)
                if (this.LoopLines[i].P1.Equals(point) || this.LoopLines[i].P2.Equals(point))
                {
                    return true;
                }
@@ -339,7 +339,7 @@
            for (int i = 0; i < this.FindPathLines.Count; i++)
            {
                if (this.FindPathLines[i].P1 == point || this.FindPathLines[i].P2 == point)
                if (this.FindPathLines[i].P1 .Equals( point) || this.FindPathLines[i].P2.Equals(point))
                {
                    return true;
                }
@@ -375,7 +375,7 @@
        /// 寻找巡逻路线
        /// </summary>
        /// <param name="rolePosition"></param>
        public static void FindLoopPath(ZTPoint rolePosition)
        public void FindLoopPath(ZTPoint rolePosition)
        {
        }
@@ -385,9 +385,14 @@
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        public static void FindPath(ZTPoint start, ZTPoint end)
        public List<ZTPoint> FindPath(ZTPoint start, ZTPoint end)
        {
            //查询两点间是否连通
            //查找两点是否在障碍物里,如果在则计算出来的最短距离
            //计算最近的寻路点
            //计算寻路点的最短路径
            //得出所有路径点
            return new List<ZTPoint>();
        }
src/RichCreator.Utility/Structs/ZTLinePoint.cs
@@ -78,7 +78,7 @@
        public static bool operator ==(ZTLinePoint a, ZTLinePoint b)
        {
            if ((a.p1 == b.p1 && a.p2 == b.p2) || (a.p1 == b.p2 && a.p2 == b.p1))
            if ((a.p1 .Equals( b.p1) && a.p2.Equals(b.p2)) || (a.p1 .Equals( b.p2) && a.p2.Equals(b.p1)))
            {
                return true;
            }
src/RichCreator.Utility/Structs/ZTPoint.cs
@@ -9,10 +9,14 @@
    /// <summary>
    /// 点
    /// </summary>
    public class ZTPoint : IEquatable<ZTPoint>
    public class ZTPoint
    {
        public static ZTPoint Empty = default(ZTPoint);
        public static ZTPoint Empty = new ZTPoint(0,0);
        public ZTPoint()
        {
        }
        public ZTPoint(Int32 x, Int32 y)
        {
            this.X = x;
@@ -23,27 +27,7 @@
        public Int32 X { get; set; }
        public Int32 Y { get; set; }
        public static bool operator ==(ZTPoint a, ZTPoint b)
        {
            if (a.X == b.X && a.Y == b.Y)
            {
                return true;
            }
            return false;
        }
        public static bool operator !=(ZTPoint a, ZTPoint b)
        {
            if (a.X != b.X || a.Y != b.Y)
            {
                return true;
            }
            return false;
        }
        public static ZTPoint operator +(ZTPoint a, ZTPoint b)
        {
            return new ZTPoint(a.X + b.X, a.Y + b.Y);
@@ -92,6 +76,10 @@
        #region IEquatable
        public bool Equals(ZTPoint other)
        {
            if (other == null)
            {
                return false;
            }
            if (this.X == other.X && this.Y == other.Y)
            {
                return true;
src/RichCreator.Utility/Structs/ZTPolygon.cs
@@ -10,30 +10,33 @@
    /// <summary>
    /// 多边形
    /// </summary>
    public class ZTPolygon : IEnumerable<ZTPoint>
    public class ZTPolygon
    {
        private ZTPoint[] points;
        public ZTPolygon()
        {
        }
        public ZTPolygon(ZTPoint[] points)
        {
            this.points = points;
            this.Points = points;
        }
        public ZTPoint[] Points
        {
            get { return points; }
            set { points = value; }
            get;set;
        }
        public int Length
        {
            get { return points.Length; }
            get { return Points.Length; }
        }
        public ZTPoint this[int index]
        {
            get { return points[index]; }
            set { points[index] = value; }
            get { return Points[index]; }
            set { Points[index] = value; }
        }
        public static bool operator !=(ZTPolygon a, ZTPolygon b)
@@ -53,7 +56,7 @@
            }
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                if (!a[i].Equals(b[i]))
                {
                    return false;
                }
@@ -63,7 +66,7 @@
        public static implicit operator ZTPoint[] (ZTPolygon polygon)
        {
            return polygon.points;
            return polygon.Points;
        }
        public static implicit operator ZTPolygon(ZTPoint[] points)
@@ -71,14 +74,6 @@
            return new ZTPolygon(points);
        }
        IEnumerator<ZTPoint> IEnumerable<ZTPoint>.GetEnumerator()
        {
            return (IEnumerator<ZTPoint>)points.GetEnumerator();
        }
        public IEnumerator GetEnumerator()
        {
            return points.GetEnumerator();
        }
    }
}
src/RichCreator.Utility/Structs/ZTRectangle.cs
@@ -60,7 +60,7 @@
        public static bool operator ==(ZTRectangle a, ZTRectangle b)
        {
            if (a.Start == b.Start && a.End == b.End)
            if (a.Start .Equals( b.Start) && a.End.Equals( b.End))
            {
                return true;
            }
@@ -69,7 +69,7 @@
        public static bool operator !=(ZTRectangle a, ZTRectangle b)
        {
            if (a.Start != b.Start || a.End != b.End)
            if (!a.Start.Equals( b.Start) || !a.End.Equals(b.End))
            {
                return true;
            }
@@ -85,7 +85,7 @@
        #region IEquatable
        public bool Equals(ZTRectangle other)
        {
            if (this.Start == other.Start && this.End == other.End)
            if (this.Start.Equals(other.Start) && this.End.Equals(other.End))
            {
                return true;
            }
src/RichCreator.Utility/Utilitys/GeometryHelper.cs
@@ -145,7 +145,7 @@
            ZTPoint p1;
            int n = polygon.Length;
            p1 = polygon[0];
            if (point == p1)
            if (point .Equals( p1))
            {
                return Intersection.Tangent;
            }
@@ -153,7 +153,7 @@
            for (i = 1; i <= n; i++)
            {
                ZTPoint p2 = polygon[i % n];
                if (point == p2)
                if (point .Equals( p2))
                {
                    return Intersection.Tangent;
                }
src/RichCreator.sln
@@ -7,7 +7,7 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{66124456-F406-43C9-848F-92C582AFC5ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RichCreator.Server", "RichCreator.Server\RichCreator.Server.csproj", "{9A1D6739-D740-4AB8-B760-6F819D14ABB3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RichCreator.Server", "RichCreator.Server\RichCreator.Server.csproj", "{9A1D6739-D740-4AB8-B760-6F819D14ABB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RichCreator.Editor", "RichCreator.Editor\RichCreator.Editor.csproj", "{7721B0B4-0574-4D16-A281-C55581F7B79B}"
EndProject
src/RichCreator/PathFinding/Dijkstra.cs
@@ -41,8 +41,8 @@
                return new List<ZTPoint>();
            }
            var s = nodes.Where(x => x.Name == start).ToList();
            var u = nodes.Where(x => x.Name != start).ToList();
            var s = nodes.Where(x => x.Name .Equals(start)).ToList();
            var u = nodes.Where(x => !x.Name.Equals( start)).ToList();
            s.ForEach(x =>
            {
@@ -103,11 +103,11 @@
        private Edge GetEdgeByTwoNode(Node start, Node end)
        {
            var edge = edges.FirstOrDefault(x => x.Start == start.Name && x.End == end.Name);
            var edge = edges.FirstOrDefault(x => x.Start .Equals( start.Name) && x.End .Equals( end.Name));
            if (edge == null)
            {
                edge = edges.FirstOrDefault(x => x.Start == end.Name && x.End == start.Name);
                edge = edges.FirstOrDefault(x => x.Start .Equals( end.Name) && x.End.Equals(start.Name));
            }
            return edge;
@@ -142,7 +142,7 @@
        /// <returns></returns>
        private Node GetNodeByName(ZTPoint nodeName)
        {
            return nodes.FirstOrDefault(x => x.Name == nodeName);
            return nodes.FirstOrDefault(x => x.Name .Equals(nodeName));
        }
        /// <summary>
@@ -152,7 +152,7 @@
        {
            edges.ForEach(edge =>
            {
                if (nodes.All(x => x.Name != edge.Start))
                if (nodes.All(x => !x.Name .Equals( edge.Start)))
                {
                    nodes.Add(new Node()
                    {
@@ -160,7 +160,7 @@
                    });
                }
                if (nodes.All(x => x.Name != edge.End))
                if (nodes.All(x => !x.Name .Equals( edge.End)))
                {
                    nodes.Add(new Node()
                    {
src/RichCreator/StateMachines/KillMonsterStateMachine.cs
@@ -226,7 +226,7 @@
                        this.stateRolePosition = DnfCVHelper.FindRole(hsvImage, this.GameRect);
                        if (this.stateRolePosition == ZTPoint.Empty)
                        if (this.stateRolePosition .Equals( ZTPoint.Empty))
                        {
                            SetState(KillMonsterStates.FindRoleMove, false);
                        }
@@ -334,7 +334,7 @@
        {
            //拾取物品,获取最近一个物品位置并步行过去
            ZTPoint thingItemPosition = GetNearlyThingItem(image, stateRolePosition);
            if (thingItemPosition != ZTPoint.Empty)
            if (!thingItemPosition .Equals( ZTPoint.Empty))
            {
                if (this.moveState.IsMoving && !this.moveState.IsPickupMoving)
                {
@@ -358,7 +358,7 @@
        {
            //查找真实的门
            this.stateDoorPosition = LindongCVHelper.FindDoor(out stateDoorLevelDirect, hsvImage, this.house.DoorDirection, this.GameRect);
            if (this.stateDoorPosition != ZTPoint.Empty)
            if (!this.stateDoorPosition .Equals(ZTPoint.Empty))
            {
                //找到门,向门移动  
                if (this.moveState.IsFindDoorMoving)
@@ -547,7 +547,7 @@
        {
            SkillInfo attackSkill = this.house.Skills.SyncPeek();
            //没有移动,可能有障碍物
            if (stateRolePosition == this.roleLastPosition)
            if (stateRolePosition .Equals( this.roleLastPosition))
            {
                if (FindRoleLastNoMoveStart && (DateTime.Now - FindRoleLastNoMoveTime).TotalMilliseconds > NoMoveMaxMillSecond)
                {
src/RichCreator/StateMachines/MoveState.cs
@@ -379,7 +379,7 @@
            ZTRectangle limitRect = ZTRectangle.Empty;
            
            //达到未移动阀值,可能有障碍物,先攻击,如果攻击后还是无效则上下左右移
            if (rolePosition == this.roleLastPosition)
            if (rolePosition .Equals( this.roleLastPosition))
            {
                if (StaticTimerIsStart)
                {
src/test/Program.cs
@@ -11,7 +11,13 @@
{
    public struct person
    {
        public int age { get; set; }
        public string name { get; set; }
    }
    class Program
@@ -26,9 +32,14 @@
        static void Main(string[] args)
        {
            person p = new person();
            p.age = 12;
            p.name = "xylee";
            Console.WriteLine(ZTImage.Json.JsonBuilder.ToJsonString(p));