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


C# XmlSpawner.Delete方法代码示例

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


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

示例1: ImportMegaSpawner


//.........这里部分代码省略.........
										{
											op.WriteLine( "MSFimport : individual spawnrange entry difference: {0} vs {1}",
												GetText( entrynode["SpawnRange"], "4" ), spawnRange );

										}
									}
									catch { }
								}
							}

							// these apply to individual entries
							int amount = int.Parse( GetText( entrynode["Amount"], "1" ) );
							string entryname = GetText( entrynode["EntryType"], "" );

							// keep track of the maxcount for the spawner by adding the individual amounts
							maxcount += amount;

							// add the creature entry
							so[entrycount] = new SpawnObject( entryname, amount );

							entrycount++;
							if( entrycount > nentries )
							{
								// log it
								try
								{
									using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
									{
										op.WriteLine( "{0} MSFImport Error; inconsistent entry count {1} {2}", DateTime.Now, location, map );
										op.WriteLine();
									}
								}
								catch { }
								from.SendMessage( "Inconsistent entry count detected at {0} {1}.", location, map );
								break;
							}

						}
					}
					if( diff )
					{
						from.SendMessage( "Individual entry setting detected at {0} {1}.", location, map );
						// log it
						try
						{
							using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
							{
								op.WriteLine( "{0} MSFImport: Individual entry setting differences listed above from spawner at {1} {2}", DateTime.Now, location, map );
								op.WriteLine();
							}
						}
						catch { }
					}
				}
			}

			// assign it a unique id
			Guid SpawnId = Guid.NewGuid();
			// Create the new xml spawner
			XmlSpawner spawner = new XmlSpawner( SpawnId, location.X, location.Y, 0, 0, name, maxcount,
				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 );

			spawner.SpawnRange = spawnRange;
			spawner.m_PlayerCreated = true;
			string fromname = null;
			if( from != null ) fromname = from.Name;
			spawner.LastModifiedBy = fromname;
			spawner.FirstModifiedBy = fromname;

			// Try to find a valid Z height if required (Z == -999)

			if( location.Z == -999 )
			{
				int NewZ = map.GetAverageZ( location.X, location.Y );

				if( map.CanFit( location.X, location.Y, NewZ, SpawnFitSize ) == false )
				{
					for( int x = 1; x <= 39; x++ )
					{
						if( map.CanFit( location.X, location.Y, NewZ + x, SpawnFitSize ) )
						{
							NewZ += x;
							break;
						}
					}
				}
				location.Z = NewZ;
			}

			spawner.MoveToWorld( location, map );

			if( !IsValidMapLocation( location, spawner.Map ) )
			{
				spawner.Delete();
				throw new Exception( "Invalid spawner location." );
			}
		}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:101,代码来源:XmlSpawner2.cs

示例2: 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

