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


C# Spawner.Delete方法代码示例

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


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

示例1: SaveSpawners_OnCommand

		public static void SaveSpawners_OnCommand(CommandEventArgs e)
		{

			if (e.Arguments.Length == 5)
			{
				int count = 0;
				int x1, y1, x2, y2;
				string FileName = e.Arguments[0].ToString();
				try
				{
					x1 = Int32.Parse(e.Arguments[1]);
					y1 = Int32.Parse(e.Arguments[2]);
					x2 = Int32.Parse(e.Arguments[3]);
					y2 = Int32.Parse(e.Arguments[4]);
				}
				catch
				{
					Usage(e.Mobile);
					return;
				}
				//adjust rect				
				if (x1 > x2)
				{
					int x3 = x1;
					x1 = x2;
					x2 = x3;
				}
				if (y1 > y2)
				{
					int y3 = y1;
					y1 = y2;
					y2 = y3;
				}
				string itemIdxPath = Path.Combine("Saves/Spawners/", FileName + ".idx");
				string itemBinPath = Path.Combine("Saves/Spawners/", FileName + ".bin");

				try
				{
					ArrayList list = new ArrayList();
					foreach (Item item in Server.World.Items.Values)
					{
						if (item is Spawner)
						{
							if (item.X >= x1 && item.Y >= y1 && item.X < x2 && item.Y < y2 && item.Map == e.Mobile.Map)
								list.Add(item);
						}
					}

					if (list.Count > 0)
					{
						try
						{
							string folder = Path.GetDirectoryName(itemIdxPath);

							if (!Directory.Exists(folder))
							{
								Directory.CreateDirectory(folder);
							}

						}
						catch
						{
							e.Mobile.SendMessage("An error occured while trying to create Spawner folder.");
						}

						count = list.Count;
						GenericWriter idx;
						GenericWriter bin;

						idx = new BinaryFileWriter(itemIdxPath, false);
						bin = new BinaryFileWriter(itemBinPath, true);

						idx.Write((int)list.Count);

						for (int i = 0; i < list.Count; ++i)
						{
							long start = bin.Position;
							Spawner temp = new Spawner();
							CopyProperties(temp, (Spawner)list[i]);

							idx.Write((long)start);
							//dont save template data as we cant load it back properly
							temp.TemplateItem = null;
							temp.TemplateMobile = null;
							temp.CreaturesName = ((Spawner)list[i]).CreaturesName;
							temp.Serialize(bin);

							idx.Write((int)(bin.Position - start));
							temp.Delete();
						}
						idx.Close();
						bin.Close();
					}
				}
				catch (Exception ex)
				{
					LogHelper.LogException(ex);
					System.Console.WriteLine("Exception Caught in SaveSpawner code: " + ex.Message);
					System.Console.WriteLine(ex.StackTrace);
				}
//.........这里部分代码省略.........
开发者ID:zerodowned,项目名称:angelisland,代码行数:101,代码来源:SpawnerManagement.cs

示例2: ImportSpawner

        private static void ImportSpawner(XmlElement node)
        {
            int count = int.Parse(GetText(node["count"], "1"));
            int homeRange = int.Parse(GetText(node["homerange"], "4"));

            int walkingRange = int.Parse(GetText(node["walkingrange"], "-1"));

            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"));
            List<string> 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"));
			
            Spawner spawner = new Spawner(count, minDelay, maxDelay, team, homeRange, creaturesName);
            if (walkingRange >= 0)
                spawner.WalkingRange = walkingRange;

            spawner.Name = name;
            spawner.MoveToWorld(location, map);
            if (spawner.Map == Map.Internal)
            {
                spawner.Delete();
                throw new Exception("Spawner created on Internal map.");
            }
            spawner.Respawn();
        }
开发者ID:jasegiffin,项目名称:JustUO,代码行数:31,代码来源:SpawnerExporter.cs

示例3: ImportSpawner

        private static void ImportSpawner(XmlElement node, string mapa, string tipo)
        {
            int count = int.Parse(GetText(node["count"], "1"));
            int homeRange = int.Parse(GetText(node["homerange"], "4"));
            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"));

            if (map.Name == mapa)
            {

                if (tipo == "odbc")
                {

                    ODBCSpawner spawner = new ODBCSpawner(count, minDelay, maxDelay, team, homeRange, creaturesName);
                    spawner.Name = name;
                    spawner.MoveToWorld(location, map);
                    if (spawner.Map == Map.Internal)
                    {
                        spawner.Delete();
                        throw new Exception("Spawner created on Internal map.");
                    }
                    spawner.Respawn();
                }
                else
                {
                    // Genova: necessário converter creaturesName para list<string>.
                    List<string> listaCreaturesName = new List<string>();
                    listaCreaturesName.CopyTo(creaturesName.ToArray(typeof(string)) as string[]);
                    Spawner spawner = new Spawner(count, minDelay, maxDelay, team, homeRange, listaCreaturesName);
                    spawner.Name = name;
                    spawner.MoveToWorld(location, map);
                    if (spawner.Map == Map.Internal)
                    {
                        spawner.Delete();
                        throw new Exception("Spawner created on Internal map.");
                    }
                    spawner.Respawn();
                }
            }
        }
开发者ID:brodock,项目名称:genova-project,代码行数:48,代码来源:SpawnerExporter.cs


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