Exemple #1
0
    public void traverse(int height, int width, Directions dir, int numPath)
    {
        cleanVisited();

        Stack S = new Stack();
        Dictionary <string, Pos3> parents = new Dictionary <string, Pos3> ();

        S.Push(new Pos3(height, width, (int)dir));
        while (S.Count != 0)
        {
            Pos3 v = (Pos3)S.Pop();
            if (!maze[v.x, v.y].visited)
            {
                if (v.x == startingCell.x && v.y == startingCell.y)
                {
                    break;
                }
                maze[v.x, v.y].visited = true;
                if (maze[v.x, v.y].up && v.z != (int)Directions.Up)
                {
                    S.Push(new Pos3(v.x - 1, v.y, (int)Directions.Down));
                    parents[(v.x - 1) + ":" + v.y] = new Pos3(v.x, v.y, (int)Directions.Up);
                }
                if (maze[v.x, v.y].down && v.z != (int)Directions.Down)
                {
                    S.Push(new Pos3(v.x + 1, v.y, (int)Directions.Up));
                    parents[(v.x + 1) + ":" + v.y] = new Pos3(v.x, v.y, (int)Directions.Down);
                }
                if (maze[v.x, v.y].left && v.z != (int)Directions.Left)
                {
                    S.Push(new Pos3(v.x, v.y - 1, (int)Directions.Right));
                    parents[v.x + ":" + (v.y - 1)] = new Pos3(v.x, v.y, (int)Directions.Left);
                }
                if (maze[v.x, v.y].right && v.z != (int)Directions.Right)
                {
                    S.Push(new Pos3(v.x, v.y + 1, (int)Directions.Left));
                    parents[v.x + ":" + (v.y + 1)] = new Pos3(v.x, v.y, (int)Directions.Right);
                }
            }
        }

        Pos3 curr = new Pos3(startingCell.x, startingCell.y, 0);

        while (curr != null)
        {
            maze[curr.x, curr.y].road++;
            if (!parents.ContainsKey(curr.x + ":" + curr.y))
            {
                break;
            }
            curr = parents[curr.x + ":" + curr.y];
            maze[curr.x, curr.y].type = Cell.Types.Road;
            Debug.Log("D:" + maze[curr.x, curr.y].road + ":x:" + curr.x + ":y:" + curr.y);
            maze[curr.x, curr.y].dir[maze[curr.x, curr.y].road]   = (Directions)curr.z;
            maze[curr.x, curr.y].paths[maze[curr.x, curr.y].road] = numPath;
        }

        maze[height, width].type = Cell.Types.Respawn;
    }
 public ResultData()
 {
     joint1_pos   = new Pos3();
     joint2_pos   = new Pos3();
     joint3_pos   = new Pos3();
     joint4_pos   = new Pos3();
     joint5_pos   = new Pos3();
     target_pos   = new Pos3();
     image        = new byte[0];
     colliderArea = ColliderArea.NONE;
 }
Exemple #3
0
        /// <summary>
        /// パーツを指定してインスタンスを初期化する
        /// </summary>
        /// <param name="parts"></param>
        /// <param name="pane"></param>
        public void AddParts(PartsBase parts, IRichPane pane, CodePos offset)
        {
            _lastDevelpType = DevelopType.Unknown;

            var p = new Pos3
            {
                OrgPane = RichPaneBinder.CreateCopyComplete(pane),
                NowPane = pane,
                Org     = (CodeRect)parts.Rect.Clone(), // 符号化の座標(符号しない場合、単なるパーツ座標)
                                                        //p.Org = (uCdRect)parts.Rect.Clone() - parts.GetCdPos(pane, _prevShift); // 符号化の座標(符号しない場合、単なるパーツ座標)
                Pre    = (CodeRect)parts.Rect.Clone(),  // 符号化の座標(符号しない場合、単なるパーツ座標)
                Now    = (CodeRect)parts.Rect.Clone(),  // 符号化の座標(符号しない場合、単なるパーツ座標)
                Offset = (CodePos)offset.Clone()
            };

            base[parts] = p;
        }
