本文整理汇总了C#中TileSet类的典型用法代码示例。如果您正苦于以下问题:C# TileSet类的具体用法?C# TileSet怎么用?C# TileSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TileSet类属于命名空间,在下文中一共展示了TileSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TileScene
public TileScene(TileSet tileSet, Point[,] mapIndices, int depth = 0)
{
this.tileSet = tileSet;
this.mapIndices = mapIndices;
this.depth = depth;
sprites = null;
}
开发者ID:kallisti-dev,项目名称:GameEngineConcept,代码行数:7,代码来源:TileScene.cs
示例2: Theater
public Theater(TileSet tileset)
{
var allocated = false;
Func<Sheet> allocate = () =>
{
if (allocated)
throw new SheetOverflowException("Terrain sheet overflow. Try increasing the tileset SheetSize parameter.");
allocated = true;
return new Sheet(new Size(tileset.SheetSize, tileset.SheetSize), true);
};
sheetBuilder = new SheetBuilder(SheetType.Indexed, allocate);
templates = new Dictionary<ushort, Sprite[]>();
var frameCache = new FrameCache(Game.modData.SpriteLoaders, tileset.Extensions);
foreach (var t in tileset.Templates)
{
var allFrames = frameCache[t.Value.Image];
var frames = t.Value.Frames != null ? t.Value.Frames.Select(f => allFrames[f]).ToArray() : allFrames;
templates.Add(t.Value.Id, frames.Select(f => sheetBuilder.Add(f)).ToArray());
}
// 1x1px transparent tile
missingTile = sheetBuilder.Add(new byte[1], new Size(1, 1));
Sheet.ReleaseBuffer();
}
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:28,代码来源:Theater.cs
示例3: GetSpriteSrc
protected override string GetSpriteSrc(ModData modData, TileSet tileSet, string sequence, string animation, string sprite, Dictionary<string, MiniYaml> d)
{
var loader = (TilesetSpecificSpriteSequenceLoader)Loader;
var spriteName = sprite ?? sequence;
if (LoadField<bool>(d, "UseTilesetCode", false))
{
string code;
if (loader.TilesetCodes.TryGetValue(ResolveTilesetId(tileSet, d), out code))
spriteName = spriteName.Substring(0, 1) + code + spriteName.Substring(2, spriteName.Length - 2);
}
if (LoadField<bool>(d, "AddExtension", true))
{
var useTilesetExtension = LoadField<bool>(d, "UseTilesetExtension", false);
string tilesetExtension;
if (useTilesetExtension && loader.TilesetExtensions.TryGetValue(ResolveTilesetId(tileSet, d), out tilesetExtension))
return spriteName + tilesetExtension;
return spriteName + loader.DefaultSpriteExtension;
}
return spriteName;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:26,代码来源:TilesetSpecificSpriteSequence.cs
示例4: Layer
public Layer(TileSet tileset, string data, int currentLayerID, int width, int height)
{
this._tileset = tileset;
this._data = data.Split (',');
this._currentLayerID = currentLayerID;
this._width = width;
this._height = height;
}
开发者ID:kjellski,项目名称:TiledMapLoader,代码行数:8,代码来源:Layer.cs
示例5: TerrainTemplatePreviewWidget
protected TerrainTemplatePreviewWidget(TerrainTemplatePreviewWidget other)
: base(other)
{
worldRenderer = other.worldRenderer;
tileset = other.worldRenderer.World.Map.Rules.TileSet;
Template = other.Template;
GetScale = other.GetScale;
}
开发者ID:pchote,项目名称:OpenRA,代码行数:8,代码来源:TerrainTemplatePreviewWidget.cs
示例6: TerrainBitmap
public static Bitmap TerrainBitmap(TileSet tileset, Map map, bool actualSize = false)
{
var isDiamond = map.TileShape == TileShape.Diamond;
var b = map.Bounds;
// Fudge the heightmap offset by adding as much extra as we need / can.
// This tries to correct for our incorrect assumption that MPos == PPos
var heightOffset = Math.Min(map.MaximumTerrainHeight, map.MapSize.Y - b.Bottom);
var width = b.Width;
var height = b.Height + heightOffset;
var bitmapWidth = width;
if (isDiamond)
bitmapWidth = 2 * bitmapWidth - 1;
if (!actualSize)
bitmapWidth = height = Exts.NextPowerOf2(Math.Max(bitmapWidth, height));
var terrain = new Bitmap(bitmapWidth, height);
var bitmapData = terrain.LockBits(terrain.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
var mapTiles = map.MapTiles.Value;
unsafe
{
var colors = (int*)bitmapData.Scan0;
var stride = bitmapData.Stride / 4;
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var uv = new MPos(x + b.Left, y + b.Top);
var type = tileset.GetTileInfo(mapTiles[uv]);
var leftColor = type != null ? type.LeftColor : Color.Black;
if (isDiamond)
{
// Odd rows are shifted right by 1px
var dx = uv.V & 1;
var rightColor = type != null ? type.RightColor : Color.Black;
if (x + dx > 0)
colors[y * stride + 2 * x + dx - 1] = leftColor.ToArgb();
if (2 * x + dx < stride)
colors[y * stride + 2 * x + dx] = rightColor.ToArgb();
}
else
colors[y * stride + x] = leftColor.ToArgb();
}
}
}
terrain.UnlockBits(bitmapData);
return terrain;
}
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:57,代码来源:Minimap.cs
示例7: TileSetRenderer
public TileSetRenderer(TileSet tileset, Size tileSize)
{
this.TileSet = tileset;
this.TileSize = Math.Min(tileSize.Width, tileSize.Height);
templates = new Dictionary<ushort, List<byte[]>>();
var sourceCache = new Dictionary<string, ISpriteSource>();
foreach (var t in TileSet.Templates)
templates.Add(t.Key, LoadTemplate(t.Value.Image, tileset.Extensions, sourceCache, t.Value.Frames));
}
开发者ID:RunCraze,项目名称:OpenRA,代码行数:10,代码来源:TileSetRenderer.cs
示例8: Theater
public Theater(TileSet tileset)
{
this.tileset = tileset;
var allocated = false;
var type = tileset.EnableDepth ? SheetType.DualIndexed : SheetType.Indexed;
Func<Sheet> allocate = () =>
{
if (allocated)
throw new SheetOverflowException("Terrain sheet overflow. Try increasing the tileset SheetSize parameter.");
allocated = true;
return new Sheet(type, new Size(tileset.SheetSize, tileset.SheetSize));
};
sheetBuilder = new SheetBuilder(type, allocate);
random = new MersenneTwister();
var frameCache = new FrameCache(Game.ModData.SpriteLoaders);
foreach (var t in tileset.Templates)
{
var variants = new List<Sprite[]>();
foreach (var i in t.Value.Images)
{
var allFrames = frameCache[i];
var frameCount = tileset.EnableDepth ? allFrames.Length / 2 : allFrames.Length;
var indices = t.Value.Frames != null ? t.Value.Frames : Enumerable.Range(0, frameCount);
variants.Add(indices.Select(j =>
{
var f = allFrames[j];
var s = sheetBuilder.Allocate(f.Size, f.Offset);
Util.FastCopyIntoChannel(s, 0, f.Data);
if (tileset.EnableDepth)
Util.FastCopyIntoChannel(s, 1, allFrames[j + frameCount].Data);
return s;
}).ToArray());
}
var allSprites = variants.SelectMany(s => s);
// Ignore the offsets baked into R8 sprites
if (tileset.IgnoreTileSpriteOffsets)
allSprites = allSprites.Select(s => new Sprite(s.Sheet, s.Bounds, float2.Zero, s.Channel, s.BlendMode));
templates.Add(t.Value.Id, new TheaterTemplate(allSprites.ToArray(), variants.First().Count(), t.Value.Images.Length));
}
// 1x1px transparent tile
missingTile = sheetBuilder.Add(new byte[1], new Size(1, 1));
Sheet.ReleaseBuffer();
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:55,代码来源:Theater.cs
示例9: AddStaticResources
// Add the static resources defined in the map; if the map lives
// in a world use AddCustomTerrain instead
static Bitmap AddStaticResources(TileSet tileset, Map map, Ruleset resourceRules, Bitmap terrainBitmap)
{
var terrain = new Bitmap(terrainBitmap);
var isRectangularIsometric = map.Grid.Type == MapGridType.RectangularIsometric;
var b = map.Bounds;
// Fudge the heightmap offset by adding as much extra as we need / can
// This tries to correct for our incorrect assumption that MPos == PPos
var heightOffset = Math.Min(map.Grid.MaximumTerrainHeight, map.MapSize.Y - b.Bottom);
var width = b.Width;
var height = b.Height + heightOffset;
var resources = resourceRules.Actors["world"].TraitInfos<ResourceTypeInfo>()
.ToDictionary(r => r.ResourceType, r => r.TerrainType);
var bitmapData = terrain.LockBits(terrain.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
unsafe
{
var colors = (int*)bitmapData.Scan0;
var stride = bitmapData.Stride / 4;
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var uv = new MPos(x + b.Left, y + b.Top);
if (map.MapResources.Value[uv].Type == 0)
continue;
string res;
if (!resources.TryGetValue(map.MapResources.Value[uv].Type, out res))
continue;
var color = tileset[tileset.GetTerrainIndex(res)].Color.ToArgb();
if (isRectangularIsometric)
{
// Odd rows are shifted right by 1px
var dx = uv.V & 1;
if (x + dx > 0)
colors[y * stride + 2 * x + dx - 1] = color;
if (2 * x + dx < stride)
colors[y * stride + 2 * x + dx] = color;
}
else
colors[y * stride + x] = color;
}
}
}
terrain.UnlockBits(bitmapData);
return terrain;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:57,代码来源:Minimap.cs
示例10: Refresh
public void Refresh()
{
TileSet tileset = Linker.Tilesets[0];
if (Architect.MapLoaded && selectedTileset != tileset)
{
clearTilesetButtons();
selectedTileset = tileset;
showTileset();
selectTile(0);
}
}
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:11,代码来源:TilesetItemsPanel.cs
示例11: init
public void init(string mapName, int mapWidth, int mapHeight, int chunkSize, int tileSize, TileSet tileSet, IEnumerable<Tile> tileList, Sprite background)
{
this.mapName = mapName;
this.mapWidth = mapWidth;
this.mapHeight = mapHeight;
this.chunkSize = chunkSize;
this.tileSize = tileSize;
this.tileSet = tileSet;
this.tiles = tileList.ToArray();
this.backgroundImage = background;
}
开发者ID:rkdrnf,项目名称:fortresswar,代码行数:11,代码来源:MapData.cs
示例12: RenderGrid
public static Bitmap RenderGrid(TileSet tileSet, Palette palette, TileGrid tileGrid, bool transparent)
{
Bitmap bitmap = new Bitmap(tileGrid.Width * tileGrid.TileWidth, tileGrid.Height * tileGrid.TileHeight,
PixelFormat.Format32bppArgb);
BitmapData canvas = bitmap.LockBits();
RenderGrid(canvas, 0, 0, tileSet, palette, tileGrid, transparent);
bitmap.UnlockBits(canvas);
return bitmap;
}
开发者ID:ChrisBlueStone,项目名称:RopeSnake,代码行数:11,代码来源:Renderer.cs
示例13: Bind
public void Bind(Map m, TileSet ts, TileSetRenderer tsr, IPalette p, IPalette pp)
{
Map = m;
TileSet = ts;
TileSetRenderer = tsr;
Palette = p;
PlayerPalette = pp;
playerPalettes = null;
Chunks.Clear();
currentTool = null;
}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:11,代码来源:Surface.cs
示例14: TileLayer
public TileLayer(string _layerName, string _layerData, int _layerWidth, int _layerHeight, TileSet _myTileSet, int _currentLayer, GameObject _root)
{
layerName = _layerName.Trim();
layerData = _layerData.Split(',');
layerWidth = _layerWidth;
layerHeight = _layerHeight;
layerTileSet = _myTileSet;
currentLayer = _currentLayer;
myTextureLocation = _myTileSet.ImageSource.TrimStart('.');
rootObject = _root;
}
开发者ID:Inphinitii,项目名称:ArenaShooter-Physics-Final,代码行数:11,代码来源:TileLayer.cs
示例15: DecorationSetForm
/// <summary>
/// Constructor
/// </summary>
/// <param name="node">XmlNode handle</param>
public DecorationSetForm(XmlNode node)
{
InitializeComponent();
LastMousePosition = Control.MousePosition;
BgTileSet = new TileSet();
DecorationSet = new DecorationSet();
DecorationSet.Load(node);
ChangeDecorationId(0);
}
开发者ID:melkor54248,项目名称:dungeoneye,代码行数:16,代码来源:DecorationSetForm.cs
示例16: Creature
public Creature(TileSet animationTile)
{
animations = new Dictionary<Direction, Animation>(4);
facing = Direction.Down;
animations.Add(Direction.Up, new Animation(animationTile, 500, 2,6,10));
animations.Add(Direction.Down, new Animation(animationTile, 500, 0, 4, 8));
animations.Add(Direction.Left, new Animation(animationTile, 500, 1, 5, 9));
animations.Add(Direction.Right, new Animation(animationTile, 500, 3, 7, 11));
Abilities = new Collection<Ability>();
}
开发者ID:Gadamagaska,项目名称:Quantum-Man-C-,代码行数:12,代码来源:Creature.cs
示例17: CreatePlatform
public void CreatePlatform(int width, Vector3 position, TileSet tileSet)
{
this.width = width;
transform.position = position;
this.tileSet = tileSet;
actualWidth = width*tileSet.tileWidth;
boxCollider.size = new Vector2(actualWidth,tileSet.tileHeight);
boxCollider.sharedMaterial = tileSet.physicsMaterial;
SetSprites();
if(tileSet.HasPlatformDecorations)
Decorate();
}
开发者ID:EternalGB,项目名称:frogue,代码行数:12,代码来源:PoolablePlatform.cs
示例18: CtrlTileEditControl
/// <summary>
/// Initializes an new instance of TileEditControl with a given TileSet
/// </summary>
/// <param name="target">Tileset given via parameter</param>
public CtrlTileEditControl(TileSet target)
{
this.RunStartUpMethods();
// open directly with given Tileset
// reset all the controls
this.UncheckButtons();
// fill tilegrid with tileset
this.GridView.Fill(this.TargetTile);
// check type-button and set info text
this.CheckTypeButton(this.TargetTile.GetID);
}
开发者ID:baLR0n,项目名称:TileMaker,代码行数:18,代码来源:CtrlTileEditControl.cs
示例19: Bind
public void Bind(Map m, TileSet ts, TileSetRenderer tsr, IPalette p, IPalette pp)
{
Map = m;
if (m != null)
Actors = m.ActorDefinitions.ToDictionary(n => n.Key, n => new ActorReference(n.Value.Value, n.Value.ToDictionary()));
TileSet = ts;
TileSetRenderer = tsr;
Palette = p;
PlayerPalette = pp;
playerPalettes = null;
Chunks.Clear();
currentTool = null;
}
开发者ID:ushardul,项目名称:OpenRA,代码行数:14,代码来源:Surface.cs
示例20: ResolveTilesetId
string ResolveTilesetId(TileSet tileSet, Dictionary<string, MiniYaml> d)
{
var tsId = tileSet.Id;
MiniYaml yaml;
if (d.TryGetValue("TilesetOverrides", out yaml))
{
var tsNode = yaml.Nodes.FirstOrDefault(n => n.Key == tsId);
if (tsNode != null)
tsId = tsNode.Value.Value;
}
return tsId;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:14,代码来源:TilesetSpecificSpriteSequence.cs
注:本文中的TileSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论