Exemplo n.º 1
0
        public void LinkNode(PathNode snode, PathNode dnode, PathType dir)
        {
            PathDir d = new PathDir(dir);

            snode[d.Forward] = dnode;
            dnode[d.Back]    = snode;
        }
Exemplo n.º 2
0
        void updateCar(CarInfo info, Pen drawpen = null)
        {
            int angle = 0;
            int ax = 0, ay = 0;
            int w = (int)(info.lastLenght * Scale * info.pross / 100);

            if (drawpen == null)
            {
                drawpen = OtherPathPen;
            }
            PathDir pdir = new PathDir();

            if (info.lastNodeID >= allPath.Count || info.nowNodeID >= allPath.Count)
            {
                return;
            }
            PathNode node = allPath[info.lastNodeID];

            pdir.Rotate(node[allPath[info.nowNodeID]]);
            switch (pdir.Forward)
            {
            case PathType.Forward:
                ax    = 0;
                ay    = -w;
                angle = 0;
                break;

            case PathType.Left:
                ax    = -w;
                ay    = 0;
                angle = -90;
                break;

            case PathType.Right:
                ax    = w;
                ay    = 0;
                angle = 90;
                break;

            case PathType.Back:
                ax    = 0;
                ay    = w;
                angle = 180;
                break;
            }
            drawCar(node.x + ax, node.y + ay, angle, (info == SelectCar?CarBrush:OtherCarBrush));
        }
Exemplo n.º 3
0
        public bool setTargetPoint(PathNode node, PathNode lastnode = null)
        {
            if (node == null)
            {
                return(false);
            }
            if (lastnode == null)
            {
                lastnode = lastNode;
            }
            TargetDirList.Clear();
            if (lastNode == null)
            {
                return(false);
            }
            if (node.isNew || !node.isDead)
            {
                return(false);
            }
            if (lastNode == node)
            {
                return(false);
            }
            TargetPath = lastnode.gotoNode(node);
            if (TargetPath == null)
            {
                return(false);
            }
            PathDir  dir = LastPathDir;
            PathNode nt  = null;

            foreach (PathNode n in TargetPath)
            {
                PathType type;
                if (nt == null)
                {
                    nt = n;
                    continue;
                }
                type = dir.getDir(nt[n]);
                dir.Rotate(type);
                TargetDirList.Add(type);
                nt = n;
            }
            return(true);
        }
Exemplo n.º 4
0
        public bool MoveToPoint(PathNode node)
        {
            if (node.isNew || !node.isDead)
            {
                return(false);
            }
            PathDir dir = new PathDir();

            for (int i = 0; i < node.paths.Length; i++)
            {
                if (node.paths[i] != null)
                {
                    dir.Rotate((PathType)i);
                    break;
                }
            }
            dir.Rotate(PathType.Back);
            LastPathDir = dir;
            lastNode    = node;
            return(true);
        }