示例3: XmlImportMap

		public static void XmlImportMap(string filename, Mobile from, out int processedmaps, out int processedspawners)
		{
			processedmaps = 0;
			processedspawners = 0;
			int total_processed_maps = 0;
			int total_processed_spawners = 0;
			if (filename == null || filename.Length <= 0 || from == null || from.Deleted) return;
			// Check if the file exists
			if (System.IO.File.Exists(filename) == true)
			{
				int spawnercount = 0;
				int badspawnercount = 0;
				int linenumber = 0;
				// default is no map override, use the map spec from each spawn line
				int overridemap = -1;
				try
				{
					// Create an instance of StreamReader to read from a file.
					// The using statement also closes the StreamReader.
					using (StreamReader sr = new StreamReader(filename))
					{
						string line;
						// Read and display lines from the file until the end of
						// the file is reached.
						while ((line = sr.ReadLine()) != null)
						{
							// format of each .map line is * Dragon:Wyvern 5209 965 -40 2 2 10 50 30 1
							//  * typename:typename:... x y z map mindelay maxdelay homerange spawnrange maxcount
							// or
							//  * typename:typename:... x y z map mindelay maxdelay homerange spawnrange spawnid maxcount
							// ## are comments
							// overridemap mapnumber
							// map 0 is tram+fel
							// map 1 is fel
							// map 2 is tram
							// map 3 is ilsh
							// map 4 is mal
							// map 5 is tokuno
							linenumber++;
							string[] args = line.Trim().Split(' ');

							// look for the override keyword
							if (args.Length == 2 && (args[0].ToLower() == "overridemap"))
							{
								try
								{
									overridemap = int.Parse(args[1]);
								}
								catch { }
							}
							// look for a spawn spec line
							if (args.Length > 0 && (args[0] == "*"))
							{
								bool badspawn = false;
								int x = 0;
								int y = 0;
								int z = 0;
								int map = 0;
								int mindelay = 0;
								int maxdelay = 0;
								int homerange = 0;
								int spawnrange = 0;
								int maxcount = 0;
								int spawnid = 0;
								string[] typenames = null;
								if (args.Length != 11 && args.Length != 12)
								{
									badspawn = true;
									from.SendMessage("Invalid arg count {1} at line {0}", linenumber, args.Length);
								}
								else
								{
									// get the list of spawns
									typenames = args[1].Split(':');
									// parse the rest of the args

									if (args.Length == 11)
									{

										try
										{
											x = int.Parse(args[2]);
											y = int.Parse(args[3]);
											z = int.Parse(args[4]);
											map = int.Parse(args[5]);
											mindelay = int.Parse(args[6]);
											maxdelay = int.Parse(args[7]);
											homerange = int.Parse(args[8]);
											spawnrange = int.Parse(args[9]);
											maxcount = int.Parse(args[10]);

										}
										catch { from.SendMessage("Parsing error at line {0}", linenumber); badspawn = true; }
									}
									else
										if (args.Length == 12)
										{

											try
											{
//.........这里部分代码省略.........
开发者ID:cynricthehun,项目名称:UOLegends,代码行数:101,代码来源:XmlSpawner2.cs

示例4: ParseOldMapFormat


//.........这里部分代码省略.........
									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 )
								{
									// force vendor spawners to behave like the distro
									spawner.SpawnRange = 0;
								}
								else
								{
									spawner.SpawnRange = spawnrange;
								}

								spawner.m_PlayerCreated = true;
								string fromname = null;
								if( from != null ) fromname = from.Name;
								spawner.LastModifiedBy = fromname;
								spawner.FirstModifiedBy = fromname;
								spawner.MoveToWorld( new Point3D( x, y, z ), spawnmap );
								if( spawner.Map == Map.Internal )
								{
									badspawnercount++;
									spawner.Delete();
									from.SendMessage( "Invalid map at line {0}", linenumber );
									from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
									return;
								}
								spawnercount++;
								// handle the special case of map 0 that also needs to do trammel
								if( map == 0 )
								{
									spawnmap = Map.Trammel;
									// assign it a unique id
									SpawnId = Guid.NewGuid();
									// Create the new xml spawner
									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 );

									spawner.SpawnRange = spawnrange;
									spawner.m_PlayerCreated = true;

									spawner.LastModifiedBy = fromname;
									spawner.FirstModifiedBy = fromname;
									spawner.MoveToWorld( new Point3D( x, y, z ), spawnmap );
									if( spawner.Map == Map.Internal )
									{
										badspawnercount++;
										spawner.Delete();
										from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
										return;
									}
									spawnercount++;
								}
							}
							else
							{
								badspawnercount++;
								from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
							}
						}
		}
开发者ID:greeduomacro,项目名称:hubroot,代码行数:101,代码来源:XmlSpawner2.cs

示例5: OnTarget

			protected override void OnTarget( Mobile from, object targeted )
			{
				if(from == null) return;

				// assign it a unique id
				Guid SpawnId = Guid.NewGuid();
				// count the number of entries to be added for maxcount
				int maxcount = 0;
				for(int i = 0; i<MaxEntries;i++)
				{
					if(defs.SelectionList != null && i < defs.SelectionList.Length && defs.SelectionList[i] &&
						defs.NameList != null && i < defs.NameList.Length && defs.NameList[i] != null && defs.NameList[i].Length > 0)
					{
						maxcount++;
					}
				}
                
				// if autonumbering is enabled, name the spawner with the name+number
				string sname = defs.SpawnerName;
				if(defs.AutoNumber)
				{
					sname = String.Format("{0}#{1}",defs.SpawnerName, defs.AutoNumberValue);
				}

				XmlSpawner spawner = new XmlSpawner( SpawnId, from.Location.X, from.Location.Y, 0, 0, sname, maxcount,
					defs.MinDelay, defs.MaxDelay, defs.Duration, defs.ProximityRange, defs.ProximitySound, 1,
					defs.Team, defs.HomeRange, defs.HomeRangeIsRelative, new XmlSpawner.SpawnObject[0], defs.RefractMin, defs.RefractMax,
					defs.TODStart, defs.TODEnd, null, defs.TriggerObjectProp, defs.ProximityMsg, defs.TriggerOnCarried, defs.NoTriggerOnCarried,
					defs.SpeechTrigger, null, null, defs.PlayerTriggerProp, defs.TriggerProbability , null, defs.Group, defs.TODMode, defs.KillReset, defs.ExternalTriggering,
					defs.SequentialSpawn, null, defs.AllowGhostTrig, defs.AllowNPCTrig, defs.SpawnOnTrigger, null, defs.DespawnTime, defs.SkillTrigger, defs.SmartSpawning, null);

				spawner.PlayerCreated = true;

				// if the object is a container, then place it in the container
				if(targeted is Container)
				{
					((Container)targeted).DropItem(spawner);
				} 
				else
				{
					// place the spawner at the targeted location
					IPoint3D p = targeted as IPoint3D;
					if(p == null)
					{
						spawner.Delete();
						return;
					}
					if ( p is Item )
						p = ((Item)p).GetWorldTop();

					spawner.MoveToWorld( new Point3D(p), from.Map );

				}

				spawner.SpawnRange = defs.SpawnRange;
				// add entries from the name list
				for(int i = 0; i<MaxEntries;i++)
				{
					if(defs.SelectionList != null && i < defs.SelectionList.Length && defs.SelectionList[i] &&
						defs.NameList != null && i < defs.NameList.Length && defs.NameList[i] != null && defs.NameList[i].Length > 0)
					{
						spawner.AddSpawn = defs.NameList[i];
					}
				}

				defs.LastSpawner = spawner;
           
				if(defs.AutoNumber)
					// bump the autonumber
					defs.AutoNumberValue++;

				//from.CloseGump(typeof(XmlAddGump));
				XmlAddGump.Refresh(m_state.Mobile, true);

				// open the spawner gump 
				DoShowGump(from, spawner);

			}
开发者ID:Crome696,项目名称:ServUO,代码行数:78,代码来源:XmlAdd.cs


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