Пример #1
0
 public Tile(Texture2D texture, Rectangle rectangle, Tiled.LayerId layerId, bool isActive = true, string tag = "")
 {
     this.texture   = texture;
     this.rigidbody = new Rigidbody(
         rectangle: rectangle
         );
     this.tag      = tag;
     this.isActive = isActive;
     this.layerID  = layerId;
 }
Пример #2
0
        private List <ITile> GetTiles(Dictionary <int, Texture2D> textures, int[,] map, Tiled.LayerId layerId, Point mapTopLeftCorner)
        {
            List <ITile> tiles = new List <ITile>();

            for (int row = 0; row < map.GetLength(0); row++)
            {
                for (int element = 0; element < map.GetLength(1); element++)
                {
                    if (textures[map[row, element]] != null)
                    {
                        int AssetSize_x_ScaleFactor = ChristianGame.Default.AssetSize * ChristianGame.Default.ScaleFactor;

                        Tile tile = new Tile(
                            texture: textures[map[row, element]],
                            rectangle: new Rectangle(
                                x: (element * textures[map[row, element]].Width) + (mapTopLeftCorner.X * AssetSize_x_ScaleFactor),
                                y: (row * textures[map[row, element]].Height) + (mapTopLeftCorner.Y * AssetSize_x_ScaleFactor),
                                width: textures[map[row, element]].Width,
                                height: textures[map[row, element]].Height
                                ),
                            layerId: layerId,
                            tag: ""
                            );

                        tiles.Add(tile);
                    }
                }
            }

            return(tiles);
        }