Esempio n. 1
0
        public bool AddSingleItem(RoadNode node)
        {
            bool returnState = false;

            if (!CheckHasNode(node.X, node.Y))
            {
                InsertNode(node.IsRed);
                returnState = true;
            }

            return(returnState);
        }
Esempio n. 2
0
        /// <summary>
        /// 插入节点数据
        /// </summary>
        /// <param name="bRed"></param>
        /// <param name="nDrawCount"></param>
        /// <returns></returns>
        protected virtual bool InsertNode(bool bRed, int nDrawCount = 0)
        {
            if (First)
            {
                CurrentRed = bRed;
                First      = false;
            }
            else
            {
                //是否需要另起一列
                if (bRed != CurrentRed)
                {
                    CurrentRed = bRed;
                    CurrentY   = 1;
                    StartX++;
                    CurrentX = StartX;
                    LineCount.Add(0);
                    while (CheckHasNode(CurrentX, CurrentY))
                    {
                        StartX++;
                        CurrentX = StartX;
                        LineCount.Add(0);
                    }
                }
                else
                {
                    if (CheckHasNode(CurrentX, CurrentY + 1) || CurrentY + 1 > RolMaxHeight)
                    {
                        CurrentX++;
                    }
                    else
                    {
                        CurrentY++;
                    }
                }
            }
            RoadNode newNode = new RoadNode(CurrentX, CurrentY, CurrentRed, nDrawCount);

            Nodes.Add(newNode);
            NodeDic.Add(new Vector2(CurrentX, CurrentY), newNode);
            LineCount[StartX - 1]++;
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加单独数据(三小路)
        /// </summary>
        /// <param name="it"></param>
        /// <param name="bigRoad"></param>
        /// <returns></returns>
        public bool AddSingleItem(RoadNode it, RoadNodeTable bigRoad)
        {
            bool returnState = false;

            //满足此两项条件 方可产生节点
            if (it.X > Nstep || (it.X == Nstep && it.Y > 1))
            {
                //看整齐
                if (it.Y == 1)
                {
                    returnState = InsertNode(bigRoad.GetRolCount(it.X - 2) == bigRoad.GetRolCount(it.X + 1 - Nstep));
                }
                else
                {
                    //看有无
                    int nTempX = it.X + 1 - Nstep;
                    returnState = bigRoad.CheckHasNode(nTempX, it.Y) ? InsertNode(true) : InsertNode(!bigRoad.CheckHasNode(nTempX, it.Y - 1));
                }
            }
            return(returnState);
        }