Exemple #4
0
        /// <summary>
        /// インスタンスを初期化する
        /// </summary>
        /// <param name="with">基準位置とパーツの種類の元情報</param>
        /// <param name="pane">基準位置のスクロールとズーム値を記憶するためのインプット</param>
        public void Initialize(PartsCollectionBase with)
        {
            Clear();

            _lastDevelpType = DevelopType.Unknown;

            foreach (PartsCollectionBase.PartsEntry pe in with)
            {
                var p = new Pos3
                {
                    OrgPane = RichPaneBinder.CreateCopyComplete(pe.Pane),
                    NowPane = pe.Pane,
                    Org     = (CodeRect)pe.Parts.Rect.Clone(), // 符号化の座標(符号しない場合、単なるパーツ座標)
                    Pre     = (CodeRect)pe.Parts.Rect.Clone(), // 符号化の座標(符号しない場合、単なるパーツ座標)
                    Now     = (CodeRect)pe.Parts.Rect.Clone(), // 符号化の座標(符号しない場合、単なるパーツ座標)
                    Offset  = CodePos.FromInt(0, 0)
                };
                base[pe.Parts] = p;
            }
        }
Exemple #5
0
    public void generateMaze()
    {
        ArrayList walls = new ArrayList();

        reset();

        if (!startingSet)
        {
            startingCell = selectStartingCell(Height, Width);
        }
        maze [startingCell.x, startingCell.y].visited = true;
        maze [startingCell.x, startingCell.y].type    = Cell.Types.Center;

        walls = addWalls(startingCell.x, startingCell.y, walls);

        while (walls.Count != 0)
        {
            Pos3 wall = (Pos3)walls[Mathf.FloorToInt(Random.Range(0, walls.Count))];
            if ((wall.z == (int)Directions.Up && wall.x == 0) ||
                (wall.z == (int)Directions.Down && wall.x == Height - 1) ||
                (wall.z == (int)Directions.Left && wall.y == 0) ||
                (wall.z == (int)Directions.Right && wall.y == Width - 1) ||
                (wall.z == (int)Directions.Right && maze[wall.x, wall.y + 1].visited) ||
                (wall.z == (int)Directions.Left && maze[wall.x, wall.y - 1].visited) ||
                (wall.z == (int)Directions.Up && maze[wall.x - 1, wall.y].visited) ||
                (wall.z == (int)Directions.Down && maze[wall.x + 1, wall.y].visited))
            {
                walls.Remove(wall);
            }
            else
            {
                if (wall.z == (int)Directions.Right)
                {
                    maze[wall.x, wall.y + 1].visited = true;
                    maze[wall.x, wall.y + 1].left    = true;
                    maze[wall.x, wall.y].right       = true;
                    walls = addWalls(wall.x, wall.y + 1, walls);
                }
                else if (wall.z == (int)Directions.Left)
                {
                    maze[wall.x, wall.y - 1].visited = true;
                    maze[wall.x, wall.y - 1].right   = true;
                    maze[wall.x, wall.y].left        = true;
                    walls = addWalls(wall.x, wall.y - 1, walls);
                }
                else if (wall.z == (int)Directions.Up)
                {
                    maze[wall.x - 1, wall.y].visited = true;
                    maze[wall.x - 1, wall.y].down    = true;
                    maze[wall.x, wall.y].up          = true;
                    walls = addWalls(wall.x - 1, wall.y, walls);
                }
                else if (wall.z == (int)Directions.Down)
                {
                    maze[wall.x + 1, wall.y].visited = true;
                    maze[wall.x + 1, wall.y].up      = true;
                    maze[wall.x, wall.y].down        = true;
                    walls = addWalls(wall.x + 1, wall.y, walls);
                }
                walls.Remove(wall);
            }
        }
    }