本文整理汇总了C#中Server.Tile类的典型用法代码示例。如果您正苦于以下问题:C# Tile类的具体用法?C# Tile怎么用?C# Tile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tile类属于Server命名空间,在下文中一共展示了Tile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Game
public Game(int width, int height, int mines)
{
this.height = height;
this.width = width;
this.mines = mines;
tiles = new Tile[width, height];
for (int i = 0; i < this.width; i++)
for (int j = 0; j < this.height; j++)
tiles[i, j] = new Tile();
Random rand = new Random();
for (int i = 0; i < mines; )
{
int r1 = rand.Next(width);
int r2 = rand.Next(height);
if (tiles[r1, r2].status == Tile.TileStatus.CLEAN)
{
tiles[r1, r2].status = Tile.TileStatus.MINED;
i++;
}
}
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.Elapsed += new System.Timers.ElapsedEventHandler(onTick);
timer.Start();
}
示例2: MultiComponentList
public MultiComponentList( MultiComponentList toCopy )
{
m_Min = toCopy.m_Min;
m_Max = toCopy.m_Max;
m_Center = toCopy.m_Center;
m_Width = toCopy.m_Width;
m_Height = toCopy.m_Height;
m_Tiles = new Tile[m_Width][][];
for ( int x = 0; x < m_Width; ++x )
{
m_Tiles[x] = new Tile[m_Height][];
for ( int y = 0; y < m_Height; ++y )
{
m_Tiles[x][y] = new Tile[toCopy.m_Tiles[x][y].Length];
for ( int i = 0; i < m_Tiles[x][y].Length; ++i )
m_Tiles[x][y][i] = toCopy.m_Tiles[x][y][i];
}
}
m_List = new MultiTileEntry[toCopy.m_List.Length];
for ( int i = 0; i < m_List.Length; ++i )
m_List[i] = toCopy.m_List[i];
}
示例3: IsOk
private bool IsOk(Mobile m, bool ignoreDoors, int ourZ, int ourTop, Tile[] tiles, ArrayList items, bool canFly )
{
for ( int i = 0; i < tiles.Length; ++i )
{
Tile check = tiles[i];
ItemData itemData = TileData.ItemTable[check.ID & 0x3FFF];
if ( (itemData.Flags & ImpassableSurface) != 0 ) // Impassable || Surface
{
//we can fly test what we can fly over defined in mobile array
if(canFly && m.FlyArray != null)
{
//look through are array of fly tiles
for( int x = 0; x < m.FlyArray.Length; x++ )
{
if(check.ID == m.FlyArray[x] )
{
FlyZvalue = check.Z + itemData.CalcHeight;
continue;
}
}
if(FlyZvalue !=0)
continue;
}
int checkZ = check.Z;
int checkTop = checkZ + itemData.CalcHeight;
if ( checkTop > ourZ && ourTop > checkZ )
return false;
}
}
for ( int i = 0; i < items.Count; ++i )
{
Item item = (Item)items[i];
int itemID = item.ItemID & 0x3FFF;
ItemData itemData = TileData.ItemTable[itemID];
TileFlag flags = itemData.Flags;
if ( (flags & ImpassableSurface) != 0 ) // Impassable || Surface
{
if ( ignoreDoors && ((flags & TileFlag.Door) != 0 || itemID == 0x692 || itemID == 0x846 || itemID == 0x873 || (itemID >= 0x6F5 && itemID <= 0x6F6)) )
continue;
int checkZ = item.Z;
int checkTop = checkZ + itemData.CalcHeight;
if ( checkTop > ourZ && ourTop > checkZ )
return false;
}
}
return true;
}
示例4: AddRange
public void AddRange( Tile[] tiles )
{
if ( (m_Count + tiles.Length) > m_Tiles.Length )
{
Tile[] old = m_Tiles;
m_Tiles = new Tile[(m_Count + tiles.Length) * 2];
for ( int i = 0; i < old.Length; ++i )
m_Tiles[i] = old[i];
}
for ( int i = 0; i < tiles.Length; ++i )
m_Tiles[m_Count++] = tiles[i];
}
示例5: ToArray
public Tile[] ToArray()
{
if ( m_Count == 0 )
return m_EmptyTiles;
Tile[] tiles = new Tile[m_Count];
for ( int i = 0; i < m_Count; ++i )
tiles[i] = m_Tiles[i];
m_Count = 0;
return tiles;
}
示例6: IsOk
private bool IsOk( bool ignoreDoors, bool ignoreSpellFields, int ourZ, int ourTop, Tile[] tiles, List<Item> items )
{
for ( int i = 0; i < tiles.Length; ++i )
{
Tile check = tiles[i];
#region SA
ItemData itemData = TileData.ItemTable[(check.ID-0x4000) & 0x7FFF];
#endregion
if ( (itemData.Flags & ImpassableSurface) != 0 ) // Impassable || Surface
{
int checkZ = check.Z;
int checkTop = checkZ + itemData.CalcHeight;
if ( checkTop > ourZ && ourTop > checkZ )
return false;
}
}
for ( int i = 0; i < items.Count; ++i )
{
Item item = items[i];
#region SA
int itemID = (item.ItemID-0x4000) & 0x7FFF;
#endregion
ItemData itemData = TileData.ItemTable[itemID];
TileFlag flags = itemData.Flags;
if ( (flags & ImpassableSurface) != 0 ) // Impassable || Surface
{
if ( ignoreDoors && ((flags & TileFlag.Door) != 0 || itemID == 0x692 || itemID == 0x846 || itemID == 0x873 || (itemID >= 0x6F5 && itemID <= 0x6F6)) )
continue;
if ( ignoreSpellFields && ( itemID == 0x82 || itemID == 0x3946 || itemID == 0x3956 ) )
continue;
int checkZ = item.Z;
int checkTop = checkZ + itemData.CalcHeight;
if ( checkTop > ourZ && ourTop > checkZ )
return false;
}
}
return true;
}
示例7: PatchTiles
public static Tile[] PatchTiles( Tile[] tiles, int season )
{
if ( season <= 0 || season >= SeasonCount )
return tiles;
var tileChanges = m_TileChanges[season];
if ( tileChanges != null )
{
for ( int i = 0; i < tiles.Length; i++ )
{
if ( tileChanges.ContainsKey( tiles[i].ID ) )
tiles[i].ID = tileChanges[tiles[i].ID];
}
}
return tiles;
}
示例8: IsOk
private bool IsOk( bool ignoreDoors, int ourZ, int ourTop, Tile[] tiles, ArrayList items )
{
for ( int i = 0; i < tiles.Length; ++i )
{
Tile check = tiles[i];
ItemData itemData = TileData.ItemTable[check.ID & 0x3FFF];
if ( (itemData.Flags & ImpassableSurface) != 0 ) // Impassable || Surface
{
int checkZ = check.Z;
int checkTop = checkZ + itemData.CalcHeight;
if ( checkTop > ourZ && ourTop > checkZ )
return false;
}
}
for ( int i = 0; i < items.Count; ++i )
{
Item item = (Item)items[i];
int itemID = item.ItemID & 0x3FFF;
ItemData itemData = TileData.ItemTable[itemID];
TileFlag flags = itemData.Flags;
if ( (flags & ImpassableSurface) != 0 ) // Impassable || Surface
{
if ( ignoreDoors && ((flags & TileFlag.Door) != 0 || itemID == 0x692 || itemID == 0x846 || itemID == 0x873 || (itemID >= 0x6F5 && itemID <= 0x6F6)) )
continue;
int checkZ = item.Z;
int checkTop = checkZ + itemData.CalcHeight;
if ( checkTop > ourZ && ourTop > checkZ )
return false;
}
}
return true;
}
示例9: ReadStaticBlock
private unsafe Tile[][][] ReadStaticBlock( int x, int y )
{
try
{
m_IndexReader.BaseStream.Seek( ((x * m_BlockHeight) + y) * 12, SeekOrigin.Begin );
int lookup = m_IndexReader.ReadInt32();
int length = m_IndexReader.ReadInt32();
if ( lookup < 0 || length <= 0 )
{
return m_EmptyStaticBlock;
}
else
{
int count = length / 7;
m_Statics.Seek( lookup, SeekOrigin.Begin );
if ( m_TileBuffer.Length < count )
m_TileBuffer = new StaticTile[count];
StaticTile[] staTiles = m_TileBuffer;//new StaticTile[tileCount];
fixed ( StaticTile *pTiles = staTiles )
{
#if !MONO
NativeReader.Read( m_Statics.SafeFileHandle.DangerousGetHandle(), pTiles, length );
#else
NativeReader.Read( m_Statics.Handle, pTiles, length );
#endif
if ( m_Lists == null )
{
m_Lists = new TileList[8][];
for ( int i = 0; i < 8; ++i )
{
m_Lists[i] = new TileList[8];
for ( int j = 0; j < 8; ++j )
m_Lists[i][j] = new TileList();
}
}
TileList[][] lists = m_Lists;
StaticTile *pCur = pTiles, pEnd = pTiles + count;
while ( pCur < pEnd )
{
lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Z );
pCur = pCur + 1;
}
Tile[][][] tiles = new Tile[8][][];
for ( int i = 0; i < 8; ++i )
{
tiles[i] = new Tile[8][];
for ( int j = 0; j < 8; ++j )
tiles[i][j] = lists[i][j].ToArray();
}
return tiles;
}
}
}
catch ( EndOfStreamException )
{
if ( DateTime.Now >= m_NextStaticWarning )
{
Console.WriteLine( "Warning: Static EOS for {0} ({1}, {2})", m_Owner, x, y );
m_NextStaticWarning = DateTime.Now + TimeSpan.FromMinutes( 1.0 );
}
return m_EmptyStaticBlock;
}
}
示例10: PatchStatics
private unsafe int PatchStatics( TileMatrix matrix, string dataPath, string indexPath, string lookupPath )
{
using ( FileStream fsData = new FileStream( dataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
using ( FileStream fsIndex = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
using ( FileStream fsLookup = new FileStream( lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
BinaryReader indexReader = new BinaryReader( fsIndex );
BinaryReader lookupReader = new BinaryReader( fsLookup );
int count = (int)(indexReader.BaseStream.Length / 4);
TileList[][] lists = new TileList[8][];
for ( int x = 0; x < 8; ++x )
{
lists[x] = new TileList[8];
for ( int y = 0; y < 8; ++y )
lists[x][y] = new TileList();
}
for ( int i = 0; i < count; ++i )
{
int blockID = indexReader.ReadInt32();
int blockX = blockID / matrix.BlockHeight;
int blockY = blockID % matrix.BlockHeight;
int offset = lookupReader.ReadInt32();
int length = lookupReader.ReadInt32();
lookupReader.ReadInt32(); // Extra
if ( offset < 0 || length <= 0 )
{
matrix.SetStaticBlock( blockX, blockY, matrix.EmptyStaticBlock );
continue;
}
fsData.Seek( offset, SeekOrigin.Begin );
int tileCount = length / 7;
if ( m_TileBuffer.Length < tileCount )
m_TileBuffer = new StaticTile[tileCount];
StaticTile[] staTiles = m_TileBuffer;
fixed ( StaticTile *pTiles = staTiles )
{
#if !MONO
NativeReader.Read( fsData.SafeFileHandle.DangerousGetHandle(), pTiles, length );
#else
NativeReader.Read( fsData.Handle, pTiles, length );
#endif
StaticTile *pCur = pTiles, pEnd = pTiles + tileCount;
while ( pCur < pEnd )
{
lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Z );
pCur = pCur + 1;
}
Tile[][][] tiles = new Tile[8][][];
for ( int x = 0; x < 8; ++x )
{
tiles[x] = new Tile[8][];
for ( int y = 0; y < 8; ++y )
tiles[x][y] = lists[x][y].ToArray();
}
matrix.SetStaticBlock( blockX, blockY, tiles );
}
}
indexReader.Close();
lookupReader.Close();
return count;
}
}
}
}
示例11: PatchLand
private unsafe int PatchLand( TileMatrix matrix, string dataPath, string indexPath )
{
using ( FileStream fsData = new FileStream( dataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
using ( FileStream fsIndex = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
BinaryReader indexReader = new BinaryReader( fsIndex );
int count = (int)(indexReader.BaseStream.Length / 4);
for ( int i = 0; i < count; ++i )
{
int blockID = indexReader.ReadInt32();
int x = blockID / matrix.BlockHeight;
int y = blockID % matrix.BlockHeight;
fsData.Seek( 4, SeekOrigin.Current );
Tile[] tiles = new Tile[64];
fixed ( Tile *pTiles = tiles )
{
#if !MONO
NativeReader.Read( fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192 );
#else
NativeReader.Read( fsData.Handle, pTiles, 192 );
#endif
}
matrix.SetLandBlock( x, y, tiles );
}
indexReader.Close();
return count;
}
}
}
示例12: Resize
public void Resize( int newWidth, int newHeight )
{
int oldWidth = m_Width, oldHeight = m_Height;
Tile[][][] oldTiles = m_Tiles;
int totalLength = 0;
Tile[][][] newTiles = new Tile[newWidth][][];
for ( int x = 0; x < newWidth; ++x )
{
newTiles[x] = new Tile[newHeight][];
for ( int y = 0; y < newHeight; ++y )
{
if ( x < oldWidth && y < oldHeight )
newTiles[x][y] = oldTiles[x][y];
else
newTiles[x][y] = new Tile[0];
totalLength += newTiles[x][y].Length;
}
}
m_Tiles = newTiles;
m_List = new MultiTileEntry[totalLength];
m_Width = newWidth;
m_Height = newHeight;
m_Min = Point2D.Zero;
m_Max = Point2D.Zero;
int index = 0;
for ( int x = 0; x < newWidth; ++x )
{
for ( int y = 0; y < newHeight; ++y )
{
Tile[] tiles = newTiles[x][y];
for ( int i = 0; i < tiles.Length; ++i )
{
Tile tile = tiles[i];
int vx = x - m_Center.X;
int vy = y - m_Center.Y;
if ( vx < m_Min.m_X )
m_Min.m_X = vx;
if ( vy < m_Min.m_Y )
m_Min.m_Y = vy;
if ( vx > m_Max.m_X )
m_Max.m_X = vx;
if ( vy > m_Max.m_Y )
m_Max.m_Y = vy;
m_List[index++] = new MultiTileEntry( (short)tile.ID, (short)vx, (short)vy, (short)tile.Z, 1 );
}
}
}
}
示例13: PatchLand
private int PatchLand( TileMatrix matrix, string dataPath, string indexPath )
{
using ( FileStream fsData = new FileStream( dataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
using ( FileStream fsIndex = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
{
BinaryReader indexReader = new BinaryReader( fsIndex );
int count = (int)(indexReader.BaseStream.Length / 4);
for ( int i = 0; i < count; ++i )
{
int blockID = indexReader.ReadInt32();
int x = blockID / matrix.BlockHeight;
int y = blockID % matrix.BlockHeight;
fsData.Seek( 4, SeekOrigin.Current );
Tile[] tiles = new Tile[64];
GCHandle handle = GCHandle.Alloc(tiles, GCHandleType.Pinned);
try {
if ( m_Buffer == null || 192 > m_Buffer.Length )
m_Buffer = new byte[192];
fsData.Read( m_Buffer, 0, 192 );
Marshal.Copy(m_Buffer, 0, handle.AddrOfPinnedObject(), 192);
} finally {
handle.Free();
}
matrix.SetLandBlock( x, y, tiles );
}
indexReader.Close();
return count;
}
}
}
示例14: SetStaticBlock
public void SetStaticBlock( int x, int y, Tile[][][] value )
{
if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight )
return;
if ( m_StaticTiles[x] == null )
m_StaticTiles[x] = new Tile[m_BlockHeight][][][];
m_StaticTiles[x][y] = value;
if ( m_StaticPatches[x] == null )
m_StaticPatches[x] = new int[(m_BlockHeight + 31) >> 5];
m_StaticPatches[x][y >> 5] |= 1 << (y & 0x1F);
}
示例15: ReadStaticBlock
private unsafe Tile[][][] ReadStaticBlock( int x, int y )
{
try
{
m_IndexReader.BaseStream.Seek( ((x * m_BlockHeight) + y) * 12, SeekOrigin.Begin );
int lookup = m_IndexReader.ReadInt32();
int length = m_IndexReader.ReadInt32();
if ( lookup < 0 || length <= 0 )
{
return m_EmptyStaticBlock;
}
else
{
int count = length / 7;
m_Statics.Seek( lookup, SeekOrigin.Begin );
if ( m_TileBuffer.Length < count )
m_TileBuffer = new StaticTile[count];
StaticTile[] staTiles = m_TileBuffer;//new StaticTile[tileCount];
fixed ( StaticTile *pTiles = staTiles )
{
if ( m_Buffer == null || length > m_Buffer.Length )
m_Buffer = new byte[length];
m_Statics.Read( m_Buffer, 0, length );
Marshal.Copy(m_Buffer, 0, new IntPtr(pTiles), length);
if ( m_Lists == null )
{
m_Lists = new TileList[8][];
for ( int i = 0; i < 8; ++i )
{
m_Lists[i] = new TileList[8];
for ( int j = 0; j < 8; ++j )
m_Lists[i][j] = new TileList();
}
}
TileList[][] lists = m_Lists;
for (int i = 0; i < count; i++) {
StaticTile *pCur = pTiles + i;
lists[pCur->m_X & 0x7][pCur->m_Y & 0x7].Add( (short)((pCur->m_ID & 0x3FFF) + 0x4000), pCur->m_Z );
}
Tile[][][] tiles = new Tile[8][][];
for ( int i = 0; i < 8; ++i )
{
tiles[i] = new Tile[8][];
for ( int j = 0; j < 8; ++j )
tiles[i][j] = lists[i][j].ToArray();
}
return tiles;
}
}
}
catch ( EndOfStreamException )
{
if ( DateTime.Now >= m_NextStaticWarning )
{
Console.WriteLine( "Warning: Static EOS for {0} ({1}, {2})", m_Owner, x, y );
m_NextStaticWarning = DateTime.Now + TimeSpan.FromMinutes( 1.0 );
}
return m_EmptyStaticBlock;
}
}