Exemplo n.º 1
0
        /// <summary>
        /// 起点から指定した方向に一つ進んだ座標を返します。
        /// </summary>
        private static Point getNextDirectionPosition(Point startPos, Map.Direction4 dir)
        {
            var nextTile = startPos;

            switch (dir)
            {
            case Map.Direction4.East:
                nextTile = new Point(nextTile.X + 1, nextTile.Y);
                break;

            case Map.Direction4.South:
                nextTile = new Point(nextTile.X, nextTile.Y + 1);
                break;

            case Map.Direction4.West:
                nextTile = new Point(nextTile.X - 1, nextTile.Y);
                break;

            case Map.Direction4.North:
                nextTile = new Point(nextTile.X, nextTile.Y - 1);
                break;
            }

            return(nextTile);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 4方向をツクール2000/2003の方向順序に変換します。
        /// </summary>
        /// <param name="newDir4">現在の規格の4方向</param>
        /// <returns>旧規格の4方向</returns>
        private OldTkoolDirection4 ConvertToOldDirection(Map.Direction4 newDir4)
        {
            switch (newDir4)
            {
            case Map.Direction4.East:
                return(OldTkoolDirection4.East);

            case Map.Direction4.West:
                return(OldTkoolDirection4.West);

            case Map.Direction4.South:
                return(OldTkoolDirection4.South);

            case Map.Direction4.North:
                return(OldTkoolDirection4.North);
            }
            return(OldTkoolDirection4.None);
        }
Exemplo n.º 3
0
            /// <summary>
            /// 指定した進行方向で通路を削ります。
            /// </summary>
            /// <param name="link">対象とする通路</param>
            /// <param name="trimDirection">削っていく方向 (東向きの場合は左端が削られます)</param>
            public void TrimLink(LinkData link, Map.Direction4 trimDirection)
            {
                //始点・終点・固定軸を決定する
                var start = 0;
                var end   = 0;
                var pivot = 0;
                var step  = 0;

                switch (trimDirection)
                {
                case Map.Direction4.East:
                    start = link.Start.X;
                    end   = link.End.X;
                    pivot = link.Start.Y;
                    step  = 1;
                    break;

                case Map.Direction4.West:
                    start = link.End.X;
                    end   = link.Start.X;
                    pivot = link.Start.Y;
                    step  = -1;
                    break;

                case Map.Direction4.South:
                    start = link.Start.Y;
                    end   = link.End.Y;
                    pivot = link.Start.X;
                    step  = 1;
                    break;

                case Map.Direction4.North:
                    start = link.End.Y;
                    end   = link.Start.Y;
                    pivot = link.Start.X;
                    step  = -1;
                    break;
                }

                //逐次削っていく
                for (var p = start; (0 < step) ? (start <= p && p <= end) : (end <= p && p <= start); p += step)
                {
                    var cutFlag = true;

                    //次のタイル位置をセットする
                    var checkTilePos = Point.Empty;
                    switch (trimDirection)
                    {
                    case Map.Direction4.East:
                    case Map.Direction4.West:
                        checkTilePos = new Point(p, pivot);
                        break;

                    case Map.Direction4.South:
                    case Map.Direction4.North:
                        checkTilePos = new Point(pivot, p);
                        break;
                    }

                    //3方向チェック
                    for (var d = 0; d < DirectionCount; d++)
                    {
                        if (d == (int)trimDirection)
                        {
                            //進行方向はチェックしない
                            continue;
                        }

                        var checkTileNextPos = getNextDirectionPosition(checkTilePos, (Map.Direction4)d);
                        if (this.TileData[checkTileNextPos.X, checkTileNextPos.Y] == GeneratedMapTile.Floor)
                        {
                            cutFlag = false;
                            break;
                        }
                    }

                    if (cutFlag)
                    {
                        //現在のタイルを削る
                        this.TileData[checkTilePos.X, checkTilePos.Y] = GeneratedMapTile.Ceil;
                    }
                }
            }