本文整理汇总了C#中TEditXNA.Terraria.Tile类的典型用法代码示例。如果您正苦于以下问题:C# Tile类的具体用法?C# Tile怎么用?C# Tile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tile类属于TEditXNA.Terraria命名空间,在下文中一共展示了Tile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SaveTiles
public static int SaveTiles(Tile[,] tiles, int maxX, int maxY, BinaryWriter bw)
{
for (int x = 0; x < maxX; x++)
{
OnProgressChanged(null, new ProgressChangedEventArgs(x.ProgressPercentage(maxX), "Saving Tiles..."));
for (int y = 0; y < maxY; y++)
{
Tile tile = tiles[x, y];
int dataIndex;
int headerIndex;
byte[] tileData = SerializeTileData(tile, out dataIndex, out headerIndex);
// rle compression
byte header1 = tileData[headerIndex];
short rle = 0;
int nextY = y + 1;
int remainingY = maxY - y - 1;
while (remainingY > 0 && tile.Equals(tiles[x, nextY]))
{
rle = (short)(rle + 1);
remainingY--;
nextY++;
}
y = y + rle;
if (rle > 0)
{
tileData[dataIndex++] = (byte)(rle & 255);
if (rle <= 255)
{
// set bit[6] of header1 for byte size rle
header1 = (byte)(header1 | 64);
}
else
{
// set bit[7] of header1 for int16 size rle
header1 = (byte)(header1 | 128);
// grab the upper half of the int16 and stick it in tiledata
tileData[dataIndex++] = (byte)((rle & 65280) >> 8);
}
}
tileData[headerIndex] = header1;
// end rle compression
bw.Write(tileData, headerIndex, dataIndex - headerIndex);
}
}
return (int)bw.BaseStream.Position;
}
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:60,代码来源:World.FileV2.cs
示例2: AppendTileFlagsFromByte
public static void AppendTileFlagsFromByte(ref Tile tile, byte flags)
{
if ((flags & (byte)TileFlags.IsActive) == (byte)TileFlags.IsActive)
tile.IsActive = true;
if ((flags & (byte)TileFlags.IsLava) == (byte)TileFlags.IsLava)
tile.IsLava = true;
if ((flags & (byte)TileFlags.HasWire) == (byte)TileFlags.HasWire)
tile.HasWire = true;
if ((flags & (byte)TileFlags.IsHoney) == (byte)TileFlags.IsHoney)
tile.IsHoney = true;
if ((flags & (byte)TileFlags.HasWire2) == (byte)TileFlags.HasWire2)
tile.HasWire2 = true;
if ((flags & (byte)TileFlags.HasWire3) == (byte)TileFlags.HasWire3)
tile.HasWire3 = true;
if ((flags & (byte)TileFlags.Actuator) == (byte)TileFlags.Actuator)
tile.Actuator = true;
if ((flags & (byte)TileFlags.InActive) == (byte)TileFlags.InActive)
tile.InActive = true;
}
开发者ID:Kaedenn,项目名称:Terraria-Map-Editor,代码行数:26,代码来源:ClipboardBuffer.File.cs
示例3: GetTileColor
public static Color GetTileColor(Tile tile, Color background, bool showWall = true, bool showTile = true, bool showLiquid = true, bool showWire = true)
{
var c = new Color(0, 0, 0, 0);
if (tile.Wall > 0 && showWall)
if (World.WallProperties.Count > tile.Wall)
c = c.AlphaBlend(World.WallProperties[tile.Wall].Color);
else
c = c.AlphaBlend(Color.Magenta); // Add out-of-range colors
else
c = background;
if (tile.IsActive && showTile)
{
if (World.TileProperties.Count > tile.Type)
c = c.AlphaBlend(World.TileProperties[tile.Type].Color);
else
c = c.AlphaBlend(Color.Magenta); // Add out-of-range colors
}
if (tile.Liquid > 0 && showLiquid)
c = c.AlphaBlend(tile.IsLava ? World.GlobalColors["Lava"] : World.GlobalColors["Water"]);
if (tile.HasWire && showWire)
c = c.AlphaBlend(World.GlobalColors["Wire"]);
return c;
}
开发者ID:nikitikitaki,项目名称:Terraria-Map-Editor,代码行数:28,代码来源:PixelMap.cs
示例4: CheckTileMatch
private bool CheckTileMatch(ref Tile originTile, ref Tile nextTile)
{
switch (_wvm.TilePicker.PaintMode)
{
case PaintMode.TileAndWall:
if ((originTile.Type != nextTile.Type || originTile.IsActive != nextTile.IsActive) && _wvm.TilePicker.TileStyleActive)
return false;
if (originTile.Wall != nextTile.Wall && _wvm.TilePicker.WallStyleActive)
return false;
if (originTile.BrickStyle != nextTile.BrickStyle && _wvm.TilePicker.BrickStyleActive)
return false;
if (_wvm.TilePicker.TilePaintActive && (originTile.Type != nextTile.Type || originTile.IsActive != nextTile.IsActive))
return false;
if (_wvm.TilePicker.WallPaintActive && (originTile.Wall != nextTile.Wall || (originTile.IsActive && World.TileProperties[originTile.Type].IsSolid) ||
(nextTile.IsActive && World.TileProperties[nextTile.Type].IsSolid)))
return false;
if (_wvm.TilePicker.ExtrasActive)
return false;
break;
case PaintMode.Wire:
return false;
case PaintMode.Liquid:
if ((originTile.LiquidAmount > 0 != nextTile.LiquidAmount > 0) ||
originTile.LiquidType != nextTile.LiquidType ||
(originTile.IsActive && World.TileProperties[originTile.Type].IsSolid) ||
(nextTile.IsActive && World.TileProperties[nextTile.Type].IsSolid))
return false;
break;
}
return true;
}
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:32,代码来源:FillTool.cs
示例5: GetTileColor
public static Color GetTileColor(Tile tile, Color background, bool showWall = true, bool showTile = true, bool showLiquid = true, bool showRedWire = true, bool showBlueWire = true, bool showGreenWire = true, bool showYellowWire = true)
{
var c = new Color(0, 0, 0, 0);
if (tile.Wall > 0 && showWall)
{
if (tile.WallColor > 0 && (!showTile || tile.TileColor == 0))
c = c.AlphaBlend(World.PaintProperties[tile.WallColor].Color);
else if (World.WallProperties.Count > tile.Wall)
{
if (World.WallProperties[tile.Wall].Color.A != 0)
c = c.AlphaBlend(World.WallProperties[tile.Wall].Color);
else
c = background;
}
else
c = c.AlphaBlend(Color.Magenta); // Add out-of-range colors
}
else
c = background;
if (tile.IsActive && showTile)
{
if (tile.TileColor > 0)
c = c.AlphaBlend(World.PaintProperties[tile.TileColor].Color);
else if (World.TileProperties.Count > tile.Type)
c = c.AlphaBlend(World.TileProperties[tile.Type].Color);
else
c = c.AlphaBlend(Color.Magenta); // Add out-of-range colors
}
if (tile.LiquidAmount > 0 && showLiquid)
{
if (tile.LiquidType == LiquidType.Lava) c = c.AlphaBlend(World.GlobalColors["Lava"]);
else if (tile.LiquidType == LiquidType.Honey) c = c.AlphaBlend(World.GlobalColors["Honey"]);
else c = c.AlphaBlend(World.GlobalColors["Water"]);
}
if (tile.WireRed && showRedWire)
{
c = c.AlphaBlend(World.GlobalColors["Wire"]);
}
if (tile.WireGreen && showGreenWire)
{
c = c.AlphaBlend(World.GlobalColors["Wire2"]);
}
if (tile.WireBlue && showBlueWire)
{
c = c.AlphaBlend(World.GlobalColors["Wire1"]);
}
if (tile.WireYellow && showYellowWire)
{
c = c.AlphaBlend(World.GlobalColors["Wire3"]);
}
return c;
}
开发者ID:TEdit,项目名称:Terraria-Map-Editor,代码行数:57,代码来源:PixelMap.cs
示例6: AppendTileFlagsFromByte
public static void AppendTileFlagsFromByte(ref Tile tile, byte flags)
{
if ((flags & (byte)TileFlags.IsActive) == (byte)TileFlags.IsActive)
tile.IsActive = true;
if ((flags & (byte)TileFlags.IsLava) == (byte)TileFlags.IsLava)
tile.IsLava = true;
if ((flags & (byte)TileFlags.HasWire) == (byte)TileFlags.HasWire)
tile.HasWire = true;
}
开发者ID:ThomasWDonnelly,项目名称:Terraria-Map-Editor,代码行数:11,代码来源:ClipboardBuffer.File.cs
示例7: Add
public void Add(Vector2Int32 location, Tile tile)
{
var undoTile = new UndoTile(location, tile);
if (undoTile == null)
{
throw new Exception("Null undo?");
}
lock (UndoSaveLock)
{
UndoTiles.Add(undoTile);
LastTile = undoTile;
}
if (UndoTiles.Count > FlushSize)
{
Flush();
}
}
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:19,代码来源:UndoBuffer.cs
示例8: FixChand
public void FixChand(int x, int y)
{
int newPosition = 0;
int type = Tiles[x, y].Type;
if (Tiles[x, y].IsActive)
{
if (type == 35)
{
newPosition = 1;
}
if (type == 36)
{
newPosition = 2;
}
if (type == 170)
{
newPosition = 3;
}
if (type == 171)
{
newPosition = 4;
}
if (type == 172)
{
newPosition = 5;
}
}
if (newPosition > 0)
{
int xShift = x;
int yShift = y;
xShift = Tiles[x, y].U/18;
while (xShift >= 3)
{
xShift = xShift - 3;
}
if (xShift >= 3)
{
xShift = xShift - 3;
}
xShift = x - xShift;
yShift = yShift + Tiles[x, y].V/18*-1;
for (int x1 = xShift; x1 < xShift + 3; x1++)
{
for (int y1 = yShift; y1 < yShift + 3; y1++)
{
if (Tiles[x1, y1] == null)
{
Tiles[x1, y1] = new Tile();
}
if (Tiles[x1, y1].IsActive && Tiles[x1, y1].Type == type)
{
Tiles[x1, y1].Type = 34;
Tiles[x1, y1].V = (short) (Tiles[x1, y1].V + newPosition*54);
}
}
}
}
}
开发者ID:reaperx420,项目名称:Terraria-Map-Editor,代码行数:59,代码来源:World.cs
示例9: DrawSprites
/* Heathtech */
//Pretty much overwrote this whole function. The original part is still intact, but much more hidden
private void DrawSprites()
{
Rectangle visibleBounds = GetViewingArea();
TEditXna.Terraria.Objects.BlendRules blendRules = TEditXna.Terraria.Objects.BlendRules.Instance;
if (visibleBounds.Height * visibleBounds.Width < 25000)
{
//Extended the viewing space to give tiles time to cache their UV's
for (int y = visibleBounds.Top - 1; y < visibleBounds.Bottom + 2; y++)
{
for (int x = visibleBounds.Left - 1; x < visibleBounds.Right + 2; x++)
{
if (x < 0 || y < 0 || x >= _wvm.CurrentWorld.TilesWide || y >= _wvm.CurrentWorld.TilesHigh)
{
continue;
}
var curtile = _wvm.CurrentWorld.Tiles[x, y];
var tileprop = World.TileProperties[curtile.Type];
//Neighbor tiles are often used when dynamically determining which UV position to render
int e = 0, n = 1, w = 2, s = 3, ne = 4, nw = 5, sw = 6, se = 7;
Tile[] neighborTile = new Tile[8];
neighborTile[e] = (x + 1) < _wvm.CurrentWorld.TilesWide ? _wvm.CurrentWorld.Tiles[x + 1, y] : null;
neighborTile[n] = (y - 1) > 0 ? _wvm.CurrentWorld.Tiles[x, y - 1] : null;
neighborTile[w] = (x - 1) > 0 ? _wvm.CurrentWorld.Tiles[x - 1, y] : null;
neighborTile[s] = (y + 1) < _wvm.CurrentWorld.TilesHigh ? _wvm.CurrentWorld.Tiles[x, y + 1] : null;
neighborTile[ne] = (x + 1) < _wvm.CurrentWorld.TilesWide && (y - 1) > 0 ? _wvm.CurrentWorld.Tiles[x + 1, y - 1] : null;
neighborTile[nw] = (x - 1) > 0 && (y - 1) > 0 ? _wvm.CurrentWorld.Tiles[x - 1, y - 1] : null;
neighborTile[sw] = (x - 1) > 0 && (y + 1) < _wvm.CurrentWorld.TilesHigh ? _wvm.CurrentWorld.Tiles[x - 1, y + 1] : null;
neighborTile[se] = (x + 1) < _wvm.CurrentWorld.TilesWide && (y + 1) < _wvm.CurrentWorld.TilesHigh ? _wvm.CurrentWorld.Tiles[x + 1, y + 1] : null;
if (_wvm.ShowWalls)
{
if (curtile.Wall > 0)
{
var wallTex = _textureDictionary.GetWall(curtile.Wall);
if (wallTex != null)
{
if (curtile.uvWallCache == 0xFFFF)
{
int sameStyle = 0x00000000;
sameStyle |= (neighborTile[e] != null && neighborTile[e].Wall == curtile.Wall) ? 0x0001 : 0x0000;
sameStyle |= (neighborTile[n] != null && neighborTile[n].Wall == curtile.Wall) ? 0x0010 : 0x0000;
sameStyle |= (neighborTile[w] != null && neighborTile[w].Wall == curtile.Wall) ? 0x0100 : 0x0000;
sameStyle |= (neighborTile[s] != null && neighborTile[s].Wall == curtile.Wall) ? 0x1000 : 0x0000;
Vector2Int32 uvBlend = blendRules.GetUVForMasks((uint)sameStyle, 0x00000000, 0);
curtile.uvWallCache = (ushort)((uvBlend.Y << 8) + uvBlend.X);
}
var texsize = new Vector2Int32(32, 32);
var source = new Rectangle((curtile.uvWallCache & 0x00FF) * (texsize.X + 4), (curtile.uvWallCache >> 8) * (texsize.Y + 4), texsize.X, texsize.Y);
var dest = new Rectangle(1 + (int)((_scrollPosition.X + x - 0.5) * _zoom), 1 + (int)((_scrollPosition.Y + y - 0.5) * _zoom), (int)_zoom * 2, (int)_zoom * 2);
_spriteBatch.Draw(wallTex, dest, source, Color.White, 0f, default(Vector2), SpriteEffects.None, 1);
}
}
}
if (_wvm.ShowTiles)
{
if (curtile.IsActive)
{
if (tileprop.IsFramed)
{
Rectangle source = new Rectangle(), dest = new Rectangle();
var tileTex = _textureDictionary.GetTile(curtile.Type);
bool isTree = false, isMushroom = false;
bool isLeft = false, isBase = false, isRight = false;
if (curtile.Type == 5 && curtile.U >= 22 && curtile.V >= 198)
{
isTree = true;
switch (curtile.U)
{
case 22: isBase = true; break;
case 44: isLeft = true; break;
case 66: isRight = true; break;
}
//Abuse uvTileCache to remember what type of tree it is, since potentially scanning a hundred of blocks PER tree tile sounds slow
int treeType = (curtile.uvTileCache & 0x000F);
if (treeType > 4) //Tree type not yet set
{
//Check tree type
treeType = 0; //Default to normal in case no grass grows beneath the tree
int baseX = (isLeft) ? 1 : (isRight) ? -1 : 0;
for (int i = 0; i < 100; i++)
{
Tile checkTile = (y + i) < _wvm.CurrentWorld.TilesHigh ? _wvm.CurrentWorld.Tiles[x + baseX, y + i] : null;
bool found = true;
if (checkTile != null && checkTile.IsActive)
{
switch (checkTile.Type)
{
case 2: treeType = 0; break; //Normal
case 23: treeType = 1; break; //Corruption
case 60: treeType = 2; break; //Jungle
case 109: treeType = 3; break; //Hallow
//.........这里部分代码省略.........
开发者ID:Ninlay,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:WorldRenderXna.xaml.cs
示例10: DrawSprites
/* Heathtech */
//Pretty much overwrote this whole function. The original part is still intact, but much more hidden
private void DrawSprites()
{
Rectangle visibleBounds = GetViewingArea();
TEditXna.Terraria.Objects.BlendRules blendRules = TEditXna.Terraria.Objects.BlendRules.Instance;
var width = _wvm.CurrentWorld.TilesWide;
var height = _wvm.CurrentWorld.TilesHigh;
if (visibleBounds.Height * visibleBounds.Width < 25000)
{
//Extended the viewing space to give tiles time to cache their UV's
for (int y = visibleBounds.Top - 1; y < visibleBounds.Bottom + 2; y++)
{
for (int x = visibleBounds.Left - 1; x < visibleBounds.Right + 2; x++)
{
if (x < 0 || y < 0 || x >= _wvm.CurrentWorld.TilesWide || y >= _wvm.CurrentWorld.TilesHigh)
{
continue;
}
var curtile = _wvm.CurrentWorld.Tiles[x, y];
var tileprop = World.TileProperties[curtile.Type];
//Neighbor tiles are often used when dynamically determining which UV position to render
int e = 0, n = 1, w = 2, s = 3, ne = 4, nw = 5, sw = 6, se = 7;
Tile[] neighborTile = new Tile[8];
neighborTile[ e] = (x + 1) < width ? _wvm.CurrentWorld.Tiles[x + 1, y ] : null;
neighborTile[ n] = (y - 1) > 0 ? _wvm.CurrentWorld.Tiles[x , y - 1] : null;
neighborTile[ w] = (x - 1) > 0 ? _wvm.CurrentWorld.Tiles[x - 1, y ] : null;
neighborTile[ s] = (y + 1) < height ? _wvm.CurrentWorld.Tiles[x , y + 1] : null;
neighborTile[ne] = (x + 1) < width && (y - 1) > 0 ? _wvm.CurrentWorld.Tiles[x + 1, y - 1] : null;
neighborTile[nw] = (x - 1) > 0 && (y - 1) > 0 ? _wvm.CurrentWorld.Tiles[x - 1, y - 1] : null;
neighborTile[sw] = (x - 1) > 0 && (y + 1) < height ? _wvm.CurrentWorld.Tiles[x - 1, y + 1] : null;
neighborTile[se] = (x + 1) < width && (y + 1) < height ? _wvm.CurrentWorld.Tiles[x + 1, y + 1] : null;
//draw background textures
if (y >= 80)
{
int[,] backstyle = {
{66, 67, 68, 69, 128, 125, 185},
{70, 71, 68, 72, 128, 125, 185},
{73, 74, 75, 76, 134, 125, 185},
{77, 78, 79, 82, 134, 125, 185},
{83, 84, 85, 86, 137, 125, 185},
{83, 87, 88, 89, 137, 125, 185},
{121, 122, 123, 124, 140, 125, 185},
{153, 147, 148, 149, 150, 125, 185},
{146, 154, 155, 156, 157, 125, 185}
};
int hellback = _wvm.CurrentWorld.HellBackStyle;
int backX = 0;
if (x <= _wvm.CurrentWorld.CaveBackX0)
backX = _wvm.CurrentWorld.CaveBackStyle0;
else if (x > _wvm.CurrentWorld.CaveBackX0 && x <= _wvm.CurrentWorld.CaveBackX1)
backX = _wvm.CurrentWorld.CaveBackStyle1;
else if (x > _wvm.CurrentWorld.CaveBackX1 && x <= _wvm.CurrentWorld.CaveBackX2)
backX = _wvm.CurrentWorld.CaveBackStyle2;
else if (x > _wvm.CurrentWorld.CaveBackX2)
backX = _wvm.CurrentWorld.CaveBackStyle3;
var source = new Rectangle(0, 0, 16, 16);
var backTex = _textureDictionary.GetBackground(0);
if (y < _wvm.CurrentWorld.GroundLevel)
{
backTex = _textureDictionary.GetBackground(0);
source.Y += (y - 80) * 16;
}
else if (y == _wvm.CurrentWorld.GroundLevel)
{
backTex = _textureDictionary.GetBackground(backstyle[backX, 0]);
source.X += (x % 8) * 16;
}
else if (y > _wvm.CurrentWorld.GroundLevel && y < _wvm.CurrentWorld.RockLevel)
{
backTex = _textureDictionary.GetBackground(backstyle[backX, 1]);
source.X += (x % 8) * 16;
source.Y += ((y - 1 - (int)_wvm.CurrentWorld.GroundLevel) % 6) * 16;
}
else if (y == _wvm.CurrentWorld.RockLevel)
{
backTex = _textureDictionary.GetBackground(backstyle[backX, 2]);
source.X += (x % 8) * 16;
}
else if (y > _wvm.CurrentWorld.RockLevel && y < (_wvm.CurrentWorld.TilesHigh - 327))
{
backTex = _textureDictionary.GetBackground(backstyle[backX, 3]);
source.X += (x % 8) * 16;
source.Y += ((y - 1 - (int)_wvm.CurrentWorld.RockLevel) % 6) * 16;
}
else if (y == (_wvm.CurrentWorld.TilesHigh - 327))
{
backTex = _textureDictionary.GetBackground(backstyle[backX, 4] + hellback);
source.X += (x % 8) * 16;
}
else if (y > (_wvm.CurrentWorld.TilesHigh - 327) && y < (_wvm.CurrentWorld.TilesHigh - 200))
{
backTex = _textureDictionary.GetBackground(backstyle[backX, 5] + hellback);
source.X += (x % 8) * 16;
source.Y += ((y - 1 - (int)_wvm.CurrentWorld.TilesHigh + 327) % 18) * 16;
//.........这里部分代码省略.........
开发者ID:TEdit,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:WorldRenderXna.xaml.cs
示例11: SetWall
private void SetWall(Tile curTile, bool erase)
{
if (TilePicker.WallMaskMode == MaskMode.Off ||
(TilePicker.WallMaskMode == MaskMode.Match && curTile.Wall == TilePicker.WallMask) ||
(TilePicker.WallMaskMode == MaskMode.Empty && curTile.Wall == 0) ||
(TilePicker.WallMaskMode == MaskMode.NotMatching && curTile.Wall != TilePicker.WallMask))
{
if (erase)
SetPixelAutomatic(curTile, wall: 0);
else
SetPixelAutomatic(curTile, wall: TilePicker.Wall);
}
}
开发者ID:AFKassassin,项目名称:Terraria-Map-Editor,代码行数:13,代码来源:WorldViewModel.Editor.cs
示例12: SetPixelAutomatic
private void SetPixelAutomatic(Tile curTile,
int? tile = null,
int? wall = null,
byte? liquid = null,
LiquidType? liquidType = null,
bool? wire = null,
short? u = null,
short? v = null,
bool? wire2 = null,
bool? wire3 = null,
BrickStyle? brickStyle = null,
bool? actuator = null, bool? actuatorInActive = null,
int? tileColor = null,
int? wallColor = null)
{
// Set Tile Data
if (u != null)
curTile.U = (short)u;
if (v != null)
curTile.V = (short)v;
if (tile != null)
{
if (tile == -1)
{
curTile.Type = 0;
curTile.IsActive = false;
}
else
{
curTile.Type = (ushort)tile;
curTile.IsActive = true;
}
}
if (actuator != null && curTile.IsActive)
{
curTile.Actuator = (bool)actuator;
}
if (actuatorInActive != null && curTile.IsActive)
{
curTile.InActive = (bool)actuatorInActive;
}
if (brickStyle != null && TilePicker.BrickStyleActive)
{
curTile.BrickStyle = (BrickStyle)brickStyle;
}
if (wall != null)
curTile.Wall = (byte)wall;
if (liquid != null)
{
curTile.LiquidAmount = (byte)liquid;
}
if (liquidType != null)
{
curTile.LiquidType = (LiquidType)liquidType;
}
if (wire != null)
curTile.WireRed = (bool)wire;
if (wire2 != null)
curTile.WireGreen = (bool)wire2;
if (wire3 != null)
curTile.WireBlue = (bool)wire3;
if (tileColor != null)
{
if (curTile.IsActive)
{
curTile.TileColor = (byte)tileColor;
}
else
{
curTile.TileColor = (byte)0;
}
}
if (wallColor != null)
{
if (curTile.Wall != 0)
{
curTile.WallColor = (byte)wallColor;
}
else
{
curTile.WallColor = (byte)0;
}
}
if (curTile.IsActive)
if (World.TileProperties[curTile.Type].IsSolid)
curTile.LiquidAmount = 0;
}
开发者ID:AFKassassin,项目名称:Terraria-Map-Editor,代码行数:100,代码来源:WorldViewModel.Editor.cs
示例13: Equals
public bool Equals(Tile other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return other.IsActive.Equals(IsActive) && other.Type == Type && other.Wall == Wall && other.Liquid == Liquid && other.IsLava.Equals(IsLava) && other.U == U && other.V == V && other.HasWire.Equals(HasWire);
}
开发者ID:ThomasWDonnelly,项目名称:Terraria-Map-Editor,代码行数:6,代码来源:Tile.cs
示例14: Load3
public static ClipboardBuffer Load3(string filename, bool frame19 = false)
{
bool failed = false;
try
{
using (var stream = new FileStream(filename, FileMode.Open))
{
using (var br = new BinaryReader(stream))
{
string name = br.ReadString();
int version = br.ReadInt32();
int sizeX = br.ReadInt32();
int sizeY = br.ReadInt32();
var buffer = new ClipboardBuffer(new Vector2Int32(sizeX, sizeY));
buffer.Name = name;
for (int x = 0; x < sizeX; x++)
{
for (int y = 0; y < sizeY; y++)
{
var curTile = new Tile();
curTile.IsActive = br.ReadBoolean();
if (curTile.IsActive)
{
curTile.Type = br.ReadByte();
if (curTile.Type == 19) // fix for platforms
{
curTile.U = 0;
curTile.V = 0;
if (frame19)
{
curTile.U = br.ReadInt16();
curTile.V = br.ReadInt16();
}
}
else if (World.TileProperties[curTile.Type].IsFramed)
{
curTile.U = br.ReadInt16();
curTile.V = br.ReadInt16();
if (curTile.Type == 144) //timer
curTile.V = 0;
}
else
{
curTile.U = -1;
curTile.V = -1;
}
}
if (br.ReadBoolean())
curTile.Wall = br.ReadByte();
if (br.ReadBoolean())
{
curTile.Liquid = br.ReadByte();
curTile.IsLava = br.ReadBoolean();
}
curTile.HasWire = br.ReadBoolean();
buffer.Tiles[x, y] = curTile;
}
}
for (int chestIndex = 0; chestIndex < 1000; chestIndex++)
{
if (br.ReadBoolean())
{
var curChest = new Chest(br.ReadInt32(), br.ReadInt32());
for (int j = 0; j < 20; ++j)
{
curChest.Items[j].StackSize = br.ReadByte();
if (curChest.Items[j].StackSize > 0)
{
if (version >= 3)
curChest.Items[j].NetId = br.ReadInt32();
else
curChest.Items[j].SetFromName(br.ReadString());
curChest.Items[j].Prefix = br.ReadByte();
}
else
{
curChest.Items[j].SetFromName("[empty]");
}
}
buffer.Chests.Add(curChest);
}
}
for (int signIndex = 0; signIndex < 1000; signIndex++)
{
if (br.ReadBoolean())
{
string text = br.ReadString();
int x = br.ReadInt32();
int y = br.ReadInt32();
buffer.Signs.Add(new Sign(x, y, text));
//.........这里部分代码省略.........
开发者ID:Kaedenn,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:ClipboardBuffer.File.cs
示例15: Load2
public static ClipboardBuffer Load2(string filename)
{
using (var stream = new FileStream(filename, FileMode.Open))
{
using (var reader = new BinaryReader(stream))
{
string name = reader.ReadString();
int version = reader.ReadInt32();
int maxx = reader.ReadInt32();
int maxy = reader.ReadInt32();
var buffer = new ClipboardBuffer(new Vector2Int32(maxx, maxy));
buffer.Name = string.IsNullOrWhiteSpace(name) ? Path.GetFileNameWithoutExtension(filename) : name;
try
{
for (int x = 0; x < maxx; x++)
{
for (int y = 0; y < maxy; y++)
{
var curTile = new Tile();
curTile.IsActive = reader.ReadBoolean();
if (curTile.IsActive)
{
curTile.Type = reader.ReadByte();
if (curTile.Type == 19) // fix for platforms
{
curTile.U = 0;
curTile.V = 0;
}
else if (World.TileProperties[curTile.Type].IsFramed)
{
curTile.U = reader.ReadInt16();
curTile.V = reader.ReadInt16();
if (curTile.Type == 144) //timer
curTile.V = 0;
}
else
{
curTile.U = -1;
curTile.V = -1;
}
}
if (reader.ReadBoolean())
curTile.Wall = reader.ReadByte();
if (reader.ReadBoolean())
{
curTile.Liquid = reader.ReadByte();
curTile.IsLava = reader.ReadBoolean();
}
curTile.HasWire = reader.ReadBoolean();
buffer.Tiles[x, y] = curTile;
}
}
}
catch (Exception)
{
for (int x = 0; x < buffer.Size.X; x++)
{
for (int y = 0; y < buffer.Size.Y; y++)
{
if (buffer.Tiles[x, y] == null)
buffer.Tiles[x, y] = new Tile();
}
}
return buffer;
}
for (int chestIndex = 0; chestIndex < 1000; chestIndex++)
{
if (reader.ReadBoolean())
{
var chest = new Chest();
chest.X = reader.ReadInt32();
chest.Y = reader.ReadInt32();
for (int slot = 0; slot < 20; slot++)
{
byte stackSize = reader.ReadByte();
if (stackSize > 0)
{
string itemName = reader.ReadString();
chest.Items[slot].SetFromName(itemName);
chest.Items[slot].StackSize = stackSize;
}
}
//Chests[chestIndex] = chest;
buffer.Chests.Add(chest);
}
}
for (int signIndex = 0; signIndex < 1000; signIndex++)
//.........这里部分代码省略.........
开发者ID:Kaedenn,项目名称:Terraria-Map-Editor,代码行数:101,代码来源:ClipboardBuffer.File.cs
示例16: LinearFloodFill
private void LinearFloodFill(ref int x, ref int y, ref Tile originTile)
{
int bitmapWidth = _wvm.CurrentWorld.TilesWide;
int bitmapHeight = _wvm.CurrentWorld.TilesHigh;
//FIND LEFT EDGE OF COLOR AREA
int lFillLoc = x; //the location to check/fill on the left
int tileIndex = (bitmapWidth * y) + x;
while (true)
{
if (!_wvm.CheckTiles[tileIndex])
{
_wvm.UndoManager.SaveTile(lFillLoc, y);
_wvm.SetPixel(lFillLoc, y);
_wvm.UpdateRenderPixel(lFillLoc, y);
_wvm.CheckTiles[tileIndex] = true;
}
lFillLoc--;
tileIndex--;
if (lFillLoc <= 0 || _wvm.CheckTiles[tileIndex] || !CheckTileMatch(ref originTile, ref _wvm.CurrentWorld.Tiles[lFillLoc, y]) || !_wvm.Selection.IsValid(lFillLoc, y))
break; //exit loop if we're at edge of bitmap or color area
}
/* Heathtech */
BlendRules.ResetUVCache(_wvm, lFillLoc + 1, y, x - lFillLoc, 1);
lFillLoc++;
if (lFillLoc < _minX)
_minX = lFillLoc;
//FIND RIGHT EDGE OF COLOR AREA
int rFillLoc = x; //the location to check/fill on the left
tileIndex = (bitmapWidth * y) + x;
while (true)
{
if (!_wvm.CheckTiles[tileIndex])
{
_wvm.UndoManager.SaveTile(rFillLoc, y);
_wvm.SetPixel(rFillLoc, y);
_wvm.UpdateRenderPixel(rFillLoc, y);
_wvm.CheckTiles[tileIndex] = true;
BlendRules.ResetUVCache(_wvm, rFillLoc, y, 1, 1);
}
rFillLoc++;
tileIndex++;
if (rFillLoc >= bitmapWidth || _wvm.CheckTiles[tileIndex] || !CheckTileMatch(ref originTile, ref _wvm.CurrentWorld.Tiles[rFillLoc, y]) || !_wvm.Selection.IsValid(rFillLoc, y))
break; //exit loop if we're at edge of bitmap or color area
}
/* Heathtech */
BlendRules.ResetUVCache(_wvm, x, y, rFillLoc - x, 1);
rFillLoc--;
if (rFillLoc > _maxX)
_maxX = rFillLoc;
var r = new FloodFillRange(lFillLoc, rFillLoc, y);
_ranges.Enqueue(ref r);
}
开发者ID:Ninlay,项目名称:Terraria-Map-Editor,代码行数:59,代码来源:FillTool.cs
|
请发表评论