Beispiel #1
0
        public virtual void Redraw(DungeonNode node, PrintInfo pi)
        {
            if (node.Tiles == null)
            {
                return;
            }
            if (pi == null)
            {
                pi = new PrintInfo();
            }

            drawingEngine.SetCursorPosition(left, top);
            for (int row = 0; row < node.Height; row++)
            {
                drawingEngine.SetCursorPosition(left, top + row);
                for (int col = 0; col < node.Width; col++)
                {
                    var tile = node.GetTile(new Point(col, row));
                    if (tile != null && tile.Symbol == '@')
                    {
                        int kk = 0;
                        kk++;
                    }
                    Print(tile, pi);
                }
            }
        }
Beispiel #2
0
        public virtual void RefreshPosition(DungeonNode Node, PrintInfo pi, int x, int y)
        {
            if (pi == null)
            {
                pi = new PrintInfo();
            }
            drawingEngine.SetCursorPosition(left + x, top + y);
            var tile = Node.GetTile(new Point(x, y));

            Print(tile, pi);
        }
Beispiel #3
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="childMaze"></param>
            /// <param name="destStartPoint"></param>
            /// <param name="childMazeMaxSize"></param>
            /// <param name="childIsland"></param>
            /// <param name="entranceSideToSkip"></param>
            public virtual void AppendMaze
            (
                DungeonNode childMaze,
                Point?destStartPoint            = null,
                Point?childMazeMaxSize          = null,
                bool childIsland                = false,
                EntranceSide?entranceSideToSkip = null,
                DungeonNode prevNode            = null
            )
            {
                childMaze.AppendedSide = entranceSideToSkip;
                Parts.Add(childMaze);

                var start = destStartPoint ?? GetInteriorStartingPoint(4, childMaze);

                if (start.X < 0 || start.Y < 0)
                {
                    throw new Exception("AppendMaze start.X < 0 || start.Y < 0");
                }

                if (childMazeMaxSize == null)
                {
                    childMazeMaxSize = new Point(childMaze.Width, childMaze.Height);
                }

                childMaze.AppendMazeStartPoint = start;
                if (childIsland)
                {
                    childMaze.NodeIndex = NextChildIslandId--;
                    childMaze.SetTilesNodeIndex();
                }
                for (int row = 0; row < childMazeMaxSize.Value.Y; row++)
                {
                    for (int col = 0; col < childMazeMaxSize.Value.X; col++)
                    {
                        var tileInChildMaze = childMaze.GetTile(new Point(col, row));
                        if (tileInChildMaze == null)
                        {
                            continue;
                        }
                        if (entranceSideToSkip != null)
                        {
                            var childMazeWall = tileInChildMaze as Wall;
                            if (childMaze.Sides[entranceSideToSkip.Value].Contains(childMazeWall))
                            {
                                //if (prevNode == null || !prevNode.Secret)
                                {
                                    var indexOfWall = childMaze.Sides[entranceSideToSkip.Value].IndexOf(childMazeWall);
                                    if (prevNode == null ||
                                        (entranceSideToSkip == EntranceSide.Left && indexOfWall < prevNode.Height - 1) ||
                                        (entranceSideToSkip == EntranceSide.Top && indexOfWall < prevNode.Width)
                                        )
                                    {
                                        continue;
                                    }
                                }
                            }
                        }
                        SetCorner(childMazeMaxSize, row, col, tileInChildMaze);
                        int destCol = col + start.X;
                        int destRow = row + start.Y;
                        tileInChildMaze.point = new Point(destCol, destRow);

                        if (childIsland)
                        {
                            tileInChildMaze.DungeonNodeIndex = childMaze.NodeIndex;
                        }

                        //var at = this.GetTile(new Point(destCol, destRow));
                        //if (at.name == "Bat")
                        //{

                        //}
                        var destPt     = new Point(destCol, destRow);
                        var prevSecret = prevNode != null && prevNode.Secret && prevNode.NodeIndex == 0;
                        if (prevSecret && this.GetTile(destPt) is IDoor)
                        {
                            continue;
                        }
                        var set = this.SetTile(tileInChildMaze, destPt, autoSetTileDungeonIndex: false, reportError: false);
                        if (set)
                        {
                            if (prevSecret)
                            {
                                tileInChildMaze.DungeonNodeIndex = childMaze.NodeIndex;
                            }
                        }
                        else
                        {
                            var emp = this.GetClosestEmpty(tileInChildMaze);
                            if (emp != null)
                            {
                                set = this.SetTile(tileInChildMaze, emp.point, autoSetTileDungeonIndex: false);
                            }
                            if (!set)
                            {
                                var err      = "SetTile failed " + tileInChildMaze + " emp:" + (emp != null);
                                var tileAtPt = this.GetTile(destPt);
                                this.Log(err + " tileAtPt: " + tileAtPt, true);
                            }
                        }
                    }
                }
            }