当前位置: 首页>>代码示例>>C#>>正文


C# Map.GetAverageZ方法代码示例

本文整理汇总了C#中UltimaXNA.Ultima.World.Maps.Map.GetAverageZ方法的典型用法代码示例。如果您正苦于以下问题:C# Map.GetAverageZ方法的具体用法?C# Map.GetAverageZ怎么用?C# Map.GetAverageZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UltimaXNA.Ultima.World.Maps.Map的用法示例。


在下文中一共展示了Map.GetAverageZ方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
		}
开发者ID:msx752,项目名称:UltimaXNA,代码行数:94,代码来源:MobileMovementCheck.cs

示例2: 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();
        }
开发者ID:msx752,项目名称:UltimaXNA,代码行数:40,代码来源:GroundView.cs

示例3: 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;
//.........这里部分代码省略.........
开发者ID:msx752,项目名称:UltimaXNA,代码行数:101,代码来源:MobileMovementCheck.cs


注:本文中的UltimaXNA.Ultima.World.Maps.Map.GetAverageZ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。