本文整理汇总了C#中SpawnObject类的典型用法代码示例。如果您正苦于以下问题:C# SpawnObject类的具体用法?C# SpawnObject怎么用?C# SpawnObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpawnObject类属于命名空间,在下文中一共展示了SpawnObject类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ImportMegaSpawner
private static void ImportMegaSpawner( Mobile from, XmlElement node )
{
string name = GetText( node["Name"], "MegaSpawner" );
bool running = bool.Parse( GetText( node["Active"], "True" ) );
Point3D location = Point3D.Parse( GetText( node["Location"], "Error" ) );
Map map = Map.Parse( GetText( node["Map"], "Error" ) );
int team = 0;
bool group = false;
int maxcount = 0; // default maxcount of the spawner
int homeRange = 4; // default homerange
int spawnRange = 4; // default homerange
TimeSpan maxDelay = TimeSpan.FromMinutes( 10 );
TimeSpan minDelay = TimeSpan.FromMinutes( 5 );
XmlElement listnode = node["EntryLists"];
int nentries = 0;
SpawnObject[] so = null;
if( listnode != null )
{
// get the number of entries
if( listnode.HasAttributes )
{
XmlAttributeCollection attr = listnode.Attributes;
nentries = int.Parse( attr.GetNamedItem( "count" ).Value );
}
if( nentries > 0 )
{
so = new SpawnObject[nentries];
int entrycount = 0;
bool diff = false;
foreach( XmlElement entrynode in listnode.GetElementsByTagName( "EntryList" ) )
{
// go through each entry and add a spawn object for it
if( entrynode != null )
{
if( entrycount == 0 )
{
// get the spawner defaults from the first entry
// dont handle the individually specified entry attributes
group = bool.Parse( GetText( entrynode["GroupSpawn"], "False" ) );
maxDelay = TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MaxDelay"], "10:00" ) ) );
minDelay = TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MinDelay"], "05:00" ) ) );
homeRange = int.Parse( GetText( entrynode["WalkRange"], "10" ) );
spawnRange = int.Parse( GetText( entrynode["SpawnRange"], "4" ) );
}
else
{
// just check for consistency with other entries and report discrepancies
if( group != bool.Parse( GetText( entrynode["GroupSpawn"], "False" ) ) )
{
diff = true;
// log it
try
{
using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
{
op.WriteLine( "MSFimport : individual group entry difference: {0} vs {1}",
GetText( entrynode["GroupSpawn"], "False" ), group );
}
}
catch { }
}
if( minDelay != TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MinDelay"], "05:00" ) ) ) )
{
diff = true;
// log it
try
{
using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
{
op.WriteLine( "MSFimport : individual mindelay entry difference: {0} vs {1}",
GetText( entrynode["MinDelay"], "05:00" ), minDelay );
}
}
catch { }
}
if( maxDelay != TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MaxDelay"], "10:00" ) ) ) )
{
diff = true;
// log it
try
{
using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
{
op.WriteLine( "MSFimport : individual maxdelay entry difference: {0} vs {1}",
GetText( entrynode["MaxDelay"], "10:00" ), maxDelay );
}
}
catch { }
}
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:hubroot,代码行数:101,代码来源:XmlSpawner2.cs
示例2: XmlLoadFromStream
//.........这里部分代码省略.........
double SpawnTriggerProbability = 1;
try { SpawnTriggerProbability = double.Parse( (string)dr["TriggerProbability"] ); }
catch { }
int SpawnSequentialSpawning = -1;
try { SpawnSequentialSpawning = int.Parse( (string)dr["SequentialSpawning"] ); }
catch { }
string SpawnRegionName = null;
try { SpawnRegionName = (string)dr["RegionName"]; }
catch { }
string SpawnConfigFile = null;
try { SpawnConfigFile = (string)dr["ConfigFile"]; }
catch { }
bool SpawnAllowGhost = false;
try { SpawnAllowGhost = bool.Parse( (string)dr["AllowGhostTriggering"] ); }
catch { }
bool SpawnAllowNPC = false;
try { SpawnAllowNPC = bool.Parse( (string)dr["AllowNPCTriggering"] ); }
catch { }
bool SpawnSpawnOnTrigger = false;
try { SpawnSpawnOnTrigger = bool.Parse( (string)dr["SpawnOnTrigger"] ); }
catch { }
bool SpawnSmartSpawning = false;
try { SpawnSmartSpawning = bool.Parse( (string)dr["SmartSpawning"] ); }
catch { }
string SpawnObjectPropertyName = null;
try { SpawnObjectPropertyName = (string)dr["ObjectPropertyName"]; }
catch { }
// read in the object proximity target, this will be an object name, so have to do a search
// to find the item in the world. Also have to test for redundancy
string triggerObjectName = null;
try { triggerObjectName = (string)dr["ObjectPropertyItemName"]; }
catch { }
// read in the target for the set command, this will be an object name, so have to do a search
// to find the item in the world. Also have to test for redundancy
string setObjectName = null;
try { setObjectName = (string)dr["SetPropertyItemName"]; }
catch { }
// we will assign this during the self-reference resolution pass
Item SpawnSetPropertyItem = null;
// we will assign this during the self-reference resolution pass
Item SpawnObjectPropertyItem = null;
// read the duration parameter from the xml file
// but older files wont have it so deal with that condition and set it to the default of "0", i.e. infinite duration
// Try to get the "Duration" field, but in case it doesn't exist, catch and discard the exception
TimeSpan SpawnDuration = TimeSpan.FromMinutes( 0 );
try { SpawnDuration = TimeSpan.FromMinutes( double.Parse( (string)dr["Duration"] ) ); }
catch { }
TimeSpan SpawnDespawnTime = TimeSpan.FromHours( 0 );
try { SpawnDespawnTime = TimeSpan.FromHours( double.Parse( (string)dr["DespawnTime"] ) ); }
catch { }
int SpawnProximityRange = -1;
开发者ID:greeduomacro,项目名称:hubroot,代码行数:67,代码来源:XmlSpawner2.cs
示例3: ParseOldMapFormat
//.........这里部分代码省略.........
{
case 0:
spawnmap = Map.Felucca;
// note it also does trammel
break;
case 1:
spawnmap = Map.Felucca;
break;
case 2:
spawnmap = Map.Trammel;
break;
case 3:
spawnmap = Map.Ilshenar;
break;
case 4:
spawnmap = Map.Malas;
break;
case 5:
spawnmap = Map.Tokuno;
break;
}
if( !IsValidMapLocation( x, y, spawnmap ) )
{
// invalid so dont spawn it
badspawnercount++;
from.SendMessage( "Invalid map/location at line {0}", linenumber );
from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
return;
}
// allow it to make an xmlspawner instead
// first add all of the creatures on the list
SpawnObject[] so = new SpawnObject[typenames.Length];
bool hasvendor = true;
for( int i = 0; i < typenames.Length; i++ )
{
so[i] = new SpawnObject( typenames[i], maxcount );
// check the type to see if there are vendors on it
Type type = SpawnerType.GetType( typenames[i] );
// check for vendor-only spawners which get special spawnrange treatment
if( type != null && (type != typeof( BaseVendor ) && !type.IsSubclassOf( typeof( BaseVendor ) )) )
{
hasvendor = false;
}
}
// assign it a unique id
Guid SpawnId = Guid.NewGuid();
// and give it a name based on the spawner count and file
string spawnername = String.Format( "{0}#{1}", Path.GetFileNameWithoutExtension( filename ), spawnercount );
// Create the new xml spawner
XmlSpawner spawner = new XmlSpawner( SpawnId, x, y, 0, 0, spawnername, maxcount,
TimeSpan.FromMinutes( mindelay ), TimeSpan.FromMinutes( maxdelay ), TimeSpan.FromMinutes( 0 ), -1, defaultTriggerSound, 1,
0, homerange, false, so, TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ),
TimeSpan.FromMinutes( 0 ), null, null, null, null, null,
null, null, null, null, 1, null, false, defTODMode, defKillReset, false, -1, null, false, false, false, null,
TimeSpan.FromHours( 0 ), null, false, null );
if( hasvendor )
开发者ID:greeduomacro,项目名称:hubroot,代码行数:67,代码来源:XmlSpawner2.cs
示例4: ImportSpawner
private static void ImportSpawner( XmlElement node, Mobile from )
{
int count = int.Parse( GetText( node["count"], "1" ) );
int homeRange = int.Parse( GetText( node["homerange"], "4" ) );
int walkingRange = int.Parse( GetText( node["walkingrange"], "-1" ) );
// width of the spawning area
int spawnwidth = homeRange * 2;
if( walkingRange >= 0 ) spawnwidth = walkingRange * 2;
int team = int.Parse( GetText( node["team"], "0" ) );
bool group = bool.Parse( GetText( node["group"], "False" ) );
TimeSpan maxDelay = TimeSpan.Parse( GetText( node["maxdelay"], "10:00" ) );
TimeSpan minDelay = TimeSpan.Parse( GetText( node["mindelay"], "05:00" ) );
ArrayList creaturesName = LoadCreaturesName( node["creaturesname"] );
string name = GetText( node["name"], "Spawner" );
Point3D location = Point3D.Parse( GetText( node["location"], "Error" ) );
Map map = Map.Parse( GetText( node["map"], "Error" ) );
// allow it to make an xmlspawner instead
// first add all of the creatures on the list
SpawnObject[] so = new SpawnObject[creaturesName.Count];
bool hasvendor = false;
for( int i = 0; i < creaturesName.Count; i++ )
{
so[i] = new SpawnObject( (string)creaturesName[i], count );
// check the type to see if there are vendors on it
Type type = SpawnerType.GetType( (string)creaturesName[i] );
// if it has basevendors on it or invalid types, then skip it
if( type != null && (type == typeof( BaseVendor ) || type.IsSubclassOf( typeof( BaseVendor ) )) )
{
hasvendor = true;
}
}
// assign it a unique id
Guid SpawnId = Guid.NewGuid();
// Create the new xml spawner
XmlSpawner spawner = new XmlSpawner( SpawnId, location.X, location.Y, spawnwidth, spawnwidth, name, count,
minDelay, maxDelay, TimeSpan.FromMinutes( 0 ), -1, defaultTriggerSound, 1,
team, homeRange, false, so, TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ),
TimeSpan.FromMinutes( 0 ), null, null, null, null, null,
null, null, null, null, 1, null, group, defTODMode, defKillReset, false, -1, null, false, false, false, null, defDespawnTime, null, false, null );
if( hasvendor )
{
spawner.SpawnRange = 0;
}
else
{
spawner.SpawnRange = homeRange;
}
spawner.m_PlayerCreated = true;
string fromname = null;
if( from != null ) fromname = from.Name;
spawner.LastModifiedBy = fromname;
spawner.FirstModifiedBy = fromname;
spawner.MoveToWorld( location, map );
if( !IsValidMapLocation( location, spawner.Map ) )
{
spawner.Delete();
throw new Exception( "Invalid spawner location." );
}
}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:68,代码来源:XmlSpawner2.cs
示例5: configGamePlayer
public void configGamePlayer(PlayerClassType playerClassCongfig, int playerRefID, string playerName, SpawnObject spawn)
{
this.playerRefID = playerRefID;
playerClass = playerClassCongfig.playerClass;
if (this.playerClass == PlayerClassType.ClassList.GAME_MASTER)
{
GameSessionManager gameManager = this.gameObject.GetComponent<GameSessionManager>();
gameManager.scriptEnabled = true;
}
else
{
SpaceshipController spaceshipController = this.GetComponent<SpaceshipController>();
HealthSystem spaceshipHealth = this.GetComponent<HealthSystem>();
StealSystem spaceshipSteal = this.GetComponent<StealSystem>();
CombatSystem spaceshipCombat = this.GetComponent<CombatSystem>();
AbilitySystem abilitySystem = this.GetComponent<AbilitySystem>();
spaceshipController.PlayerName = playerName;
spaceshipController.playerRefID = playerRefID;
spaceshipController.scriptEnabled = true;
spaceshipController.spriteName = playerClassCongfig.shipSprite.name;
spaceshipController.transformScale = playerClassCongfig.transformScale;
spaceshipController.colliderSize = playerClassCongfig.colliderSize;
abilitySystem.config = playerClass;
Debug.Log (spawn.location);
spaceshipHealth.respawnLocation = spawn.location;
spaceshipHealth.respawnRotation = spawn.rotation;
spaceshipSteal.playerRefID = this.playerRefID;
spaceshipSteal.playerName = playerName;
if (spawnGamePrefabs) {
if (planetPrefab != null && satellitePrefab != null && basePrefab != null)
{
planetReference = (GameObject)Instantiate(planetPrefab,
transform.position + playerClassCongfig.planetOffset,
transform.rotation);
NetworkServer.Spawn(planetReference);
SatelliteController satelliteControl = satellitePrefab.GetComponent<SatelliteController>();
HealthSystem satelliteHealth = satellitePrefab.GetComponent<HealthSystem>();
satelliteControl.orbitCentre = planetReference.transform.position;
satelliteControl.playerRefID = this.playerRefID;
satelliteHealth.respawnLocation = planetReference.transform.position + new Vector3(0,-satelliteControl.orbitRadius,0);
satelliteReference = (GameObject)Instantiate(satellitePrefab,
planetReference.transform.position,
transform.rotation);
NetworkServer.Spawn(satelliteReference);
StealSystem baseSteal = basePrefab.GetComponent<StealSystem>();
baseSteal.playerRefID = this.playerRefID;
baseReference = (GameObject)Instantiate(basePrefab,
planetReference.transform.position + playerClassCongfig.baseOffset,
transform.rotation);
NetworkServer.Spawn(baseReference);
}
}
}
}
开发者ID:RoryCharlton,项目名称:DECO3801-2015-sem-2,代码行数:61,代码来源:PlayerMasterScript.cs
示例6: LoadXmlConfig
//.........这里部分代码省略.........
}
valid_entry = true;
try { strEntry = (string)dr["MobTriggerName"]; }
catch { valid_entry = false; }
if( valid_entry )
{
m_MobTriggerName = strEntry;
}
valid_entry = true;
try { strEntry = (string)dr["ObjectPropertyName"]; }
catch { valid_entry = false; }
if( valid_entry )
{
m_ObjectPropertyName = strEntry;
}
valid_entry = true;
try { strEntry = (string)dr["ObjectPropertyItemName"]; }
catch { valid_entry = false; }
if( valid_entry )
{
string[] typeargs = strEntry.Split( ",".ToCharArray(), 2 );
string typestr = null;
string namestr = strEntry;
if( typeargs.Length > 1 )
{
namestr = typeargs[0];
typestr = typeargs[1];
}
m_ObjectPropertyItem = BaseXmlSpawner.FindItemByName( this, namestr, typestr );
}
valid_entry = true;
try { strEntry = (string)dr["SetPropertyItemName"]; }
catch { valid_entry = false; }
if( valid_entry )
{
string[] typeargs = strEntry.Split( ",".ToCharArray(), 2 );
string typestr = null;
string namestr = strEntry;
if( typeargs.Length > 1 )
{
namestr = typeargs[0];
typestr = typeargs[1];
}
m_SetPropertyItem = BaseXmlSpawner.FindItemByName( this, namestr, typestr );
}
valid_entry = true;
try { strEntry = (string)dr["Name"]; }
catch { valid_entry = false; }
if( valid_entry ) { Name = strEntry; }
valid_entry = true;
try { strEntry = (string)dr["Map"]; }
catch { valid_entry = false; }
if( valid_entry )
{
// Convert the xml map value to a real map object
try
{
Map = Map.Parse( strEntry );
}
catch { }
}
// try loading the new spawn specifications first
SpawnObject[] Spawns = new SpawnObject[0];
bool havenew = true;
valid_entry = true;
try { Spawns = SpawnObject.LoadSpawnObjectsFromString2( (string)dr["Objects2"] ); }
catch { havenew = false; }
if( !havenew )
{
// try loading the new spawn specifications
try { Spawns = SpawnObject.LoadSpawnObjectsFromString( (string)dr["Objects"] ); }
catch { valid_entry = false; }
// can only have one of these defined
}
if( valid_entry )
{
// clear existing spawns
RemoveSpawnObjects();
// Create the new array of spawned objects
m_SpawnObjects = new ArrayList();
// Assign the list of objects to spawn
SpawnObjects = Spawns;
}
}
}
}
}
}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:101,代码来源:XmlSpawner2.cs
示例7: Deserialize
//.........这里部分代码省略.........
{
m_Name = reader.ReadString();
// backward compatibility with old name storage
if( m_Name != null && m_Name != String.Empty ) Name = m_Name;
m_X = reader.ReadInt();
m_Y = reader.ReadInt();
m_Width = reader.ReadInt();
m_Height = reader.ReadInt();
if( m_Width == m_Height )
m_SpawnRange = m_Width / 2;
else
m_SpawnRange = -1;
if( !haveproximityrange )
{
m_ProximityRange = -1;
}
m_WayPoint = reader.ReadItem() as WayPoint;
m_Group = reader.ReadBool();
m_MinDelay = reader.ReadTimeSpan();
m_MaxDelay = reader.ReadTimeSpan();
m_Count = reader.ReadInt();
m_Team = reader.ReadInt();
m_HomeRange = reader.ReadInt();
m_Running = reader.ReadBool();
if( m_Running == true )
{
TimeSpan delay = reader.ReadTimeSpan();
DoTimer( delay );
}
// Read in the size of the spawn object list
int SpawnListSize = reader.ReadInt();
m_SpawnObjects = new ArrayList( SpawnListSize );
for( int i = 0; i < SpawnListSize; ++i )
{
string TypeName = reader.ReadString();
int TypeMaxCount = reader.ReadInt();
SpawnObject TheSpawnObject = new SpawnObject( TypeName, TypeMaxCount );
m_SpawnObjects.Add( TheSpawnObject );
string typeName = BaseXmlSpawner.ParseObjectType( TypeName );
// does it have a substitution that might change its validity?
// if so then let it go
if( typeName == null || ((SpawnerType.GetType( typeName ) == null) &&
(!BaseXmlSpawner.IsTypeOrItemKeyword( typeName ) && typeName.IndexOf( '{' ) == -1 && !typeName.StartsWith( "*" ) && !typeName.StartsWith( "#" ))) )
{
if( m_WarnTimer == null )
m_WarnTimer = new WarnTimer2();
m_WarnTimer.Add( Location, Map, TypeName );
this.status_str = "invalid type: " + typeName;
}
// Read in the number of spawns already
int SpawnedCount = reader.ReadInt();
TheSpawnObject.SpawnedObjects = new ArrayList( SpawnedCount );
for( int x = 0; x < SpawnedCount; ++x )
{
int serial = reader.ReadInt();
开发者ID:greeduomacro,项目名称:hubroot,代码行数:67,代码来源:XmlSpawner2.cs
示例8: InitSpawn
public void InitSpawn( int x, int y, int width, int height, string name, int maxCount, TimeSpan minDelay, TimeSpan maxDelay, TimeSpan duration,
int proximityRange, int proximityTriggerSound, int amount, int team, int homeRange, bool isRelativeHomeRange, SpawnObject[] objectsToSpawn,
TimeSpan minRefractory, TimeSpan maxRefractory, TimeSpan todstart, TimeSpan todend, Item objectPropertyItem, string objectPropertyName, string proximityMessage,
string itemTriggerName, string noitemTriggerName, string speechTrigger, string mobTriggerName, string mobPropertyName, string playerPropertyName, double triggerProbability,
Item setPropertyItem, bool isGroup, TODModeType todMode, int killReset, bool externalTriggering, int sequentialSpawning, string regionName, bool allowghost, bool allownpc, bool spawnontrigger,
string configfile, TimeSpan despawnTime, string skillTrigger, bool smartSpawning, WayPoint wayPoint )
{
Visible = false;
Movable = false;
m_X = x;
m_Y = y;
m_Width = width;
m_Height = height;
// init spawn range if compatible
if( width == height )
m_SpawnRange = width / 2;
else
m_SpawnRange = -1;
m_Running = true;
m_Group = isGroup;
if( (name != null) && (name.Length > 0) )
Name = name;
else
Name = "Spawner";
m_MinDelay = minDelay;
m_MaxDelay = maxDelay;
// duration and proximity range parameter
m_MinRefractory = minRefractory;
m_MaxRefractory = maxRefractory;
m_TODStart = todstart;
m_TODEnd = todend;
m_TODMode = todMode;
m_KillReset = killReset;
m_Duration = duration;
m_DespawnTime = despawnTime;
m_ProximityRange = proximityRange;
m_ProximityTriggerSound = proximityTriggerSound;
m_proximityActivated = false;
m_durActivated = false;
m_refractActivated = false;
m_Count = maxCount;
m_Team = team;
m_StackAmount = amount;
m_HomeRange = homeRange;
m_HomeRangeIsRelative = isRelativeHomeRange;
m_ObjectPropertyItem = objectPropertyItem;
m_ObjectPropertyName = objectPropertyName;
m_ProximityTriggerMessage = proximityMessage;
m_ItemTriggerName = itemTriggerName;
m_NoItemTriggerName = noitemTriggerName;
m_SpeechTrigger = speechTrigger;
SkillTrigger = skillTrigger; // note this will register the skill as well
m_MobTriggerName = mobTriggerName;
m_MobPropertyName = mobPropertyName;
m_PlayerPropertyName = playerPropertyName;
m_TriggerProbability = triggerProbability;
m_SetPropertyItem = setPropertyItem;
m_ExternalTriggering = externalTriggering;
m_ExternalTrigger = false;
m_SequentialSpawning = sequentialSpawning;
RegionName = regionName;
m_AllowGhostTriggering = allowghost;
m_AllowNPCTriggering = allownpc;
m_SpawnOnTrigger = spawnontrigger;
m_SmartSpawning = smartSpawning;
ConfigFile = configfile;
m_WayPoint = wayPoint;
// set the totalitem property to -1 so that it doesnt show up in the item count of containers
//TotalItems = -1;
//UpdateTotal(this, TotalType.Items, -1);
// Create the array of spawned objects
m_SpawnObjects = new ArrayList();
// Assign the list of objects to spawn
SpawnObjects = objectsToSpawn;
// Kick off the process
DoTimer( TimeSpan.FromSeconds( 1 ) );
}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:86,代码来源:XmlSpawner2.cs
示例9: RemoveSpawnObjects
public void RemoveSpawnObjects(SpawnObject so)
{
if (so == null) return;
Defrag(false);
for (int i = 0; i < so.SpawnedObjects.Count; ++i)
{
object o = so.SpawnedObjects[i];
if (o is Item)
((Item)o).Delete();
else if (o is Mobile)
((Mobile)o).Delete();
}
// Defrag again
Defrag(false);
}
开发者ID:cynricthehun,项目名称:UOLegends,代码行数:20,代码来源:XmlSpawner2.cs
示例10: RemoveSpawnObjects
public void RemoveSpawnObjects( SpawnObject so )
{
if( so == null ) return;
Defrag( false );
ArrayList deletelist = new ArrayList();
for( int i = 0; i < so.SpawnedObjects.Count; ++i )
{
object o = so.SpawnedObjects[i];
if( o is Item || o is Mobile ) deletelist.Add( o );
}
DeleteFromList( deletelist );
// Defrag again
Defrag( false );
}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:21,代码来源:XmlSpawner2.cs
示例11: XmlImportMap
//.........这里部分代码省略.........
break;
case 1:
spawnmap = Map.Felucca;
break;
case 2:
spawnmap = Map.Trammel;
break;
case 3:
spawnmap = Map.Ilshenar;
break;
case 4:
spawnmap = Map.Malas;
break;
case 5:
try
{
spawnmap = Map.Parse("Tokuno");
}
catch { from.SendMessage("Invalid map at line {0}", linenumber); }
break;
}
if (!IsValidMapLocation(x, y, spawnmap))
{
// invalid so dont spawn it
badspawnercount++;
from.SendMessage("Invalid map/location at line {0}", linenumber);
from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber);
continue;
}
// allow it to make an xmlspawner instead
// first add all of the creatures on the list
SpawnObject[] so = new SpawnObject[typenames.Length];
bool hasvendor = true;
for (int i = 0; i < typenames.Length; i++)
{
so[i] = new SpawnObject(typenames[i], maxcount);
// check the type to see if there are vendors on it
Type type = SpawnerType.GetType(typenames[i]);
// check for vendor-only spawners which get special spawnrange treatment
if (type != null && (type != typeof(BaseVendor) && !type.IsSubclassOf(typeof(BaseVendor))))
{
hasvendor = false;
}
}
// assign it a unique id
Guid SpawnId = Guid.NewGuid();
// and give it a name based on the spawner count and file
string spawnername = String.Format("{0}#{1}", filename, spawnercount);
// Create the new xml spawner
XmlSpawner spawner = new XmlSpawner(SpawnId, x, y, 0, 0, spawnername, maxcount,
TimeSpan.FromMinutes(mindelay), TimeSpan.FromMinutes(maxdelay), TimeSpan.FromMinutes(0), -1, defaultTriggerSound, 1,
0, homerange, false, so, TimeSpan.FromMinutes(0), TimeSpan.FromMinutes(0), TimeSpan.FromMinutes(0),
TimeSpan.FromMinutes(0), null, null, null, null, null,
null, null, null, null, 1, null, false, defTODMode, defKillReset, false, -1, null, false, false, false, null,
TimeSpan.FromHours(0), null, false, null);
if (hasvendor)
开发者ID:cynricthehun,项目名称:UOLegends,代码行数:67,代码来源:XmlSpawner2.cs
示例12: XmlSpawner
public XmlSpawner(
int amount, int minDelay, int maxDelay, int team, int homeRange, int spawnRange, string creatureName)
: base(BaseItemId)
{
m_PlayerCreated = true;
m_UniqueId = Guid.NewGuid().ToString();
SpawnRange = spawnRange;
var so = new SpawnObject[1];
so[0] = new SpawnObject(creatureName, amount);
InitSpawn(
0,
0,
m_Width,
m_Height,
string.Empty,
amount,
TimeSpan.FromMinutes(minDelay),
TimeSpan.FromMinutes(maxDelay),
defDuration,
defProximityRange,
defProximityTriggerSound,
defAmount,
team,
homeRange,
defRelativeHome,
so,
defMinRefractory,
defMaxRefractory,
defTODStart,
defTODEnd,
null,
null,
null,
null,
null,
null,
null,
null,
null,
defTriggerProbability,
null,
defIsGroup,
defTODMode,
defKillReset,
false,
-1,
null,
false,
false,
false,
null,
defDespawnTime,
null,
false,
null);
}
开发者ID:mtPrimo,项目名称:ServUO,代码行数:57,代码来源:XmlSpawner2.cs
示例13: ExecuteAction
public static void ExecuteAction(object attachedto, Mobile trigmob, string action)
{
Point3D loc = Point3D.Zero;
Map map = null;
if (attachedto is IEntity)
{
loc = ((IEntity)attachedto).Location;
map = ((IEntity)attachedto).Map;
}
if (action == null || action.Length <= 0 || attachedto == null || map == null)
{
return;
}
string status_str = null;
SpawnObject TheSpawn = new SpawnObject(null, 0);
TheSpawn.TypeName = action;
string substitutedtypeName = BaseXmlSpawner.ApplySubstitution(null, attachedto, trigmob, action);
string typeName = BaseXmlSpawner.ParseObjectType(substitutedtypeName);
if (BaseXmlSpawner.IsTypeOrItemKeyword(typeName))
{
BaseXmlSpawner.SpawnTypeKeyword(
attachedto, TheSpawn, typeName, substitutedtypeName, true, trigmob, loc, map, out status_str);
}
else
{
// its a regular type descriptor so find out what it is
Type type = SpawnerType.GetType(typeName);
try
{
var arglist = BaseXmlSpawner.ParseString(substitutedtypeName, 3, "/");
object o = CreateObject(type, arglist[0]);
if (o == null)
{
status_str = "invalid type specification: " + arglist[0];
}
else if (o is Mobile)
{
Mobile m = (Mobile)o;
if (m is BaseCreature)
{
BaseCreature c = (BaseCreature)m;
c.Home = loc; // Spawners location is the home point
}
m.Location = loc;
m.Map = map;
BaseXmlSpawner.ApplyObjectStringProperties(null, substitutedtypeName, m, trigmob, attachedto, out status_str);
}
else if (o is Item)
{
Item item = (Item)o;
BaseXmlSpawner.AddSpawnItem(
null, attachedto, TheSpawn, item, loc, map, trigmob, false, substitutedtypeName, out status_str);
}
}
catch
{ }
}
}
开发者ID:mtPrimo,项目名称:ServUO,代码行数:65,代码来源:XmlSpawner2.cs
示例14: XmlSpawner
public XmlSpawner( string creatureName )
: base( BaseItemId )
{
m_PlayerCreated = true;
m_UniqueId = Guid.NewGuid().ToString();
SpawnObject[] so = new SpawnObject[1];
so[0] = new SpawnObject( creatureName, 1 );
SpawnRange = defSpawnRange;
InitSpawn( 0, 0, m_Width, m_Height, string.Empty, 1, defMinDelay, defMaxDelay, defDuration,
defProximityRange, defProximityTriggerSound, defAmount, defTeam, defHomeRange, defRelativeHome, so, defMinRefractory, defMaxRefractory,
defTODStart, defTODEnd, null, null, null, null, null, null, null, null, null, defTriggerProbability, null, defIsGroup, defTODMode,
defKillReset, false, -1, null, false, false, false, null, defDespawnTime, null, false, null );
}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:14,代码来源:XmlSpawner2.cs
示例15: LoadSpawnObjectsFromString
internal static SpawnObject[] LoadSpawnObjectsFromString( string ObjectList )
{
// Clear the spawn object list
ArrayList NewSpawnObjects = new ArrayList();
if( ObjectList != null && ObjectList.Length > 0 )
{
// Split the string based on the object separator first ':'
string[] SpawnObjectList = ObjectList.Split( ':' );
// Parse each item in the array
foreach( string s in SpawnObjectList )
{
// Split the single spawn object item by the max count '='
string[] SpawnObjectDetails = s.Split( '=' );
// Should be two entries
if( SpawnObjectDetails.Length == 2 )
{
// Validate the information
// Make sure the spawn object name part has a valid length
if( SpawnObjectDetails[0].Length > 0 )
{
// Make sure the max count part has a valid length
if( SpawnObjectDetails[1].Length > 0 )
{
int maxCount = 1;
try
{
maxCount = int.Parse( SpawnObjectDetails[1] );
}
catch( System.Exception )
{ // Something went wrong, leave the default amount }
}
// Create the spawn object and store it in the array list
SpawnObject so = new SpawnObject( SpawnObjectDetails[0], maxCount );
NewSpawnObjects.Add( so );
}
}
}
}
}
return (SpawnObject[])NewSpawnObjects.ToArray( typeof( SpawnObject ) );
}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:48,代码来源:XmlSpawner2.cs
示例16: LoadSpawnObjectsFromString2
internal static SpawnObject[] LoadSpawnObjectsFromString2( string ObjectList )
{
// Clear the spawn object list
ArrayList NewSpawnObjects = new ArrayList();
// spawn object definitions will take the form typestring:MX=int:SB=int:RT=double:TO=int:KL=int
// or typestring:MX=int:SB=int:RT=double:TO=int:KL=int:OBJ=typestring...
if( ObjectList != null && ObjectList.Length > 0 )
{
string[] SpawnObjectList = BaseXmlSpawner.SplitString( ObjectList, ":OBJ=" );
// Parse each item in the array
foreach( string s in SpawnObjectList )
{
// at this point each spawn string will take the form typestring:MX=int:SB=int:RT=double:TO=int:KL=int
// Split the single spawn object item by the max count to get the typename and the remaining parms
string[] SpawnObjectDetails = BaseXmlSpawner.SplitString( s, ":MX=" );
// Should be two entries
if( SpawnObjectDetails.Length == 2 )
{
// Validate the information
// Make sure the spawn object name part has a valid length
if( SpawnObjectDetails[0].Length > 0 )
{
// Make sure the parm part has a valid length
if( SpawnObjectDetails[1].Length > 0 )
{
// now parse out the parms
// MaxCount
string parmstr = GetParm( s, ":MX=" );
int maxCount = 1;
try { maxCount = int.Parse( parmstr ); }
catch { }
// SubGroup
parmstr = GetParm( s, ":SB=" );
int subGroup = 0;
try { subGroup = int.Parse( parmstr ); }
catch { }
// SequentialSpawnResetTime
parmstr = GetParm( s, ":RT=" );
double resetTime = 0;
try { resetTime = double.Parse( parmstr ); }
catch { }
// SequentialSpawnResetTo
parmstr = GetParm( s, ":TO=" );
int resetTo = 0;
try { resetTo = int.Parse( parmstr ); }
catch { }
// KillsNeeded
parmstr = GetParm( s, ":KL=" );
int killsNeeded = 0;
try { killsNeeded = int.Parse( parmstr ); }
catch { }
// RestrictKills
parmstr = GetParm( s, ":RK=" );
bool restrictKills = false;
if( parmstr != null )
try { restrictKills = (int.Parse( parmstr ) == 1); }
catch { }
// ClearOnAdvance
parmstr = GetParm( s, ":CA=" );
bool clearAdvance = true;
// if kills needed is zero, then set CA to false by default. This maintains consistency with the
// previous default behavior for old spawn specs that havent specified CA
if( killsNeeded == 0 )
clearAdvance = false;
if( parmstr != null )
try { clearAdvance = (int.Parse( parmstr ) == 1); }
catch { }
// MinDelay
parmstr = GetParm( s, ":DN=" );
double minD = -1;
try { minD = double.Parse( parmstr ); }
catch { }
// MaxDelay
parmstr = GetParm( s, ":DX=" );
double maxD = -1;
try { maxD = double.Parse( parmstr ); }
catch { }
// SpawnsPerTick
parmstr = GetParm( s, ":SP=" );
int spawnsPer = 1;
try { spawnsPer = int.Parse( parmstr ); }
catch { }
// PackRange
parmstr = GetParm( s, ":PR=" );
int packRange = -1;
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:hubroot,代码行数:101,代码来源:XmlSpawner2.cs
示例17: RefreshNextSpawnTime
public void RefreshNextSpawnTime( SpawnObject so )
{
if( so == null ) return;
int mind = (int)(so.MinDelay * 60);
int maxd = (int)(so.MaxDelay * 60);
if( mind < 0 || maxd < 0 )
{
so.NextSpawn = DateTime.Now;
}
else
{
TimeSpan delay = TimeSpan.FromSeconds( Utility.RandomMinMax( mind, maxd ) );
so.NextSpawn = DateTime.Now + delay;
}
}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:19,代码来源:XmlSpawner2.cs
示例18: SpawnEntity
public override void SpawnEntity()
{
Ttl = 9999999;
Level.AddEntity(this);
var addEntity = new SpawnObject(Shooter.Wrapper)
{
EntityId = EntityId,
X = KnownPosition.X,
Y = KnownPosition.Y,
Z = KnownPosition.Z,
Type = ObjectType,
Info = Shooter.EntityId,
Pitch = (byte) KnownPosition.Pitch,
Yaw = (byte) KnownPosition.Yaw,
VelocityX = (short)Velocity.X,
VelocityY = (short)Velocity.Y,
VelocityZ = (short)Velocity.Z,
};
Level.BroadcastPacket(addEntity);
}
开发者ID:LiveMC,项目名称:SharpMC,代码行数:20,代码来源:Projectile.cs
注:本文中的SpawnObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论