本文整理汇总了C#中Map.GetItemsInBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Map.GetItemsInBounds方法的具体用法?C# Map.GetItemsInBounds怎么用?C# Map.GetItemsInBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.GetItemsInBounds方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPumpkin
private static void AddPumpkin( Map map )
{
for( int i = 0; i < m_PumpkinFields.Length; i++ )
{
Rectangle2D rect = m_PumpkinFields[ i ];
int spawncount = ( ( rect.Height * rect.Width ) / 20 );
int pumpkins = 0;
foreach( Item item in map.GetItemsInBounds( rect ) )
{
if( item is HalloweenPumpkin )
{
pumpkins++;
}
}
if( spawncount > pumpkins )
{
Item item = new HalloweenPumpkin();
item.MoveToWorld( RandomPointIn( rect, map ), map );
}
}
}
示例2: OnTarget
public void OnTarget( Mobile from, Map map, Point3D start, Point3D end, object state )
{
try
{
object[] states = (object[])state;
BaseCommand command = (BaseCommand)states[0];
string[] args = (string[])states[1];
Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
Extensions ext = Extensions.Parse( from, ref args );
bool items, mobiles;
if ( !CheckObjectTypes( command, ext, out items, out mobiles ) )
return;
IPooledEnumerable eable;
if ( items && mobiles )
eable = map.GetObjectsInBounds( rect );
else if ( items )
eable = map.GetItemsInBounds( rect );
else if ( mobiles )
eable = map.GetMobilesInBounds( rect );
else
return;
ArrayList objs = new ArrayList();
foreach ( object obj in eable )
{
if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
continue;
if ( ext.IsValid( obj ) )
objs.Add( obj );
}
eable.Free();
ext.Filter( objs );
RunCommand( from, objs, command, args );
}
catch ( Exception ex )
{
from.SendMessage( ex.Message );
}
}
示例3: DoWipe
public static void DoWipe(Mobile from, Map map, Point3D start, Point3D end, WipeType type)
{
CommandLogging.WriteLine(from, "{0} {1} wiping from {2} to {3} in {5} ({4})", from.AccessLevel, CommandLogging.Format(from), start, end, type, map);
bool mobiles = ((type & WipeType.Mobiles) != 0);
bool multis = ((type & WipeType.Multis) != 0);
bool items = ((type & WipeType.Items) != 0);
List<IEntity> toDelete = new List<IEntity>();
Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);
IPooledEnumerable eable;
if ((items || multis) && mobiles)
eable = map.GetObjectsInBounds(rect);
else if (items || multis)
eable = map.GetItemsInBounds(rect);
else if (mobiles)
eable = map.GetMobilesInBounds(rect);
else
return;
foreach (IEntity obj in eable)
{
if (items && (obj is Item) && !((obj is BaseMulti) || (obj is HouseSign)))
toDelete.Add(obj);
else if (multis && (obj is BaseMulti))
toDelete.Add(obj);
else if (mobiles && (obj is Mobile) && !((Mobile)obj).Player)
toDelete.Add(obj);
}
eable.Free();
for (int i = 0; i < toDelete.Count; ++i)
toDelete[i].Delete();
}
示例4: CanFit
public bool CanFit(Point3D p, Map map, int itemID)
{
if (map == null || map == Map.Internal || this.Deleted || this.CheckDecay())
return false;
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 || this.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 >= 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 is BaseMulti || item.ItemID > TileData.MaxItemValue || 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 (this.Contains(item))
continue;
eable.Free();
return false;
}
eable.Free();
return true;
}
示例5: DefineMultiArea_Callback
private static void DefineMultiArea_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
{
object[] multiargs = (object[])state;
if (from != null && multiargs != null && map != null)
{
string dirname = (string)multiargs[0];
int zmin = (int)multiargs[1];
int zmax = (int)multiargs[2];
bool includeitems = (bool)multiargs[3];
bool includestatics = (bool)multiargs[4];
bool includemultis = (bool)multiargs[5];
bool includeinvisible = (bool)multiargs[6];
bool includeaddons = (bool)multiargs[7];
ArrayList itemlist = new ArrayList();
ArrayList staticlist = new ArrayList();
ArrayList tilelist = new ArrayList();
int sx = (start.X > end.X) ? end.X : start.X;
int sy = (start.Y > end.Y) ? end.Y : start.Y;
int ex = (start.X < end.X) ? end.X : start.X;
int ey = (start.Y < end.Y) ? end.Y : start.Y;
// find all of the world-placed items within the specified area
if (includeitems)
{
// make the first pass for items only
IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(sx, sy, ex - sx + 1, ey - sy + 1));
foreach (Item item in eable)
{
// is it within the bounding area
if (item.Parent == null && (zmin == int.MinValue || (item.Location.Z >= zmin && item.Location.Z <= zmax)))
{
// add the item
if ((includeinvisible || item.Visible) && (item.ItemID <= 16383))
{
itemlist.Add(item);
}
}
}
eable.Free();
int searchrange = 100;
// make the second expanded pass to pick up addon components and multi components
eable = map.GetItemsInBounds(new Rectangle2D(sx - searchrange, sy - searchrange, ex - sy + searchrange * 2 + 1,
ey - sy + searchrange * 2 + 1));
foreach (Item item in eable)
{
// is it within the bounding area
if (item.Parent == null)
{
if (item is BaseAddon && includeaddons)
{
// go through all of the addon components
foreach (AddonComponent c in ((BaseAddon)item).Components)
{
int x = c.X;
int y = c.Y;
int z = c.Z;
if ((includeinvisible || item.Visible) && (item.ItemID <= 16383 || includemultis) &&
(x >= sx && x <= ex && y >= sy && y <= ey && (zmin == int.MinValue || (z >= zmin && z <= zmax))))
{
itemlist.Add(c);
}
}
}
if (item is BaseMulti && includemultis)
{
// go through all of the multi components
MultiComponentList mcl = ((BaseMulti)item).Components;
if (mcl != null && mcl.List != null)
{
for (int i = 0; i < mcl.List.Length; i++)
{
MultiTileEntry t = mcl.List[i];
int x = t.m_OffsetX + item.X;
int y = t.m_OffsetY + item.Y;
int z = t.m_OffsetZ + item.Z;
int itemID = t.m_ItemID & 0x3FFF;
if (x >= sx && x <= ex && y >= sy && y <= ey && (zmin == int.MinValue || (z >= zmin && z <= zmax)))
{
tilelist.Add(new TileEntry(itemID, x, y, z));
}
}
}
}
}
}
//.........这里部分代码省略.........
示例6: GETITEMSINBOUNDS
public static ArrayList GETITEMSINBOUNDS(TriggerObject trigObject, IPoint2D start, IPoint2D end, Map map)
{
if (start == null || end == null || map == null || map == Map.Internal)
{
return new ArrayList();
}
var enumerator = map.GetItemsInBounds(new Rectangle2D(start, end));
ArrayList output = new ArrayList(50);
foreach (Item nearby in enumerator)
{
output.Add(nearby);
}
enumerator.Free();
return output;
}
示例7: FinishEffect
protected virtual void FinishEffect( Point3D p, Map map, Mobile from )
{
from.RevealingAction();
int spawncount = GetSpawnCount();
int z = p.Z;
//Ghost ship Z, should be 10 lower than the spawn Z
int gsZ = z - 30; //Set to -30 so it spawns under the sea and then emerges up
//Spawn Z, needs to be 10 higher than ghost ship Z so they get on top of the boat
int spawnZ = z - 20;
//Create the ghost ship here
GhostShip gs = new GhostShip();
//Add treasure
MetalChest tc = new MetalChest {ItemID = 0xE7C, LiftOverride = true};
TreasureMapChest.Fill(tc, 5);
//Now declare an area the same size as the ship, to look for items that might block
Point2D start = new Point2D( p.X - 10, p.Y - 7 ); //Starting location of the area
Point2D end = new Point2D(p.X + 10, p.Y + 7); //Ending location of the area
Rectangle2D rect = new Rectangle2D( start, end ); //Declaring the entire area as a rectangle
//Create a new list that will contain all items in the rectangle
List<Item> list = new List<Item>();
IPooledEnumerable eable = map.GetItemsInBounds(rect); //Get all items in the rectangle
foreach (Item item in eable) //Add all items in the rectangle to the list
list.Add(item);
eable.Free();
//While an item exists in the rectangle, move the spawnlocation of the boat/monsters
while (list.Count > 0 )
{
if (Utility.RandomDouble() < 0.5 )
p.X += 1;
else
p.X -= 1;
if (Utility.RandomDouble() < 0.5)
p.Y += 1;
else
p.Y -= 1;
start = new Point2D(p.X - 10, p.Y - 7);
end = new Point2D(p.X + 10, p.Y + 7);
rect = new Rectangle2D(start, end);
eable = map.GetItemsInBounds(rect);
//Clear the list as we need to create a new one with the new location of the ship
list.Clear();
foreach (Item item in eable)
list.Add(item); //Add the items (if any) in the new spawnlocation to the list
eable.Free();
}
//No items blocking, move the ship to the world
p.Z = gsZ;
gs.MoveToWorld(p, map);
//Move the treasure chest to the world
p.Z = spawnZ + 2;
p.X -= 9;
tc.MoveToWorld(p, map);
//Add the boat and all items inside the boat here
gs.Itemlist.Add(gs);
gs.Itemlist.Add(tc);
//Add as many spawns as spawncount allows
for (int i = 0; i < spawncount; ++i)
{
BaseCreature spawn;
switch (Utility.Random(4))
{
default:
spawn = new LichLord();
break;
case 1:
spawn = new AncientLich();
break;
case 2:
spawn = new Lich();
break;
case 3:
spawn = new SkeletalCaptain();
break;
}
p.Z = spawnZ;
Spawn(p, map, spawn);
spawn.Combatant = from;
//.........这里部分代码省略.........
示例8: CreateBuilding
public static void CreateBuilding(Mobile from, Map map, Point3D start, Point3D end, object state)
{
DateTime started = DateTime.Now;
from.SendMessage("Building Creation Started:");
object[] objarr = (object[])state;
string name = (string)objarr[0];
bool scriptbased = (bool)objarr[1];
bool staticsonly = (bool)objarr[2];
end = new Point3D(end.X + 1, end.Y + 1, end.Z);
List<Item> staticlist = new List<Item>();
IPooledEnumerable itemlist = map.GetItemsInBounds(new Rectangle2D(start, end));
int lowx = end.X;
int lowy = end.Y;
int highx = start.X;
int highy = start.Y;
int lowz = 150;
foreach (Item item in itemlist)
{
if (!staticsonly || item is Static)
{
staticlist.Add(item);
lowx = Math.Min(lowx, item.Location.X);
lowy = Math.Min(lowy, item.Location.Y);
lowz = Math.Min(lowz, item.Location.Z);
highx = Math.Max(highx, item.Location.X);
highy = Math.Max(highy, item.Location.Y);
}
}
int totparts = 0;
if (staticlist.Count != 0)
{
lowz -= 51;// was 9
int totwidth = Math.Max(highx - lowx, 1);
int totheight = Math.Max(highy - lowy, 1);
int tothorparts = (int)Math.Ceiling((double)(totwidth / 18.0));
int totvertparts = (int)Math.Ceiling((double)(totheight / 19.0));
totparts = tothorparts * totvertparts;
MultiTileEntry[][][] dataarray = new MultiTileEntry[tothorparts][][];
bool[][] issmallarray = new bool[tothorparts][];
for (int i = 0; i < tothorparts; i++)
{
dataarray[i] = new MultiTileEntry[totvertparts][];
issmallarray[i] = new bool[totvertparts];
}
for (int i = 0; i < tothorparts; i++)
{
for (int j = 0; j < totvertparts; j++)
{
List<MultiTileEntry> partlist = new List<MultiTileEntry>();
int lowpartx = 100;
int lowparty = 100;
int highpartx = -100;
int highparty = -100;
int minx = lowx + (i * 18);
int miny = lowy + (j * 19);
int maxx = minx + 18;
int maxy = miny + 19;
int centerx = minx + 8;
int centery = miny + 8;
if (totwidth < 18 && totheight < 19)
{
centerx = minx + (totwidth / 2);
centery = miny + (totheight / 2);
}
foreach (Item stat in staticlist)
{
Point3D loc = stat.Location;
if (loc.X >= minx && loc.X < maxx && loc.Y >= miny && loc.Y < maxy)
{
short x = (short)(stat.X - centerx);
short y = (short)(stat.Y - centery);
short z = (short)(stat.Z - lowz);
partlist.Add(new MultiTileEntry((short)stat.ItemID, x, y, z, 1));
lowpartx = Math.Min(lowpartx, x);
lowparty = Math.Min(lowparty, y);
highpartx = Math.Max(highpartx, x);
highparty = Math.Max(highparty, y);
}
}
dataarray[i][j] = partlist.ToArray();
issmallarray[i][j] = ((highpartx - lowpartx) < 16) && ((highparty - lowparty) < 16);
}
}
itemlist.Free();
Point2D min = new Point2D(-8, -8);
//.........这里部分代码省略.........
示例9: ValidateNoCrop
public static bool ValidateNoCrop(Map map, int x, int y)
{
IPooledEnumerable<Item> items = map.GetItemsInBounds(new Rectangle2D(x, y, 1, 1));
foreach (Item i in items)
{
for (int index = 0; index < m_Table.Length; index++ )
{
if (m_Table[index].CropId == i.ItemID || m_Table[index].PlantId == i.ItemID)
return false;
}
}
return true;
}
示例10: ValidateGardenGround
public static bool ValidateGardenGround(Map map, int x, int y)
{
IPooledEnumerable<Item> items = map.GetItemsInBounds(new Rectangle2D(x, y, 1, 1));
foreach (Item i in items)
{
if (i.ItemID == 13001)
return true;
}
return false;
}