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


C# Map.GetAverageZ方法代码示例

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


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

示例1: FindGoldLocation

			private static Point3D FindGoldLocation(Map map, Point3D center, int range)
			{
				int cx = center.X;
				int cy = center.Y;

				for (int i = 0; i < 20; ++i)
				{
					int x = cx + Utility.Random(range * 2) - range;
					int y = cy + Utility.Random(range * 2) - range;
					if ((cx - x) * (cx - x) + (cy - y) * (cy - y) > range * range)
						continue;

					int z = map.GetAverageZ(x, y);
					if (!map.CanFit(x, y, z, 6, false, false))
						continue;

					int topZ = z;
					foreach (Item item in map.GetItemsInRange(new Point3D(x, y, z), 0))
					{
						topZ = Math.Max(topZ, item.Z + item.ItemData.CalcHeight);
					}
					return new Point3D(x, y, topZ);
				}
				return center;
			}
开发者ID:Crome696,项目名称:ServUO,代码行数:25,代码来源:GoldShower.cs

示例2: AddMarker

		private static void AddMarker(int x, int y, Map map, bool north)
		{
			int z = map.GetAverageZ(x, y);
			Item item = new Item(north ? 0x3975 : 0x3987);
			item.Visible = false;
			item.MoveToWorld(new Point3D(x, y, z), map);
			m_Markers.Add(item);
		}
开发者ID:Tukaramdas,项目名称:ServUO-EC-Test-Fork,代码行数:8,代码来源:TestRadiusCommand.cs

