本文整理汇总了C#中Server.Mobile.GetItemsInRange方法的典型用法代码示例。如果您正苦于以下问题:C# Mobile.GetItemsInRange方法的具体用法?C# Mobile.GetItemsInRange怎么用?C# Mobile.GetItemsInRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Mobile
的用法示例。
在下文中一共展示了Mobile.GetItemsInRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckProximity
public static bool CheckProximity( Mobile from, int range )
{
Map map = from.Map;
if ( map == null )
return false;
bool found = from.GetItemsInRange( range ).Where( i => CheckTile( i.ItemID ) ).Any();
for ( int x = -range; !found && x <= range; ++x )
{
for ( int y = -range; !found && y <= range; ++y )
{
Tile[] tiles = map.Tiles.GetStaticTiles( from.X + x, from.Y + y, true );
for ( int i = 0; !found && i < tiles.Length; ++i )
{
if ( CheckTile( tiles[i].ID & TileData.MaxItemValue ) )
found = true;
}
}
}
return found;
}
示例2: OnDoubleClick
public override void OnDoubleClick(Mobile from)
{
if ( RootParent == from || ( from.InRange( GetWorldLocation(), 3 ) && from.InLOS( GetWorldLocation() ) ) )
{
if ( !Unrolled )
{
Unroll();
MoveToWorld( from.Location, from.Map );
}
else if ( ItemID == 0x0A55 )
{
if ( Parent == null )
{
IPooledEnumerable eable = from.GetItemsInRange( 7 );
Campfire fire = null;
foreach ( Item item in eable )
{
if ( item is Campfire )
{
fire = (Campfire)item;
break;
}
}
eable.Free();
if ( fire != null )
{
if ( fire.CanLogout( from ) )
new BedRollLogoutMenu().SendTo( from.NetState );
else
from.SendAsciiMessage( "Your camp is not yet secure." );
}
else
{
Roll();
from.AddToBackpack( this );
}
}
else
{
// is in a container (not on ground)
Roll();
from.AddToBackpack( this );
}
}
}
else
{
from.SendAsciiMessage( "You must be closer to use that." );
}
}
示例3: CheckResponse
private static bool CheckResponse(Gump gump, Mobile m, int id)
{
if (m == null || !m.Player)
return true;
TownHouse th = null;
ArrayList list = new ArrayList();
foreach (Item item in m.GetItemsInRange(20))
if (item is TownHouse)
list.Add(item);
foreach (TownHouse t in list)
if (t.Owner == m)
{
th = t;
break;
}
if (th == null || th.ForSaleSign == null)
return true;
if (gump is HouseGumpAOS)
{
int val = id - 1;
if (val < 0)
return true;
int type = val % 15;
int index = val / 15;
if (th.ForSaleSign.ForcePublic && type == 3 && index == 12 && th.Public)
{
m.SendMessage("This house cannot be private.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.ForcePrivate && type == 3 && index == 13 && !th.Public)
{
m.SendMessage("This house cannot be public.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.NoTrade && type == 6 && index == 1)
{
m.SendMessage("This house cannot be traded.");
m.SendGump(gump);
return false;
}
}
else if (gump is HouseGump)
{
if (th.ForSaleSign.ForcePublic && id == 17 && th.Public)
{
m.SendMessage("This house cannot be private.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.ForcePrivate && id == 17 && !th.Public)
{
m.SendMessage("This house cannot be public.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.NoTrade && id == 14)
{
m.SendMessage("This house cannot be traded.");
m.SendGump(gump);
return false;
}
}
return true;
}
示例4: Give
public virtual bool Give( Mobile m, Item item, bool placeAtFeet )
{
if ( m.PlaceInBackpack( item ) )
return true;
if ( !placeAtFeet )
return false;
Map map = m.Map;
if ( map == null )
return false;
List<Item> atFeet = new List<Item>();
foreach ( Item obj in m.GetItemsInRange( 0 ) )
atFeet.Add( obj );
for ( int i = 0; i < atFeet.Count; ++i )
{
Item check = atFeet[i];
if ( check.StackWith( m, item, false ) )
return true;
}
item.MoveToWorld( m.Location, map );
return true;
}
示例5: Give
public override bool Give( Mobile m, Item item, bool placeAtFeet )
{
if ( m.Skills.Lumberjacking.Value >= 100 )
{
if ( Utility.RandomDouble() < 0.15 )
{
Item sitem = null;
int message = 0;
double chance = Utility.RandomDouble();
if ( chance < 0.0025 ) // not completely sure
{
sitem = new BrilliantAmber();
message = 1072551; // You found a brilliant amber!
}
else if ( chance < 0.05 )
{
sitem = new ParasiticPlant();
message = 1072549; // You found a parasitic plant!
}
else if ( chance < 0.35 )
{
if ( Utility.RandomBool() )
{
sitem = new SwitchItem();
message = 1072547; // You found a switch!
}
else
{
sitem = new LuminescentFungi();
message = 1072550; // You found a luminescent fungi!
}
}
else
{
sitem = new BarkFragment();
message = 1072548; // You found a bark fragment!
}
if ( !m.PlaceInBackpack( sitem ) )
{
if ( placeAtFeet )
{
List<Item> atFeet = new List<Item>();
foreach ( Item obj in m.GetItemsInRange( 0 ) )
atFeet.Add( obj );
for ( int i = 0; i < atFeet.Count; ++i )
{
Item check = atFeet[i];
if ( check.StackWith( m, sitem, false ) )
{
m.SendLocalizedMessage( message );
return base.Give( m, item, placeAtFeet );
}
}
sitem.MoveToWorld( m.Location, m.Map );
m.SendLocalizedMessage( message );
}
else
sitem.Delete();
}
else
m.SendLocalizedMessage( message );
}
}
return base.Give( m, item, placeAtFeet );
}
示例6: OnDoubleClick
public override void OnDoubleClick( Mobile from )
{
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1008155 ); // You peer into the heavens, seeking the moons...
from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Trammel, from.X, from.Y ), "", AffixType.Prepend, "Trammel : ", "" ) );
// Scriptiz : on ne joue pas sur felucca
//from.Send( new MessageLocalizedAffix( from.Serial, from.Body, MessageType.Regular, 0x3B2, 3, 1008146 + (int)Clock.GetMoonPhase( Map.Felucca, from.X, from.Y ), "", AffixType.Prepend, "Felucca : ", "" ) );
PlayerMobile player = from as PlayerMobile;
/* Scriptiz : Code pour repérer les autres bateaux (source : Alambik) */
// Get the maximum range the player can see
// A cartograph master with a tracking master experience lead to see to 125 tiles: A true captain!
int MinimumRange = 25; //Regular 800x600 screen + "normal" extra
int MaximumExtraRange = 100;
int ExtraRange = MaximumExtraRange *
((int)(from.Skills[SkillName.Cartography].Value) +
(int)(from.Skills[SkillName.Tracking].Value)) / 200;
int range = MinimumRange + ExtraRange;
foreach (Item item in from.GetItemsInRange(range))
{
if (item is BaseBoat)
{
// Player can see the boat
BaseBoat baseboat = (BaseBoat)item;
if (!(baseboat.Contains(from))) // On va éviter de répeter qu'on voit son propre bateau
{
/* Scriptiz : implémentation du tracking */
// If the player is good at tracking, let him track a mobile on the boat
if(from.Skills[SkillName.Tracking].Value * 2 >= from.GetDistanceToSqrt(baseboat.Location))
{
foreach (Mobile m in baseboat.GetMobilesInRange(15))
{
if (m == null) continue;
if (baseboat.Contains(m))
{
from.QuestArrow = new TrackArrow(from, m, range);
break;
}
}
}
// Get the name if not too far
string name = "un navire";
if (from.InRange(item.Location, MinimumRange + MaximumExtraRange / 5))
if (baseboat.ShipName != null)
name = "le" + baseboat.ShipName;
// Is it far?
string distance = "à l'horizon";
if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 1 / 5))
distance = "à côté";
else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 2 / 5))
distance = "proche";
else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 3 / 5))
distance = "loin";
else if (from.InRange(item.Location, MinimumRange + MaximumExtraRange * 4 / 5))
distance = "très loin";
// Get the relative direction of the seen boat
string direction;
// north/south
if (from.Y < baseboat.Y)
direction = "Sud";
else
direction = "Nord";
// east/west (Scriptiz : correction est <> ouest)
if (from.X < baseboat.X)
direction = direction + " Est";
else
direction = direction + " Ouest";
//Does the boat is moving?
string mobility = "est immobile";
if (baseboat.IsMoving)
{
mobility = "bouge vers ";
switch (baseboat.Moving)
{
case Direction.North: mobility += "le nord"; break;
case Direction.South: mobility += "le sud"; break;
case Direction.East: mobility += "l'est"; break;
case Direction.West: mobility += "l'ouest"; break;
case Direction.Up: mobility += "le nord-ouest"; break;
case Direction.Down: mobility += "le sud-est"; break;
case Direction.Left: mobility += "le sud-ouest"; break;
case Direction.Right: mobility += "le nord-est"; break;
default: break;
}
}
from.SendMessage("Vous voyez {0} au {1}. Il est {2} et {3}.", name, direction, distance, mobility);
}
}
}
/* Scriptiz : fin du code de Alambik */
if ( player != null )
{
//.........这里部分代码省略.........
示例7: IsNearType
public static bool IsNearType( Mobile mob, Type type, int range )
{
bool mobs = type.IsSubclassOf( typeof( Mobile ) );
bool items = type.IsSubclassOf( typeof( Item ) );
IPooledEnumerable eable;
if ( mobs )
eable = mob.GetMobilesInRange( range );
else if ( items )
eable = mob.GetItemsInRange( range );
else
return false;
foreach ( object obj in eable )
{
if ( type.IsAssignableFrom( obj.GetType() ) )
{
eable.Free();
return true;
}
}
eable.Free();
return false;
}
示例8: Give
//.........这里部分代码省略.........
if( m is PlayerMobile && pm.Feats.GetFeatLevel(FeatList.GemHarvesting) > 0 && pm.GemHarvesting && item is CopperOre && Utility.RandomMinMax( 1, 100 ) > 95 )
{
int roll = Utility.RandomMinMax( 1, 100 );
if (roll > 95 && pm.Feats.GetFeatLevel(FeatList.GemHarvesting) > 2)
item = new Cinnabar();
if( roll > 90 && pm.Feats.GetFeatLevel(FeatList.GemHarvesting) > 2)
item = new Diamond();
else if( roll > 80 && pm.Feats.GetFeatLevel(FeatList.GemHarvesting) > 2 )
item = new StarSapphire();
else if( roll > 70 && pm.Feats.GetFeatLevel(FeatList.GemHarvesting) > 1 )
item = new Ruby();
else if( roll > 59 && pm.Feats.GetFeatLevel(FeatList.GemHarvesting) > 1 )
item = new Emerald();
else if( roll > 48 && pm.Feats.GetFeatLevel(FeatList.GemHarvesting) > 1 )
item = new Sapphire();
else if( roll > 37 )
item = new Amethyst();
else if( roll > 20 )
item = new Tourmaline();
else
item = new Citrine();
}
string orename = "some copper ore";
if( item is TinOre )
orename = "some tin ore";
else if( item is IronOre )
orename = "some iron ore";
else if( item is ObsidianIngot )
orename = "some obsidian";
else if( item is SilverOre )
orename = "some silver ore";
else if( item is GoldOre )
orename = "some gold ore";
else if( item is Citrine )
orename = "a citrine";
else if( item is Tourmaline )
orename = "a tourmaline";
else if( item is Emerald )
orename = "an emerald";
else if( item is Amethyst )
orename = "an amethyst";
else if( item is Ruby )
orename = "a ruby";
else if( item is Sapphire )
orename = "a sapphire";
else if( item is StarSapphire )
orename = "a star sapphire";
else if( item is Diamond )
orename = "a diamond";
else if( item is Sand )
orename = "some sand";
else if( item is Coal )
orename = "some coal";
m.SendMessage( "You dig " + orename + " and put it in your backpack." );
if ( m.PlaceInBackpack( item ) )
return true;
if ( !placeAtFeet )
return false;
Map map = m.Map;
if ( map == null )
return false;
ArrayList atFeet = new ArrayList();
foreach ( Item obj in m.GetItemsInRange( 0 ) )
atFeet.Add( obj );
for ( int i = 0; i < atFeet.Count; ++i )
{
Item check = (Item)atFeet[i];
if ( check.StackWith( m, item, false ) )
return true;
}
item.MoveToWorld( m.Location, map );
return true;
}
示例9: Give
public virtual bool Give( Mobile m, Item item, bool placeAtFeet )
{
if ( m.PlaceInBackpack( item ) )
return true;
if ( !placeAtFeet )
return false;
Map map = m.Map;
if ( map == null )
return false;
ArrayList atFeet = new ArrayList();
IPooledEnumerable eable = m.GetItemsInRange( 0 );
foreach ( Item obj in eable)
atFeet.Add( obj );
eable.Free();
for ( int i = 0; i < atFeet.Count; ++i )
{
Item check = (Item)atFeet[i];
if ( check.StackWith( m, item, false ) )
return true;
}
item.MoveToWorld( m.Location, map );
return true;
}
示例10: CheckLighting
/// <summary>
/// Determines if the Mobile is in an area with too much lighting to hide.
/// </summary>
/// <param name="m">Mobile to check lighting for</param>
/// <returns>true if safe to hide, false otherwise</returns>
public static bool CheckLighting( Mobile m )
{
Scout sct = Perk.GetByType<Scout>((Player)m);
if (sct != null)
{
if (sct.HideInLight())
return true;
}
if( m.AccessLevel >= AccessLevel.Counselor )
return true;
bool safe = true;
foreach( Item i in m.GetItemsInRange(3) )
{
if( (i is BaseLight && ((BaseLight)i).Burning) && m.InLOS(i) )
{
safe = false;
break;
}
}
if( safe )
{
foreach( Mobile mob in m.GetMobilesInRange(3) )
{
if( !m.InLOS(mob) )
continue;
if( mob is IIlluminatingObject )
safe = false;
else
{
Item lightOH = mob.FindItemOnLayer(Layer.OneHanded);
Item lightTH = mob.FindItemOnLayer(Layer.TwoHanded);
if( lightOH != null )
{
if( lightOH is BaseLight && (lightOH as BaseLight).Burning )
safe = false;
else if( lightOH is IIlluminatingObject && (lightOH as IIlluminatingObject).IsIlluminating )
safe = false;
}
else if( lightTH != null )
{
if( lightTH is BaseLight && (lightTH as BaseLight).Burning )
safe = false;
else if( lightTH is IIlluminatingObject && (lightTH as IIlluminatingObject).IsIlluminating )
safe = false;
}
}
if( !safe )
break;
}
}
return safe;
}
示例11: Give
public override bool Give( Mobile m, Item item, bool placeAtFeet )
{
if ( m.Skills.Mining.Value >= 100 )
{
double chance = 0.005;
if ( m_OreAndStone.RaceBonus && m.Race == Race.Elf )
chance += chance * 0.5; // 50% bonus for elves?
if ( Utility.RandomDouble() < chance )
{
Item sitem = null;
int message = 0;
switch ( Utility.Random( 6 ) )
{
case 0:
sitem = new PerfectEmerald();
message = 1072566; // You have found a perfect emerald!
break;
case 1:
sitem = new DarkSapphire();
message = 1072567; // You have found a dark sapphire!
break;
case 2:
sitem = new Turquoise();
message = 1072568; // You have found a turquoise!
break;
case 3:
sitem = new EcruCitrine();
message = 1072570; // You have found an Ecru Citrine!
break;
case 4:
sitem = new FireRuby();
message = 1072564; // You have found a fire ruby!
break;
case 5:
sitem = new BlueDiamond();
message = 1072562; // You have found a flawless diamond!
break;
}
if ( sitem != null && !m.PlaceInBackpack( sitem ) && placeAtFeet )
{
List<Item> atFeet = new List<Item>();
foreach ( Item obj in m.GetItemsInRange( 0 ) )
atFeet.Add( obj );
for ( int i = 0; i < atFeet.Count; ++i )
{
Item check = atFeet[i];
if ( check.StackWith( m, sitem, false ) )
return base.Give( m, item, placeAtFeet );
}
sitem.MoveToWorld( m.Location, m.Map );
}
m.SendLocalizedMessage( message );
}
}
return base.Give( m, item, placeAtFeet );
}
示例12: Begin
public override bool Begin(Mobile from, BaseTool tool)
{
bool forge = false, anvil = false;
IPooledEnumerable eable = from.GetItemsInRange( 3 );
foreach ( Item item in eable )
{
if ( IsForge( item ) )
forge = true;
else if ( item.GetType().IsDefined( typeof( AnvilAttribute ), true ) || item.ItemID == 0xFB0 )
anvil = true;
}
eable.Free();
if ( anvil && forge )
{
if ( base.Begin( from, tool ) )
{
if ( ShowMenu( m_MainMenu ) )
{
return true;
}
else
{
End();
return false;
}
}
else
{
return false;
}
}
else if ( anvil && !forge )
{
from.SendAsciiMessage( "You are not near a forge." );
}
else if ( forge && !anvil )
{
from.SendAsciiMessage( "You are not near an anvil." );
}
else // !forge && !anvil
{
from.SendAsciiMessage( "You are not near a forge or an anvil." );
}
return false;
}
示例13: CheckResponse
private static bool CheckResponse(Gump gump, Mobile m, int id)
{
if (m == null || !m.Player)
{
return true;
}
var list = m.GetItemsInRange(20).OfType<TownHouse>().Cast<Item>().ToList();
TownHouse th = list.Cast<TownHouse>().FirstOrDefault(t => t != null && t.Owner == m);
if (th == null || th.ForSaleSign == null)
{
return true;
}
if (gump is HouseGumpAOS)
{
int val = id - 1;
if (val < 0)
{
return true;
}
int type = val%15;
int index = val/15;
if (th.ForSaleSign.ForcePublic && type == 3 && index == 12 && th.Public)
{
m.SendMessage("This house cannot be private.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.ForcePrivate && type == 3 && index == 13 && !th.Public)
{
m.SendMessage("This house cannot be public.");
m.SendGump(gump);
return false;
}
if (!th.ForSaleSign.NoTrade || type != 6 || index != 1)
{
return true;
}
m.SendMessage("This house cannot be traded.");
m.SendGump(gump);
return false;
}
if (!(gump is HouseGump))
{
return true;
}
if (th.ForSaleSign.ForcePublic && id == 17 && th.Public)
{
m.SendMessage("This house cannot be private.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.ForcePrivate && id == 17 && !th.Public)
{
m.SendMessage("This house cannot be public.");
m.SendGump(gump);
return false;
}
if (!th.ForSaleSign.NoTrade || id != 14)
{
return true;
}
m.SendMessage("This house cannot be traded.");
m.SendGump(gump);
return false;
}
示例14: DoScan
private static bool DoScan(Mobile m, GroundskeeperStatus al, ArrayList list)
{
al.LastScan = DateTime.Now;
TimeSpan threshold = new TimeSpan(0, 3, 0); // age of item on the ground before we care
int trash = 0;
foreach (Item item in m.GetItemsInRange(12)) // 12 tiles?
{ // is this trash? No LOS checks here because the manager won't be trying to pick it up
if (Groundskeeper.IgnoreFilter(item, threshold))
continue;
list.Add(item); // add it
}
// post process list to allow things like a couple marked runes
Groundskeeper.AllowFilter(list);
trash = list.Count; // total trash after removing allowed items
// Keep only representative items from different Zs by deleting all items except those with unique Zs
ArrayList temp = new ArrayList();
foreach (Item ix in list)
temp.Add(ix);
// only spawn 1 groundskeeper per Z plane and only when those Z planes are not within LOS.
// Example: a stack of scales will be on different Z panes, but within LOS (reachable by the same groundskeeper.)
foreach (Item ix in temp)
if (!DifferentZ(list, ix as Item))
list.Remove(ix);
// did the scan find enough trash to pick up?
// if someone drops a handful of stuff (< 5 items), ignore it
return trash > 5;
}
示例15: DisplayTo
public static void DisplayTo( Mobile from )
{
Map map = from.Map;
if ( map == null )
return;
int range = (int)(from.Skills[SkillName.HerbalLore].Base); // add feat levels here
ArrayList list = new ArrayList();
foreach ( Item m in from.GetItemsInRange( range ) )
{
if ( m is BasePlant )
list.Add( m );
}
if ( list.Count > 0 )
{
list.Sort( new InternalSorter( from ) );
from.SendGump( new TrackWhatGump( from, list, range ) );
from.SendLocalizedMessage( 1018093 ); // Select the one you would like to track.
}
else
from.SendMessage( "There are no plants in this area." );
}