本文整理汇总了C#中UltimaXNA.Ultima.World.Maps.Map.GetMapTile方法的典型用法代码示例。如果您正苦于以下问题:C# Map.GetMapTile方法的具体用法?C# Map.GetMapTile怎么用?C# Map.GetMapTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UltimaXNA.Ultima.World.Maps.Map
的用法示例。
在下文中一共展示了Map.GetMapTile方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetermineIfClientIsUnderEntity
private void DetermineIfClientIsUnderEntity(Map map, Position3D center)
{
// Are we inside (under a roof)? Do not draw tiles above our head.
m_DrawMaxItemAltitude = 255;
m_DrawTerrain = true;
m_UnderSurface = false;
MapTile tile;
AEntity underObject, underTerrain;
if ((tile = map.GetMapTile(center.X, center.Y)) != null)
{
if (tile.IsZUnderEntityOrGround(center.Z, out underObject, out underTerrain))
{
// if we are under terrain, then do not draw any terrain at all.
m_DrawTerrain = (underTerrain == null);
if (!(underObject == null))
{
// Roofing and new floors ALWAYS begin at intervals of 20.
// if we are under a ROOF, then get rid of everything above me.Z + 20
// (this accounts for A-frame roofs). Otherwise, get rid of everything
// at the object above us.Z.
if (underObject is Item)
{
Item item = (Item)underObject;
if (item.ItemData.IsRoof)
m_DrawMaxItemAltitude = center.Z - (center.Z % 20) + 20;
else if (item.ItemData.IsSurface || (item.ItemData.IsWall && !item.ItemData.IsDoor))
m_DrawMaxItemAltitude = item.Z;
else
{
int z = center.Z + ((item.ItemData.Height > 20) ? item.ItemData.Height : 20);
m_DrawMaxItemAltitude = z;
}
}
// If we are under a roof tile, do not make roofs transparent if we are on an edge.
if (underObject is Item && ((Item)underObject).ItemData.IsRoof)
{
bool isRoofSouthEast = true;
if ((tile = map.GetMapTile(center.X + 1, center.Y)) != null)
{
tile.IsZUnderEntityOrGround(center.Z, out underObject, out underTerrain);
isRoofSouthEast = !(underObject == null);
}
if (!isRoofSouthEast)
m_DrawMaxItemAltitude = 255;
}
m_UnderSurface = (m_DrawMaxItemAltitude != 255);
}
}
}
}
示例2: DrawEntities
private void DrawEntities(Map map, Position3D center, MousePicking mousePicking, out Vector2 renderOffset)
{
if (center == null)
{
renderOffset = new Vector2();
return;
}
// reset the spritebatch Z
m_SpriteBatch.Reset();
// set the lighting variables.
m_SpriteBatch.SetLightIntensity(Lighting.IsometricLightLevel);
m_SpriteBatch.SetLightDirection(Lighting.IsometricLightDirection);
// get variables that describe the tiles drawn in the viewport: the first tile to draw,
// the offset to that tile, and the number of tiles drawn in the x and y dimensions.
Point firstTile, renderDimensions;
int overDrawTilesOnSides = 3;
int overDrawTilesAtTopAndBottom = 6;
int overDrawAdditionalTilesOnBottom = 10;
CalculateViewport(center, overDrawTilesOnSides, overDrawTilesAtTopAndBottom, out firstTile, out renderOffset, out renderDimensions);
CountEntitiesRendered = 0; // Count of objects rendered for statistics and debug
MouseOverList overList = new MouseOverList(mousePicking); // List of entities mouse is over.
List<AEntity> deferredToRemove = new List<AEntity>();
for (int y = 0; y < renderDimensions.Y * 2 + 1 + overDrawAdditionalTilesOnBottom; y++)
{
Vector3 drawPosition = new Vector3();
drawPosition.X = (firstTile.X - firstTile.Y + (y % 2)) * TILE_SIZE_FLOAT_HALF + renderOffset.X;
drawPosition.Y = (firstTile.X + firstTile.Y + y) * TILE_SIZE_FLOAT_HALF + renderOffset.Y;
Point firstTileInRow = new Point(firstTile.X + ((y + 1) / 2), firstTile.Y + (y / 2));
for (int x = 0; x < renderDimensions.X + 1; x++)
{
MapTile tile = map.GetMapTile(firstTileInRow.X - x, firstTileInRow.Y + x);
if (tile == null)
{
drawPosition.X -= TILE_SIZE_FLOAT;
continue;
}
List<AEntity> entities = tile.Entities;
bool draw = true;
for (int i = 0; i < entities.Count; i++)
{
if (entities[i] is DeferredEntity)
deferredToRemove.Add(entities[i]);
if (!m_DrawTerrain)
{
if ((entities[i] is Ground) || (entities[i].Z > tile.Ground.Z))
draw = false;
}
if ((entities[i].Z >= m_DrawMaxItemAltitude || (m_DrawMaxItemAltitude != 255 && entities[i] is Item && (entities[i] as Item).ItemData.IsRoof)) && !(entities[i] is Ground))
{
continue;
}
if (draw)
{
AEntityView view = entities[i].GetView();
if (view != null)
{
if (view.Draw(m_SpriteBatch, drawPosition, overList, map, !m_UnderSurface))
CountEntitiesRendered++;
}
}
}
foreach (AEntity deferred in deferredToRemove)
tile.OnExit(deferred);
deferredToRemove.Clear();
drawPosition.X -= TILE_SIZE_FLOAT;
}
}
OverheadsView.Render(m_SpriteBatch, overList, map, m_UnderSurface);
// Update the MouseOver objects
mousePicking.UpdateOverEntities(overList, mousePicking.Position);
// Draw the objects we just send to the spritebatch.
m_SpriteBatch.GraphicsDevice.SetRenderTarget(m_RenderTargetSprites);
m_SpriteBatch.GraphicsDevice.Clear(Color.Black);
m_SpriteBatch.FlushSprites(true);
m_SpriteBatch.GraphicsDevice.SetRenderTarget(null);
}
示例3: UnderSurfaceCheck
private bool UnderSurfaceCheck(Map map, int x, int y)
{
MapTile tile;
AEntity e0, e1;
if ((tile = map.GetMapTile(x, y)) != null)
{
if (tile == null)
return false;
if (tile.IsZUnderEntityOrGround(Entity.Position.Z, out e0, out e1))
{
if (e0 == null || !(e0 is Item))
return false;
Item item = e0 as Item;
if ((item.ItemData.IsRoof) || (item.ItemData.IsSurface) || (item.ItemData.IsWall && !item.ItemData.IsDoor))
return true;
}
}
return false;
}
示例4: updateSurroundingsAndNormals
private void updateSurroundingsAndNormals(Map map)
{
Point origin = new Point(Entity.Position.X, Entity.Position.Y);
float[] surroundingTilesZ = new float[kSurroundingsIndexes.Length];
for (int i = 0; i < kSurroundingsIndexes.Length; i++)
surroundingTilesZ[i] = map.GetTileZ(origin.X + kSurroundingsIndexes[i].X, origin.Y + kSurroundingsIndexes[i].Y);
m_SurroundingTiles = new Surroundings(
surroundingTilesZ[7], surroundingTilesZ[3], surroundingTilesZ[6]);
bool isFlat = m_SurroundingTiles.IsFlat && m_SurroundingTiles.East == Entity.Z;
if (!isFlat)
{
int low = 0, high = 0, sort = 0;
sort = map.GetAverageZ((int)Entity.Z, (int)m_SurroundingTiles.South, (int)m_SurroundingTiles.East, (int)m_SurroundingTiles.Down, ref low, ref high);
if (sort != SortZ)
{
SortZ = sort;
map.GetMapTile(Entity.Position.X, Entity.Position.Y).ForceSort();
}
}
m_Normals[0] = calculateNormal(
surroundingTilesZ[2], surroundingTilesZ[3],
surroundingTilesZ[0], surroundingTilesZ[6]);
m_Normals[1] = calculateNormal(
Entity.Z, surroundingTilesZ[4],
surroundingTilesZ[1], surroundingTilesZ[7]);
m_Normals[2] = calculateNormal(
surroundingTilesZ[5], surroundingTilesZ[7],
Entity.Z, surroundingTilesZ[9]);
m_Normals[3] = calculateNormal(
surroundingTilesZ[6], surroundingTilesZ[8],
surroundingTilesZ[3], surroundingTilesZ[10]);
updateVertexBuffer();
}
示例5: CheckDefer
// ======================================================================
// Deferred drawing code
// ======================================================================
protected void CheckDefer(Map map, Vector3 drawPosition)
{
MapTile deferToTile;
Direction checkDirection;
if (Entity is Mobile && ((Mobile)Entity).IsMoving)
{
Direction facing = (Entity as Mobile).DrawFacing;
if (
((facing & Direction.FacingMask) == Direction.Left) ||
((facing & Direction.FacingMask) == Direction.South) ||
((facing & Direction.FacingMask) == Direction.East))
{
deferToTile = map.GetMapTile(Entity.Position.X, Entity.Position.Y + 1);
checkDirection = facing & Direction.FacingMask;
}
else if ((facing & Direction.FacingMask) == Direction.Down)
{
deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y + 1);
checkDirection = Direction.Down;
}
else
{
deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y);
checkDirection = Direction.East;
}
}
else
{
deferToTile = map.GetMapTile(Entity.Position.X, Entity.Position.Y + 1);
checkDirection = Direction.South;
}
if (deferToTile != null)
{
if (Entity is Mobile)
{
Mobile mobile = Entity as Mobile;
// This calculates the z position of the mobile as if it had moved into the next tile.
// Strictly speaking, this isn't necessary, but looks nice for mobiles that are walking.
int z = MobileMovementCheck.GetNextZ(mobile, Entity.Position, checkDirection);
DeferredEntity deferred = new DeferredEntity(mobile, drawPosition, z);
deferToTile.OnEnter(deferred);
}
else
{
DeferredEntity deferred = new DeferredEntity(Entity, drawPosition, Entity.Z);
deferToTile.OnEnter(deferred);
}
}
}
示例6: getStartZ
private static void getStartZ(AEntity m, Map map, Position3D loc, List<Item> itemList, out int zLow, out int zTop)
{
int xCheck = (int)loc.X, yCheck = (int)loc.Y;
MapTile mapTile = map.GetMapTile(xCheck, yCheck);
if (mapTile == null)
{
zLow = int.MinValue;
zTop = int.MinValue;
}
bool landBlocks = mapTile.Ground.LandData.IsImpassible; //(TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0;
// if (landBlocks && m.CanSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0)
// landBlocks = false;
// else if (m.CantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0)
// landBlocks = true;
int landLow = 0, landCenter = 0, landTop = 0;
landCenter = map.GetAverageZ(xCheck, yCheck, ref landLow, ref landTop);
bool considerLand = !mapTile.Ground.IsIgnored;
int zCenter = zLow = zTop = 0;
bool isSet = false;
if (considerLand && !landBlocks && loc.Z >= landCenter)
{
zLow = landLow;
zCenter = landCenter;
if (!isSet || landTop > zTop)
zTop = landTop;
isSet = true;
}
StaticItem[] staticTiles = mapTile.GetStatics().ToArray();
for (int i = 0; i < staticTiles.Length; ++i)
{
StaticItem tile = staticTiles[i];
int calcTop = ((int)tile.Z + tile.ItemData.CalcHeight);
if ((!isSet || calcTop >= zCenter) && ((tile.ItemData.Flags & TileFlag.Surface) != 0) && loc.Z >= calcTop)
{
// || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)
// if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0)
// continue;
zLow = (int)tile.Z;
zCenter = calcTop;
int top = (int)tile.Z + tile.ItemData.Height;
if (!isSet || top > zTop)
zTop = top;
isSet = true;
}
}
for (int i = 0; i < itemList.Count; ++i)
{
Item item = itemList[i];
ItemData id = item.ItemData;
int calcTop = item.Z + id.CalcHeight;
if ((!isSet || calcTop >= zCenter) && ((id.Flags & TileFlag.Surface) != 0) && loc.Z >= calcTop)
{
// || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)
// if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0)
// continue;
zLow = item.Z;
zCenter = calcTop;
int top = item.Z + id.Height;
if (!isSet || top > zTop)
zTop = top;
isSet = true;
}
}
if (!isSet)
zLow = zTop = (int)loc.Z;
else if (loc.Z > zTop)
zTop = (int)loc.Z;
}
示例7: check
private static bool check(Map map, Mobile m, List<Item> items, int x, int y, int startTop, int startZ, out int newZ)
{
newZ = 0;
MapTile mapTile = map.GetMapTile(x, y);
if (mapTile == null)
return false;
StaticItem[] tiles = mapTile.GetStatics().ToArray();
bool landBlocks = (mapTile.Ground.LandData.Flags & TileFlag.Impassable) != 0;
bool considerLand = !mapTile.Ground.IsIgnored;
//if (landBlocks && canSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0) //Impassable, Can Swim, and Is water. Don't block it.
// landBlocks = false;
// else
// if (cantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0) //Can't walk and it's not water
// landBlocks = true;
int landLow = 0, landCenter = 0, landTop = 0;
landCenter = map.GetAverageZ(x, y, ref landLow, ref landTop);
bool moveIsOk = false;
int stepTop = startTop + StepHeight;
int checkTop = startZ + PersonHeight;
bool ignoreDoors = (!m.IsAlive || m.Body == 0x3DB);
#region Tiles
for (int i = 0; i < tiles.Length; ++i)
{
StaticItem tile = tiles[i];
if ((tile.ItemData.Flags & ImpassableSurface) == TileFlag.Surface) // || (canSwim && (flags & TileFlag.Wet) != 0) Surface && !Impassable
{
// if (cantWalk && (flags & TileFlag.Wet) == 0)
// continue;
int itemZ = (int)tile.Z;
int itemTop = itemZ;
int ourZ = itemZ + tile.ItemData.CalcHeight;
int ourTop = ourZ + PersonHeight;
int testTop = checkTop;
if (moveIsOk)
{
int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z);
if (cmp > 0 || (cmp == 0 && ourZ > newZ))
continue;
}
if (ourZ + PersonHeight > testTop)
testTop = ourZ + PersonHeight;
if (!tile.ItemData.IsBridge)
itemTop += tile.ItemData.Height;
if (stepTop >= itemTop)
{
int landCheck = itemZ;
if (tile.ItemData.Height >= StepHeight)
landCheck += StepHeight;
else
landCheck += tile.ItemData.Height;
if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landLow)
continue;
if (IsOk(ignoreDoors, ourZ, testTop, tiles, items))
{
newZ = ourZ;
moveIsOk = true;
}
}
}
}
#endregion
#region Items
for (int i = 0; i < items.Count; ++i)
{
Item item = items[i];
ItemData itemData = item.ItemData;
TileFlag flags = itemData.Flags;
if ((flags & ImpassableSurface) == TileFlag.Surface) // Surface && !Impassable && !Movable
{
// || (m.CanSwim && (flags & TileFlag.Wet) != 0))
// !item.Movable &&
// if (cantWalk && (flags & TileFlag.Wet) == 0)
// continue;
int itemZ = item.Z;
int itemTop = itemZ;
int ourZ = itemZ + itemData.CalcHeight;
int ourTop = ourZ + PersonHeight;
int testTop = checkTop;
//.........这里部分代码省略.........
示例8: CheckDefer
protected bool CheckDefer(Map map, Vector3 drawPosition)
{
MapTile deferToTile;
Direction checkDirection;
if (Entity is Mobile && ((Mobile)Entity).IsMoving)
{
Mobile mobile = Entity as Mobile;
if (
((mobile.Facing & Direction.FacingMask) == Direction.Left) ||
((mobile.Facing & Direction.FacingMask) == Direction.South) ||
((mobile.Facing & Direction.FacingMask) == Direction.East))
{
deferToTile = map.GetMapTile(Entity.Position.X, Entity.Position.Y + 1);
checkDirection = mobile.Facing & Direction.FacingMask;
}
else if ((mobile.Facing & Direction.FacingMask) == Direction.Down)
{
deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y + 1);
checkDirection = Direction.Down;
}
else
{
deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y);
checkDirection = Direction.East;
}
}
else
{
deferToTile = map.GetMapTile(Entity.Position.X + 1, Entity.Position.Y);
checkDirection = Direction.East;
}
if (deferToTile != null)
{
if (Entity is Mobile)
{
Mobile mobile = Entity as Mobile;
int z;
if (MobileMovementCheck.CheckMovementForced(mobile, Entity.Position, checkDirection, out z))
{
DeferredEntity deferred = new DeferredEntity(mobile, drawPosition, z);
deferToTile.OnEnter(deferred);
return true;
}
}
else
{
DeferredEntity deferred = new DeferredEntity(Entity, drawPosition, Entity.Z);
deferToTile.OnEnter(deferred);
return true;
}
}
return false;
}
示例9: InternalDrawEntities
private void InternalDrawEntities(Map map, Position3D center, MousePicking mousePicking, out Vector2 renderOffset)
{
if (center == null)
{
renderOffset = new Vector2();
return;
}
int renderDimensionY = 16; // the number of tiles that are drawn for half the screen (doubled to fill the entire screen).
int renderDimensionX = 18; // the number of tiles that are drawn in the x-direction ( + renderExtraColumnsAtSides * 2 ).
int renderExtraColumnsAtSides = 2; // the client draws additional tiles at the edge to make wide objects that are mostly offscreen visible.
// when the player entity is higher (z) in the world, we must offset the first row drawn. This variable MUST be a multiple of 2.
int renderZOffset = (center.Z / 14) * 2 + 4;
// this is used to draw tall objects that would otherwise not be visible until their ground tile was on screen. This may still skip VERY tall objects (those weird jungle trees?)
int renderExtraRowsAtBottom = renderZOffset + 10;
Point firstTile = new Point(
center.X + renderExtraColumnsAtSides - ((renderZOffset + 1) / 2),
center.Y - renderDimensionY - renderExtraColumnsAtSides - (renderZOffset / 2));
renderOffset.X = ((Settings.World.GumpResolution.Width + ((renderDimensionY) * TileSizeI)) / 2) - 22 + renderExtraColumnsAtSides * TileSizeI;
renderOffset.X -= (int)((center.X_offset - center.Y_offset) * 22);
renderOffset.X -= (firstTile.X - firstTile.Y) * 22;
renderOffset.Y = ((Settings.World.GumpResolution.Height - (renderDimensionY * TileSizeI)) / 2);
renderOffset.Y += (center.Z * 4) + (int)(center.Z_offset * 4);
renderOffset.Y -= (int)((center.X_offset + center.Y_offset) * 22);
renderOffset.Y -= (firstTile.X + firstTile.Y) * 22;
renderOffset.Y -= (renderZOffset) * 22;
ObjectsRendered = 0; // Count of objects rendered for statistics and debug
MouseOverList overList = new MouseOverList(mousePicking); // List of entities mouse is over.
List<AEntity> deferredToRemove = new List<AEntity>();
for (int col = 0; col < renderDimensionY * 2 + renderExtraRowsAtBottom; col++)
{
Vector3 drawPosition = new Vector3();
drawPosition.X = (firstTile.X - firstTile.Y + (col % 2)) * 22 + renderOffset.X;
drawPosition.Y = (firstTile.X + firstTile.Y + col) * 22 + renderOffset.Y;
Point index = new Point(firstTile.X + ((col + 1) / 2), firstTile.Y + (col / 2));
for (int row = 0; row < renderDimensionX + renderExtraColumnsAtSides * 2; row++)
{
MapTile tile = map.GetMapTile(index.X - row, index.Y + row);
if (tile == null)
continue;
List<AEntity> entities = tile.Entities;
for (int i = 0; i < entities.Count; i++)
{
if (!DrawTerrain)
{
if (entities[i] is Ground)
break;
else if (entities[i].Z > tile.Ground.Z)
break;
}
if (entities[i].Z >= m_maxItemAltitude && !(entities[i] is Ground))
continue;
AEntityView view = entities[i].GetView();
if (view != null)
if (view.Draw(m_spriteBatch, drawPosition, overList, map))
ObjectsRendered++;
if (entities[i] is DeferredEntity)
{
deferredToRemove.Add(entities[i]);
}
}
foreach (AEntity deferred in deferredToRemove)
tile.OnExit(deferred);
deferredToRemove.Clear();
drawPosition.X -= TileSizeF;
}
}
OverheadRenderer.Render(m_spriteBatch, overList, map);
// Update the MouseOver objects
mousePicking.UpdateOverEntities(overList, mousePicking.Position);
// Draw the objects we just send to the spritebatch.
m_spriteBatch.Flush(true);
}