示例3: RandomPointIn

		private static Point3D RandomPointIn( Rectangle2D rect, Map map )
		{
			int x = Utility.Random( rect.X, rect.Width );
			int y = Utility.Random( rect.Y, rect.Height );
			int z = map.GetAverageZ( x, y );

			return new Point3D( x, y, z );
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:8,代码来源:PumpkinPatch.cs

示例4: LandTarget

		public LandTarget( Point3D location, Map map )
		{
			m_Location = location;

			if ( map != null )
			{
				m_Location.Z = map.GetAverageZ( m_Location.X, m_Location.Y );
				m_TileID = map.Tiles.GetLandTile( m_Location.X, m_Location.Y ).ID & TileData.MaxLandValue;
			}
		}
开发者ID:Grimoric,项目名称:RunUO.T2A,代码行数:10,代码来源:LandTarget.cs

示例5: CANFITMOB

			public static bool CANFITMOB(
				TriggerObject trigObj,
				int x,
				int y,
				int z,
				int height,
				bool checkBlocksFit,
				bool checkMobiles,
				bool requireSurface,
				Mobile mob,
				Map map)
			{
				if (map == null || map == Map.Internal)
				{
					return false;
				}

				if (x < 0 || y < 0 || x >= map.Width || y >= map.Height)
				{
					return false;
				}

				bool hasSurface = false;
				bool checkmob = false;
				bool canswim = false;
				bool cantwalk = false;

				if (mob != null)
				{
					checkmob = true;
					canswim = mob.CanSwim;
					cantwalk = mob.CantWalk;
				}

				LandTile lt = map.Tiles.GetLandTile(x, y);
				int lowZ = 0, avgZ = 0, topZ = 0;

				bool surface;
				bool wet;

				map.GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ);

				TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;
				bool impassable = (landFlags & TileFlag.Impassable) != 0;

				if (checkmob)
				{
					wet = (landFlags & TileFlag.Wet) != 0;

					// dont allow wateronly creatures on land
					if (cantwalk && !wet)
					{
						impassable = true;
					}

					// allow water creatures on water
					if (canswim && wet)
					{
						impassable = false;
					}
				}

				if (impassable && avgZ > z && (z + height) > lowZ)
				{
					return false;
				}

				if (!impassable && z == avgZ && !lt.Ignored)
				{
					hasSurface = true;
				}

				var staticTiles = map.Tiles.GetStaticTiles(x, y, true);

				foreach (StaticTile t in staticTiles)
				{
					ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue];
					surface = id.Surface;
					impassable = id.Impassable;

					if (checkmob)
					{
						wet = (id.Flags & TileFlag.Wet) != 0;

						// dont allow wateronly creatures on land
						if (cantwalk && !wet)
						{
							impassable = true;
						}

						// allow water creatures on water
						if (canswim && wet)
						{
							surface = true;
							impassable = false;
						}
					}

					if ((surface || impassable) && (t.Z + id.CalcHeight) > z && (z + height) > t.Z)
					{
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:101,代码来源:UberScriptFunctions.cs

示例6: GETVALIDSPAWNLOCATIONANDMAP

			public static Point3D GETVALIDSPAWNLOCATIONANDMAP(
				TriggerObject trigObject, Map map, int startX, int startY, int endX, int endY, int z, bool requiresurface)
			{
				if (map == null || map == Map.Internal)
				{
					return Point3D.Zero;
				}

				// --- from XmlSpawner2.cs GetSpawnPosition function ---
				// try to find a valid spawn location using the z coord of the spawner
				// relax the normal surface requirement for mobiles if the flag is set

				// try 10 times; this is a potential performance bottleneck
				for (int i = 0; i < 10; i++)
				{
					int x = Utility.RandomMinMax(startX, endX);
					int y = Utility.RandomMinMax(startY, endY);

					bool fit = requiresurface
								   ? CANFITMOB(trigObject, x, y, z, 16, false, true, true, null, map)
								   : CANFIT(trigObject, new Point2D(x, y));

					// if that fails then try to find a valid z coord
					if (fit)
					{
						return new Point3D(x, y, z);
					}

					z = map.GetAverageZ(x, y);

					fit = requiresurface
							  ? CANFITMOB(trigObject, x, y, z, 16, false, true, true, null, map)
							  : map.CanFit(x, y, z, 16, true, false, false);

					if (fit)
					{
						return new Point3D(x, y, z);
					}

					// check for a possible static surface that works
					var staticTiles = map.Tiles.GetStaticTiles(x, y, true);

					foreach (StaticTile tile in staticTiles)
					{
						ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];

						//int calcTop = (tile.Z + id.CalcHeight);

						if ((id.Flags & TileFlag.Surface) == 0)
						{
							continue;
						}

						int top = tile.Z + id.Height;

						fit = requiresurface
								  ? CANFITMOB(trigObject, x, y, top, 16, false, true, true, null, map)
								  : map.CanFit(x, y, top, 16, true, false, false);

						if (fit)
						{
							return new Point3D(x, y, top);
						}
					}
				}

				// unable to find a valid spot in 10 tries
				return Point3D.Zero;
			}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:69,代码来源:UberScriptFunctions.cs

示例7: GetStartZ

        private void GetStartZ(Mobile m, Map map, Point3D loc, List<Item> itemList, out int zLow, out int zTop)
        {
            int xCheck = loc.X, yCheck = loc.Y;

            LandTile landTile = map.Tiles.GetLandTile(xCheck, yCheck);
            int landZ = 0, landCenter = 0, landTop = 0;
            bool landBlocks = (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0;

            if (landBlocks && m.CanSwim && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0)
                landBlocks = false;
            else if (m.CantWalk && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) == 0)
                landBlocks = true;

            map.GetAverageZ(xCheck, yCheck, ref landZ, ref landCenter, ref landTop);

            bool considerLand = !landTile.Ignored;

            int zCenter = zLow = zTop = 0;
            bool isSet = false;

            if (considerLand && !landBlocks && loc.Z >= landCenter)
            {
                zLow = landZ;
                zCenter = landCenter;

                if (!isSet || landTop > zTop)
                    zTop = landTop;

                isSet = true;
            }

            StaticTile[] staticTiles = map.Tiles.GetStaticTiles(xCheck, yCheck, true);

            for (int i = 0; i < staticTiles.Length; ++i)
            {
                StaticTile tile = staticTiles[i];
                ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];

                int calcTop = (tile.Z + id.CalcHeight);

                if ((!isSet || calcTop >= zCenter) && ((id.Flags & TileFlag.Surface) != 0 || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)) && loc.Z >= calcTop)
                {
                    if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0)
                        continue;

                    zLow = tile.Z;
                    zCenter = calcTop;

                    int top = tile.Z + id.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 || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)) && loc.Z >= calcTop)
                {
                    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 = loc.Z;
            else if (loc.Z > zTop)
                zTop = loc.Z;
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:87,代码来源:Movement.cs

示例8: HasWaterAt

        private static bool HasWaterAt( Map map, IPoint2D p )
        {
            LandTile landTile = map.Tiles.GetLandTile( p.X, p.Y );
            StaticTile[] tiles = map.Tiles.GetStaticTiles( p.X, p.Y, true );

            bool hasWater = false;

            if ( landTile.Z == -5 && ((landTile.ID >= 168 && landTile.ID <= 171) || (landTile.ID >= 310 && landTile.ID <= 311)) )
                hasWater = true;
            int landZ = 0, landAvg = 0, landTop = 0;

            map.GetAverageZ( p.X, p.Y, ref landZ, ref landAvg, ref landTop );

            //if ( !landTile.Ignored && top > landZ && landTop > z )
            //	return false;

            for ( int i = 0; i < tiles.Length; ++i )
            {
                StaticTile tile = tiles[i];
                bool isWater = ( tile.ID >= 0x5796 && tile.ID <= 0x57B2 );

                if ( tile.Z == -5 && isWater )
                    hasWater = true;
                else if ( tile.Z >= -5 && !isWater )
                    return false;
            }

            return hasWater;
        }
开发者ID:FreeReign,项目名称:Rebirth-Repack,代码行数:29,代码来源:PredefSpawners.cs

示例9: Spawn

		public static BaseCreature Spawn( int level, Point3D p, Map map, Mobile target, bool guardian )
		{
			if ( map == null )
				return null;

			BaseCreature c = Spawn( level, p, guardian );

			if ( c != null )
			{
				bool spawned = false;

				for ( int i = 0; !spawned && i < 10; ++i )
				{
					int x = p.X - 3 + Utility.Random( 7 );
					int y = p.Y - 3 + Utility.Random( 7 );

					if ( map.CanSpawnMobile( x, y, p.Z ) )
					{
						c.MoveToWorld( new Point3D( x, y, p.Z ), map );
						spawned = true;
					}
					else
					{
						int z = map.GetAverageZ( x, y );

						if ( map.CanSpawnMobile( x, y, z ) )
						{
							c.MoveToWorld( new Point3D( x, y, z ), map );
							spawned = true;
						}
					}
				}

				if ( !spawned )
				{
					c.Delete();
					return null;
				}

				if ( target != null )
					c.Combatant = target;

				return c;
			}

			return null;
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:47,代码来源:TreasureMap.cs

示例10: GetStartZ

		private static void GetStartZ(Mobile m, Map map, Point3D loc, IEnumerable<Item> itemList, out int zLow, out int zTop)
		{
			int xCheck = loc.X, yCheck = loc.Y;

			var landTile = map.Tiles.GetLandTile(xCheck, yCheck);
			var landData = TileData.LandTable[landTile.ID & TileData.MaxLandValue];
			var landBlocks = (landData.Flags & TileFlag.Impassable) != 0;

			if (landBlocks && m.CanSwim && (landData.Flags & TileFlag.Wet) != 0)
			{
				landBlocks = false;
			}
			else if (m.CantWalk && (landData.Flags & TileFlag.Wet) == 0)
			{
				landBlocks = true;
			}

			int landZ = 0, landCenter = 0, landTop = 0;

			map.GetAverageZ(xCheck, yCheck, ref landZ, ref landCenter, ref landTop);

			var considerLand = !landTile.Ignored;

			var zCenter = zLow = zTop = 0;
			var isSet = false;

			if (considerLand && !landBlocks && loc.Z >= landCenter)
			{
				zLow = landZ;
				zCenter = landCenter;
				zTop = landTop;
				isSet = true;
			}

			var staticTiles = map.Tiles.GetStaticTiles(xCheck, yCheck, true);

			foreach (var tile in staticTiles)
			{
				var tileData = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
				var calcTop = (tile.Z + tileData.CalcHeight);

				if (isSet && calcTop < zCenter)
				{
					continue;
				}

				if ((tileData.Flags & TileFlag.Surface) == 0 && (!m.CanSwim || (tileData.Flags & TileFlag.Wet) == 0))
				{
					continue;
				}

				if (loc.Z < calcTop)
				{
					continue;
				}

				if (m.CantWalk && (tileData.Flags & TileFlag.Wet) == 0)
				{
					continue;
				}

				zLow = tile.Z;
				zCenter = calcTop;

				var top = tile.Z + tileData.Height;

				if (!isSet || top > zTop)
				{
					zTop = top;
				}

				isSet = true;
			}

			ItemData itemData;

			foreach (var item in itemList)
			{
				itemData = item.ItemData;

				var calcTop = item.Z + itemData.CalcHeight;

				if (isSet && calcTop < zCenter)
				{
					continue;
				}

				if ((itemData.Flags & TileFlag.Surface) == 0 && (!m.CanSwim || (itemData.Flags & TileFlag.Wet) == 0))
				{
					continue;
				}

				if (loc.Z < calcTop)
				{
					continue;
				}

				if (m.CantWalk && (itemData.Flags & TileFlag.Wet) == 0)
				{
					continue;
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:last-wish,代码行数:101,代码来源:FastMovement.cs

示例11: GetSpawnPosition

        public static Point3D GetSpawnPosition(Point3D from, Map map, int range)
        {
            if (map == null)
                return from;
				
            for (int i = 0; i < 10; i ++)
            {
                int x = from.X + Utility.Random(range);
                int y = from.Y + Utility.Random(range);
                int z = map.GetAverageZ(x, y);
				
                if (Utility.RandomBool())
                    x *= -1;
					
                if (Utility.RandomBool())
                    y *= -1;
					
                Point3D p = new Point3D(x, y, from.Z);
				
                if (map.CanSpawnMobile(p) && map.LineOfSight(from, p))
                    return p;
				
                p = new Point3D(x, y, z);
					
                if (map.CanSpawnMobile(p) && map.LineOfSight(from, p))
                    return p;
            }
			
            return from;
        }
开发者ID:m309,项目名称:ForkUO,代码行数:30,代码来源:BasePeerless.cs

示例12: updateSurroundingsAndNormals

        private void updateSurroundingsAndNormals(Map map)
        {
            Point origin = new Point(Position.X, 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 == Z;
            if (!isFlat)
            {
                int low = 0, high = 0, sort = 0;
                sort = map.GetAverageZ((int)Z, (int)m_surroundingTiles.South, (int)m_surroundingTiles.East, (int)m_surroundingTiles.Down, ref low, ref high);
                if (sort != SortZ)
                {
                    SortZ = sort;
                    map.GetMapTile(Position.X, Position.Y, false).Resort();
                }
            }

            m_normals[0] = calculateNormal_Old(
                surroundingTilesZ[2], surroundingTilesZ[3],
                surroundingTilesZ[0], surroundingTilesZ[6]);
            m_normals[1] = calculateNormal_Old(
                Z, surroundingTilesZ[4],
                surroundingTilesZ[1], surroundingTilesZ[7]);
            m_normals[2] = calculateNormal_Old(
                surroundingTilesZ[5], surroundingTilesZ[7],
                Z, surroundingTilesZ[9]);
            m_normals[3] = calculateNormal_Old(
                surroundingTilesZ[6], surroundingTilesZ[8],
                surroundingTilesZ[3], surroundingTilesZ[10]);

            updateVertexBuffer();
        }
开发者ID:FreeReign,项目名称:UltimaXNA,代码行数:38,代码来源:MapObjectGround.cs

示例13: HoldingCell

 public HoldingCell(int x, int y, Map map)
     : base("Cellule de détention", map, 100, new Rectangle2D(x - 1, y - 1, 4, 4)) 
 {
     GoLocation = new Point3D(x, y, map.GetAverageZ(x, y));
     this.Register();
 }
开发者ID:greeduomacro,项目名称:vivre-uo,代码行数:6,代码来源:JailRC1.cs

示例14: TryInitialise

        private void TryInitialise()
        {
            if (!this.m_initialised
                && this.Map != Map.Internal
                && this.Location != Point3D.Zero)
            {
                this.m_initialised = true;
                BaseHouse house = (BaseHouse.FindHouseAt((BaseAddon)this));
                m_House = house;
                n_Map = ((BaseAddon)this).Map;
                CellarDeed2 gt = (CellarDeed2)Deed;
                Point3D hsp = new Point3D(this.X, this.Y, this.Z);
                Sector s = n_Map.GetSector(hsp);
                int houseYOffset = this.Y - house.Y;
                int houseXOffset = this.X - house.X;
                int type = (int)gt.m_LandType;

                if (null != house.Area
                    && house.Area.Length > 0)
                {
                    //Find the minimum z value, so we can ensure it is all underground.
                    int minz = 150;
                    for (int i = 0; i < house.Area.Length; ++i)
                    {
                        Rectangle2D area = house.Area[i];
                        int width = area.Width;
                        int height = area.Height;
                        for (int rx = 0; rx < width; ++rx)
                        {
                            for (int ry = 0; ry < height; ++ry)
                            {
                                int vx = rx + area.X - houseXOffset;
                                int vy = ry + area.Y - houseYOffset;
                                minz = Math.Min(n_Map.GetAverageZ(vx, vy) - 40, minz);
                            }
                        }
                    }

                    minz = minz - this.Z;
                    //Place components
                    for (int i = 0; i < house.Area.Length; ++i)
                    {
                        Rectangle2D area = house.Area[i];
                        int width = area.Width;
                        int height = area.Height;
                        for (int rx = 0; rx < width; ++rx)
                        {
                            for (int ry = 0; ry < height; ++ry)
                            {
                                int vx = rx + area.X - houseXOffset;
                                int vy = ry + area.Y - houseYOffset;

                                AddComponent(new AddonComponent(type), vx, vy, minz);
                            }
                        }
                    }

                    this.m_topTeleporter.ZOffset = minz;
                    AddComponent(new CellarTeleporter4(-minz), 0, 0, minz);
                }
            }
        }
开发者ID:Tukaramdas,项目名称:ServUO-EC-Test-Fork,代码行数:62,代码来源:CellarAddon.cs

示例15: RandomPointOneAway

        public static Point3D RandomPointOneAway(int x, int y, int z, Map map)
        {
            Point3D loc = new Point3D(x + Utility.Random(-1, 3), y + Utility.Random(-1, 3), 0);

            loc.Z = (map.CanFit(loc, 0)) ? map.GetAverageZ(loc.X, loc.Y) : z;

            return loc;
        }
开发者ID:m309,项目名称:ForkUO,代码行数:8,代码来源:TrickOrTreat.cs


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