Esempio n. 1
0
        public MObject(Map.Layer layer, Coord position, bool isWalkable = false, bool isTransparent = true)
        {
            ID = _idGen.UseID();

            Layer           = layer;
            Position        = position;
            IsWalkable      = isWalkable;
            IsTransparent   = isTransparent;
            backgroundColor = Microsoft.Xna.Framework.Color.White;
            glyph           = 'x';

            Moved = null;
        }
Esempio n. 2
0
 public TileBuffer(Map.Layer layer, Point tilePos, MapOneData.TileData before)
 {
     this.Layer        = layer;
     this.TilePosition = tilePos;
     this.Before       = before;
 }
Esempio n. 3
0
        /// <summary>
        /// 指定タイル座標とその八方のタイルのオートタイルを適用させます。
        /// </summary>
        public void ApplyAutoTile(Map.Layer layer, int tileX, int tileY, bool isParent = true)
        {
            if ((int)layer >= (int)Map.Layer.Shadow)
            {
                //オートタイルとは無縁なレイヤーは処理しない
                return;
            }

            var   l = (int)layer;
            int   vx, vy, px, py, tx, ty, bx, by, cx, cy;
            Point ny, ax, ay, ac;
            Point palPos;

            Map.QuarterTile part;
            tx = tileX;
            ty = tileY;

            //指定されたタイル座標についてセットする
            for (var y = 1; y <= 2; y++)
            {
                for (var x = 1; x <= 2; x++)
                {
                    //探索用
                    vx = (x % 2 == 1) ? -1 : 1;
                    vy = (y % 2 == 1) ? -1 : 1;
                    px = tx + (x == 0 ? -1 : (x == 3) ? 1 : 0);
                    py = ty + (y == 0 ? -1 : (y == 3) ? 1 : 0);

                    //周囲のデータ:比較用・範囲外の空間には比較基準と同じタイルがあるものとみなす
                    palPos = this.MapData.LayerTiles[l, px, py].PalletPosition;
                    ny     = palPos;                                                                                                                                                                                 //比較基準
                    ax     = (px + vx < 0 || this.MapData.MapSize.Width <= px + vx) ? palPos : this.MapData.LayerTiles[l, px + vx, py].PalletPosition;                                                               //横の比較用
                    ay     = (py + vy < 0 || this.MapData.MapSize.Height <= py + vy) ? palPos : this.MapData.LayerTiles[l, px, py + vy].PalletPosition;                                                              //縦の比較用
                    ac     = (px + vx < 0 || this.MapData.MapSize.Width <= px + vx || py + vy < 0 || this.MapData.MapSize.Height <= py + vy) ? palPos : this.MapData.LayerTiles[l, px + vx, py + vy].PalletPosition; //角(斜め)の比較用

                    //対象位置のパラメーター
                    bx = (x % 2 == 0) ? 1 : 0;
                    by = (y % 2 == 0) ? 1 : 0;
                    cx = ((x == 0) ? -1 : (x == 3) ? 1 : 0);
                    cy = ((y == 0) ? -1 : (y == 3) ? 1 : 0);

                    if (tx + cx < 0 || this.MapData.MapSize.Width <= tx + cx || ty + cy < 0 || this.MapData.MapSize.Height <= ty + cy)
                    {
                        //範囲外の部分は処理しない
                        continue;
                    }

                    palPos = this.MapData.LayerTiles[l, tx + cx, ty + cy].PalletPosition;
                    part   = (Map.QuarterTile)((x - 1) + (y - 1) * 2);

                    if (palPos.IsEmpty == false && palPos.Y < Map.AutoTileRowLength)
                    {
                        //オートタイルの場合のみ処理する
                        if (ny == ax && ny == ay && ny == ac)
                        {
                            //縦・横・角がすべて同一タイル
                            this.MapData.LayerTiles[l, tx + cx, ty + cy].SetQuarter(part, (int)Map.AutoTilePattern.AllSide);
                        }
                        else if (ny == ax && ny == ay)
                        {
                            //縦・横が同一タイル
                            this.MapData.LayerTiles[l, tx + cx, ty + cy].SetQuarter(part, (int)Map.AutoTilePattern.FourSide);
                        }
                        else if (ny == ay)
                        {
                            //縦が同一タイル
                            this.MapData.LayerTiles[l, tx + cx, ty + cy].SetQuarter(part, (int)Map.AutoTilePattern.Vertical);
                        }
                        else if (ny == ax)
                        {
                            //横が同一タイル
                            this.MapData.LayerTiles[l, tx + cx, ty + cy].SetQuarter(part, (int)Map.AutoTilePattern.Horizontal);
                        }
                        else
                        {
                            //四方八方が異なるタイル:独立型
                            this.MapData.LayerTiles[l, tx + cx, ty + cy].SetQuarter(part, (int)Map.AutoTilePattern.Isolate);
                        }
                    }
                    else
                    {
                        //オブジェクトタイルは常に独立型にする
                        this.MapData.LayerTiles[l, tx + cx, ty + cy].SetQuarter(part, (int)Map.AutoTilePattern.Isolate);
                    }
                }
            }

            //基点である場合、さらにその八方にあるタイルの接している部分を更新する
            if (isParent)
            {
                for (var x = -1; x <= +1; x++)
                {
                    for (var y = -1; y <= +1; y++)
                    {
                        if (x == 0 && y == 0)
                        {
                            //基点は処理しない
                            continue;
                        }
                        else if (tileX + x < 0 || tileY + y < 0 || this.MapData.MapSize.Width <= tileX + x || this.mapData.MapSize.Height <= tileY + y)
                        {
                            //範囲外は処理しない
                            continue;
                        }
                        this.ApplyAutoTile(layer, tileX + x, tileY + y, false);
                    }
                }
            }
        }
Esempio n. 4
0
 public Teleporter(Coord position, Map.Layer layer, int character, RLColor foreColor, Map destinationMap, Coord destinationPosition)
     : base(position, layer, character, foreColor, true, true)
 {
     DestinationMap      = destinationMap;
     DestinationPosition = destinationPosition;
 }