本文整理汇总了C#中Server.Map.GetAverageZ方法的典型用法代码示例。如果您正苦于以下问题:C# Map.GetAverageZ方法的具体用法?C# Map.GetAverageZ怎么用?C# Map.GetAverageZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Map
的用法示例。
在下文中一共展示了Map.GetAverageZ方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TreasureRegion
private const int Range = 5;// No house may be placed within 5 tiles of the treasure
public TreasureRegion(int x, int y, Map map)
: base(null, map, Region.DefaultPriority, new Rectangle2D(x - Range, y - Range, 1 + (Range * 2), 1 + (Range * 2)))
{
this.GoLocation = new Point3D(x, y, map.GetAverageZ(x, y));
this.Register();
}
示例2: CanFit
private static bool CanFit( Map map, int x, int y, int z )
{
bool hasSurface = false;
LandTile lt = map.Tiles.GetLandTile( x, y );
int lowZ = 0, avgZ = 0, topZ = 0;
map.GetAverageZ( x, y, ref lowZ, ref avgZ, ref topZ );
TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;
if ( (landFlags & TileFlag.Impassable) != 0 && topZ > z && (z + 16) > lowZ )
return false;
else if ( (landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored )
hasSurface = true;
StaticTile[] staticTiles = map.Tiles.GetStaticTiles( x, y );
bool surface, impassable;
for ( int i = 0; i < staticTiles.Length; ++i )
{
if ( IsDisplayCase( staticTiles[i].ID ) )
continue;
ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];
surface = id.Surface;
impassable = id.Impassable;
if ( (surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + 16) > staticTiles[i].Z )
return false;
else if ( surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight) )
hasSurface = true;
}
Sector sector = map.GetSector( x, y );
List<Item> items = sector.Items;
for ( int i = 0; i < items.Count; ++i )
{
Item item = items[i];
if ( item.AtWorldPoint( x, y ) )
{
ItemData id = item.ItemData;
surface = id.Surface;
impassable = id.Impassable;
if ( (surface || impassable) && (item.Z + id.CalcHeight) > z && (z + 16) > item.Z )
return false;
else if ( surface && !impassable && z == (item.Z + id.CalcHeight) )
hasSurface = true;
}
}
return hasSurface;
}
示例3: TreasureRegion
private const int Range = 5; // No house may be placed within 5 tiles of the treasure
public TreasureRegion( int x, int y, Map map ): base( "", "DynRegion", map )
{
Priority = Region.TownPriority;
LoadFromXml = false;
Coords = new ArrayList();
Coords.Add( new Rectangle2D( x - Range, y - Range, 1 + (Range * 2), 1 + (Range * 2) ) );
GoLocation = new Point3D( x, y, map.GetAverageZ( x, y ) );
}
示例4: ShowRectBounds
public static void ShowRectBounds( Rectangle2D r, Map m )
{
if( m == Map.Internal || m == null )
return;
Point3D p1 = new Point3D( r.X, r.Y - 1, 0 ); //So we dont' need to create a new one each point
Point3D p2 = new Point3D( r.X, r.Y + r.Height - 1, 0 ); //So we dont' need to create a new one each point
Effects.SendLocationEffect( new Point3D( r.X -1, r.Y - 1, m.GetAverageZ( r.X, r.Y -1 ) ) , m, 251, 75, 1, 1151, 3 ); //Top Corner //Testing color
for( int x = r.X; x <= ( r.X + r.Width -1 ); x++ )
{
p1.X = x;
p2.X = x;
p1.Z = m.GetAverageZ( p1.X, p1.Y );
p2.Z = m.GetAverageZ( p2.X, p2.Y );
Effects.SendLocationEffect( p1, m, 249, 75, 1, 1151, 3 ); //North bound
Effects.SendLocationEffect( p2, m, 249, 75, 1, 1151, 3 ); //South bound
}
p1 = new Point3D( r.X -1 , r.Y -1 , 0 );
p2 = new Point3D( r.X + r.Width - 1, r.Y, 0 );
for( int y = r.Y; y <= ( r.Y + r.Height -1 ); y++ )
{
p1.Y = y;
p2.Y = y;
p1.Z = m.GetAverageZ( p1.X, p1.Y );
p2.Z = m.GetAverageZ( p2.X, p2.Y );
Effects.SendLocationEffect( p1, m, 250, 75, 1, 1151, 3 ); //West Bound
Effects.SendLocationEffect( p2, m, 250, 75, 1, 1151, 3 ); //East Bound
}
}
示例5: GetSpawnerZ
public static int GetSpawnerZ( int x, int y, Map map )
{
int z = map.GetAverageZ( x, y );
if ( map.CanFit( x, y, z, 16, false, false ) )
return z;
for ( int i = 1; i <= 20; ++i )
{
if ( map.CanFit( x, y, z + i, 16, false, false ) )
return z + i;
if ( map.CanFit( x, y, z - i, 16, false, false ) )
return z - i;
}
return z;
}
示例6: HoverExploit
static void HoverExploit(Map map, int x, int y)
{
try
{
Point3D location = new Point3D(x, y, 0);
IPooledEnumerable eable = map.GetClientsInRange(location, 0);
Tile[] tiles = map.Tiles.GetStaticTiles(x, y, true);
foreach (NetState ns in eable)
{
if (ns == null || ns.Mobile == null) continue;
Mobile m = ns.Mobile;
if (map.CanSpawnMobile(m.Location, CanFitFlags.requireSurface) == false)
{
// Console.WriteLine("Bogus man!!");
//int averageZ = map.GetAverageZ(m.Location.X, m.Location.Y);
int averageZ = 0, topZ = 0, z = 0;
map.GetAverageZ(m.Location.X, m.Location.Y, ref z, ref averageZ, ref topZ);
while (m.Location.Z > averageZ && TileAtZ(tiles, m.Z) == false)
{ // drop the player down a notch
Point3D newLocation = new Point3D(m.Location);
newLocation.Z--;
m.MoveToWorld(newLocation, m.Map);
if (map.CanSpawnMobile(m.Location, CanFitFlags.requireSurface) == true)
break;
}
}
}
eable.Free();
}
catch (Exception ex)
{
// adam: stop logging this to the exception file as it's polluting it.
// we still need to fix it tho .. meh
Console.WriteLine(ex.ToString());
// EventSink.InvokeLogException(new LogExceptionEventArgs(ex));
}
return;
}
示例7: GetRandomLocation
public static Point2D GetRandomLocation( Map map )
{
for ( int i = 0; i < 30; ++i )
{
int tx = 0, ty = 0;
if ( map == Map.Trammel || map == Map.Felucca )
{
tx = Utility.RandomMinMax( 0, 4080 );
ty = Utility.RandomMinMax( 0, 5100 );
}
else if ( map == Map.Ilshenar )
{
tx = Utility.RandomMinMax( 220, 1770 );
ty = Utility.RandomMinMax( 200, 1415 );
}
else if ( map == Map.Malas )
{
tx = Utility.RandomMinMax( 600, 2150 );
ty = Utility.RandomMinMax( 70, 1910 );
}
else if ( map == Map.Tokuno )
{
tx = Utility.RandomMinMax( 90, 1410 );
ty = Utility.RandomMinMax( 20, 1400 );
}
else if ( map == Map.TerMur )
{
tx = Utility.RandomMinMax( 300, 1220 );
ty = Utility.RandomMinMax( 2800, 4050 );
}
// First, check for land tile to be valid, for most efficiency
if ( !IsValidLandTile( map, tx, ty ) )
continue;
var loc = new Point3D( tx, ty, map.GetAverageZ( tx, ty ) );
var region = Region.Find( loc, map );
if ( region.IsPartOf<GuardedRegion>() || region.IsPartOf<DungeonRegion>() || region.IsPartOf<HouseRegion>() )
continue;
if ( map.CanSpawnMobile( loc ) )
return new Point2D( tx, ty );
}
return Point2D.Zero;
}
示例8: ValidateLocation
private bool ValidateLocation(Point3D p, Map map)
{
if (!TreasureMap.ValidateLocation(p.X, p.Y, map))
return false;
for (int x = p.X - 1; x <= p.X + 1; x++)
{
for (int y = p.Y - 1; y <= p.Y + 1; y++)
{
if(TreasureMap.ValidateLocation(x, y, map))
{
int z = map.GetAverageZ(x, y);
IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, z), 0);
foreach (Item item in eable)
{
ItemData id = TileData.ItemTable[item.ItemID & TileData.MaxItemValue];
if (item.Z + id.CalcHeight >= z)
{
eable.Free();
return false;
}
}
eable.Free();
return true;
}
}
}
return false;
}
示例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;
}
示例10: Spawn
//25JUL2008 Lord_Greywolf fix for bad X *** START ***
// protected void Spawn( Point2D p, Map map, BaseCreature spawn )
// {
// if ( map == null )
// {
// spawn.Delete();
// return;
// }
// int x = p.X, y = p.Y;
//// for ( int j = 0; j < 5; ++j )
//// {
//// int tx = p.X - 2 + Utility.Random( 5 );
//// int ty = p.Y - 2 + Utility.Random( 5 );
//// }
// spawn.MoveToWorld( new Point3D( x, y, 0 ), map );
// spawn.PackItem( new TreasureMessageChest() );
//}
protected void Spawn(Point2D p, Map map, BaseCreature spawn)
{
if (map == null) { spawn.Delete(); return; }
int x = p.X, y = p.Y;
if (map.CanSpawnMobile(x, y, 0))
{
spawn.MoveToWorld(new Point3D(x, y, 0), map);
}
else
{
int z = map.GetAverageZ(x, y);
if (map.CanSpawnMobile(x, y, z))
{
spawn.MoveToWorld(new Point3D(x, y, z), map);
}
else if (map.CanSpawnMobile(x, y, z + 10))
{
spawn.MoveToWorld(new Point3D(x, y, z + 10), map);
}
else if (map.CanSpawnMobile(x + 1, y + 1, z))
{
spawn.MoveToWorld(new Point3D(x + 1, y + 1, z), map);
}
else if (map.CanSpawnMobile(x + 1, y + 1, z + 10))
{
spawn.MoveToWorld(new Point3D(x + 1, y + 1, z + 10), map);
}
else
{
spawn.MoveToWorld(new Point3D(x - 1, y - 1, 100), map);
}
}
spawn.PackItem(new TreasureMessageChest(Utility.RandomMinMax((((m_Level - 1) * 400) + 100), (((m_Level - 1) * 400) + 500))));
}
示例11: GetLine3D
/// <summary>
/// Gets a Point3D collection representing all locations between 'start' and 'end', including 'start' and 'end', on the given 'map'.
/// </summary>
public static Point3D[] GetLine3D(this IPoint3D start, IPoint3D end, Map map, bool avgZ = true)
{
var path = new List<Point3D>();
Geometry.Line2D(ToPoint3D(start), ToPoint3D(end), map, (p, m) => path.Add(p));
var arr = path.OrderBy(p => GetDistance(start, p)).ToArray();
arr.SetAll(
(i, p) =>
{
p.Z = avgZ ? map.GetAverageZ(p.X, p.Y) : start.Z + (int)Math.Floor((end.Z - start.Z) * (i / (double)path.Count));
return p;
});
path.Free(true);
return arr;
}
示例12: 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 );
if (HalloweenEventController.Instance != null && HalloweenEventController.Halloween && HalloweenCorruption.CheckCorrupt(c, new Point3D(x, y, p.Z), map))
c.IsCorrupt = true;
if (!c.IsCorrupt && Paragon.CheckConvert(c, new Point3D(x, y, p.Z), map))
c.IsParagon = true;
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 (HalloweenEventController.Instance != null && HalloweenEventController.Halloween && HalloweenCorruption.CheckCorrupt(c, new Point3D(x, y, z), map))
c.IsCorrupt = true;
if (!c.IsCorrupt && Paragon.CheckConvert(c, new Point3D(x, y, z), map))
c.IsParagon = true;
}
}
}
if ( !spawned )
{
c.Delete();
return null;
}
c.HomeMap = c.Map;
if ( target != null )
c.Combatant = target;
return c;
}
return null;
}
示例13: Check
private bool Check( Map map, Mobile m, List<Item> items, int x, int y, int startTop, int startZ, bool canSwim, bool cantWalk, out int newZ )
{
newZ = 0;
Tile[] tiles = map.Tiles.GetStaticTiles( x, y, true );
Tile landTile = map.Tiles.GetLandTile( x, y );
bool landBlocks = (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0;
bool considerLand = !landTile.Ignored;
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 landZ = 0, landCenter = 0, landTop = 0;
map.GetAverageZ( x, y, ref landZ, ref landCenter, ref landTop );
bool moveIsOk = false;
int stepTop = startTop + StepHeight;
int checkTop = startZ + PersonHeight;
bool ignoreDoors = ( m_AlwaysIgnoreDoors || !m.Alive || m.Body.BodyID == 0x3DB || m.IsDeadBondedPet );
bool ignoreSpellFields = m is PlayerMobile && map != Map.Felucca;
#region Tiles
for ( int i = 0; i < tiles.Length; ++i )
{
Tile tile = tiles[i];
#region SA
ItemData itemData = TileData.ItemTable[(tile.ID-0x4000) & 0x7FFF];
if ( m.Flying && ( itemData.Name == "hover over" ) )
{
newZ = tile.Z;
return true;
}
else if ( m is StygianDragon && map == Map.TerMur )
{
if ( x >= 307 && x <= 354 && y >= 126 && y <= 192 )
{
if ( tile.Z > newZ )
newZ = tile.Z;
moveIsOk = true;
}
else if ( x >= 42 && x <= 89 )
{
if ( (y >= 333 && y <= 399) || (y >= 531 && y <= 597) || (y >= 739 && y <= 805) )
{
if ( tile.Z > newZ )
newZ = tile.Z;
moveIsOk = true;
}
}
}
#endregion
TileFlag flags = itemData.Flags;
if ( (flags & ImpassableSurface) == TileFlag.Surface || (canSwim && (flags & TileFlag.Wet) != 0) ) // Surface && !Impassable
{
if ( cantWalk && (flags & TileFlag.Wet) == 0 )
continue;
int itemZ = tile.Z;
int itemTop = itemZ;
int ourZ = itemZ + 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 ( !itemData.Bridge )
itemTop += itemData.Height;
if ( stepTop >= itemTop )
{
int landCheck = itemZ;
if ( itemData.Height >= StepHeight )
landCheck += StepHeight;
else
landCheck += itemData.Height;
if ( considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ )
continue;
//.........这里部分代码省略.........
示例14: CanFit
public bool CanFit( Point3D p, Map map, int itemID )
{
if ( map == null || map == Map.Internal || Deleted || CheckDecay() )
return false;
MultiComponentList oldComponents = MultiData.GetComponents( ItemID );
MultiComponentList newComponents = MultiData.GetComponents( itemID );
for ( int x = 0; x < newComponents.Width; ++x )
{
for ( int y = 0; y < newComponents.Height; ++y )
{
int tx = p.X + newComponents.Min.X + x;
int ty = p.Y + newComponents.Min.Y + y;
if ( newComponents.Tiles[x][y].Length == 0 || Contains( tx, ty ) )
continue;
LandTile landTile = map.Tiles.GetLandTile( tx, ty );
StaticTile[] tiles = map.Tiles.GetStaticTiles( tx, ty, true );
bool hasWater = false;
if ( landTile.Z == p.Z && ((landTile.ID >= 168 && landTile.ID <= 171) || (landTile.ID >= 310 && landTile.ID <= 311)) )
hasWater = true;
int z = p.Z;
int landZ = 0, landAvg = 0, landTop = 0;
map.GetAverageZ( tx, ty, 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 ) || ( tile.ID >= 0x1796 && tile.ID <= 0x17B2 );
if ( tile.Z == p.Z && isWater )
hasWater = true;
else if ( tile.Z >= p.Z && !isWater )
return false;
}
if ( !hasWater )
return false;
}
}
IPooledEnumerable eable = map.GetItemsInBounds( new Rectangle2D( p.X + newComponents.Min.X, p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height ) );
foreach ( Item item in eable )
{
if ( item.ItemID >= 0x4000 || item.Z < p.Z || !item.Visible )
continue;
int x = item.X - p.X + newComponents.Min.X;
int y = item.Y - p.Y + newComponents.Min.Y;
if ( x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height && newComponents.Tiles[x][y].Length == 0 )
continue;
else if ( Contains( item ) )
continue;
eable.Free();
return false;
}
eable.Free();
return true;
}
示例15: GetSpawnPosition
public virtual Point3D GetSpawnPosition( ISpawnable spawned, Map map )
{
if ( map == null || map == Map.Internal )
return Location;
bool waterMob, waterOnlyMob;
if ( spawned is Mobile )
{
Mobile mob = (Mobile)spawned;
waterMob = mob.CanSwim;
waterOnlyMob = ( mob.CanSwim && mob.CantWalk );
}
else
{
waterMob = false;
waterOnlyMob = false;
}
// Try 10 times to find a Spawnable location.
for ( int i = 0; i < 10; i++ )
{
int x = Location.X + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange);
int y = Location.Y + (Utility.Random( (m_HomeRange * 2) + 1 ) - m_HomeRange);
int z = Map.GetAverageZ( x, y );
int mapZ = map.GetAverageZ( x, y );
if ( waterMob )
{
if ( IsValidWater( map, x, y, this.Z ) )
return new Point3D( x, y, this.Z );
else if ( IsValidWater( map, x, y, mapZ ) )
return new Point3D( x, y, mapZ );
}
if ( !waterOnlyMob )
{
if ( map.CanSpawnMobile( x, y, this.Z ) )
return new Point3D( x, y, this.Z );
else if ( map.CanSpawnMobile( x, y, mapZ ) )
return new Point3D( x, y, mapZ );
}
}
return this.Location;
}