Example #1
0
        /// <summary>
        /// 复制一个当前的对象
        /// </summary>
        public object Clone()
        {
            StoreHeap heap = new StoreHeap();

            heap.NodeList = NodeList;
            return(heap);
        }
Example #2
0
 public TSocketMessage(StoreHeap heap)
 {
     using (MMO_MemoryStream ms = new MMO_MemoryStream())
     {
         foreach (Node node in heap)
         {
             ms.WriteShort((short)node.Index);
             ms.WriteShort((short)node.X);
             ms.WriteShort((short)node.Y);
             ms.WriteShort((short)node.Direction);
         }
         MsgBuffer = ms.ToArray();
     }
 }
Example #3
0
        /// <summary>
        /// 当消息类型为Information时
        /// </summary>
        /// <param name="msg"></param>
        public void ReceiveInfo(TSocketMessage msg)
        {
            StoreHeap finalPath = new StoreHeap();

            using (MMO_MemoryStream ms = new MMO_MemoryStream(msg.MsgBuffer))
            {
                // 当未读取到字节流末尾时,将节点信息取出
                while (ms.Length != ms.Position)
                {
                    // 分别读取节点编号、节点X坐标、节点Y坐标、途径节点运动方向
                    Node node = new Node(ms.ReadShort(), ms.ReadShort(), ms.ReadShort(), ms.ReadShort());
                    finalPath.NodeList.Add(node);
                }
            }

            string result = "";

            result += finalPath.NodeList[0].Index.ToString() + "(直行)";

            for (int i = 1; i < finalPath.Count; i++)
            {
                string direction;
                if (finalPath.NodeList[i].Direction == 0)
                {
                    direction = "直行";
                }
                else if (finalPath.NodeList[i].Direction == 1)
                {
                    direction = "左转";
                }
                else if (finalPath.NodeList[i].Direction == 2)
                {
                    direction = "右转";
                }
                else
                {
                    direction = "停止";
                }
                result += " => " + finalPath.NodeList[i].Index.ToString() + $"({direction})";
            }

            MessageBox.Show(result);
        }