• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mobiles.XmlSpawner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



XmlSpawner类属于Server.Mobiles命名空间,在下文中一共展示了XmlSpawner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateBoxSpawn

		/// <summary>
		/// Converts a BoxSpawn to an actual spawner object. This function is used to generate
		/// spawn groups created in Pandora's Box
		/// </summary>
		/// <param name="spawn">The BoxSpawn object describing the spawn that should be created</param>
		/// <returns>A Spawner object - null if not valid</returns>
		public static Item CreateBoxSpawn( BoxSpawn spawn )
		{
			if ( spawn == null || spawn.Entries.Count == 0 )
				return null;

			XmlSpawner spawner = new XmlSpawner();

			spawner.Amount = spawn.Count;
			spawner.MaxCount = spawn.Count;
			spawner.MinDelay = TimeSpan.FromSeconds( spawn.MinDelay );
			spawner.MaxDelay = TimeSpan.FromSeconds( spawn.MaxDelay );
			spawner.Team = spawn.Team;
			spawner.HomeRange = spawn.HomeRange;

			spawner.Running = false;

			spawner.Group = spawn.Group;

			XmlSpawner.SpawnObject[] spawnObjects = new Server.Mobiles.XmlSpawner.SpawnObject[ spawn.Entries.Count ];

			for ( int i = 0; i < spawnObjects.Length; i++ )
			{
				BoxSpawnEntry entry = spawn.Entries[ i ] as BoxSpawnEntry;

				spawnObjects[ i ] = new Server.Mobiles.XmlSpawner.SpawnObject( entry.Type, entry.MaxCount );
			}

			spawner.SpawnObjects = spawnObjects;

			return spawner;
		}
开发者ID:aj9251,项目名称:pandorasbox3,代码行数:37,代码来源:XmlSpawner.cs


示例2: KeywordTimer

 public KeywordTimer(XmlSpawner spawner, KeywordTag tag, TimeSpan delay, TimeSpan repeatdelay, string condition, int gotogroup)
     : base(delay)
 {
     Priority = TimerPriority.OneSecond;
     m_Tag = tag;
     m_Spawner = spawner;
     m_Condition = condition;
     m_Goto = gotogroup;
     m_Repeatdelay = repeatdelay;
 }
开发者ID:greeduomacro,项目名称:divinity,代码行数:10,代码来源:BaseXmlSpawner.cs


示例3: TestItemProperty

        public static bool TestItemProperty(XmlSpawner spawner, Item ObjectPropertyItem, string testString, Mobile trigmob, out string status_str)
        {
            status_str = null;
            // now make sure the item itself is there
            if (ObjectPropertyItem == null || ObjectPropertyItem.Deleted)
            {
                status_str = "Trigger Object not found";
                return false;
            }

            bool testreturn = CheckPropertyString(spawner, ObjectPropertyItem, testString, trigmob, out status_str);

            return testreturn;
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:14,代码来源:BaseXmlSpawner.cs


示例4: SpawnTypeKeyword

 public static bool SpawnTypeKeyword(object invoker, XmlSpawner.SpawnObject TheSpawn, string typeName, string substitutedtypeName, bool requiresurface,
     List<XmlSpawner.SpawnPositionInfo> spawnpositioning, Mobile triggermob, Point3D location, Map map, out string status_str)
 {
     return SpawnTypeKeyword(invoker, TheSpawn, typeName, substitutedtypeName, requiresurface, spawnpositioning,
         triggermob, location, map, null, out status_str);
 }
开发者ID:greeduomacro,项目名称:divinity,代码行数:6,代码来源:BaseXmlSpawner.cs


示例5: SetPropertyValue

        // set property values with support for nested attributes
        public static string SetPropertyValue(XmlSpawner spawner, object o, string name, string value)
        {
            if (o == null)
            {
                return "Null object";
            }

            if ( o != null && o is PlayerMobile && ((PlayerMobile)o).AccessLevel >= AccessLevel.Administrator )
                return "Access denied";

            Type ptype = null;
            object po = null;
            Type type = o.GetType();

            PropertyInfo[] props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

            // parse the strings of the form property.attribute into two parts
            // first get the property
            string[] arglist = ParseString(name, 2, ".");

            string propname = arglist[0];

            string[] keywordargs = ParseString(propname, 4, ",");

            // check for special keywords
            if (keywordargs[0] == "ATTACHMENT")
            {
                if (keywordargs.Length < 4)
                {
                    return "Invalid ATTACHMENT format";
                }
                // syntax is ATTACHMENT,type,name,propname

                string apropname = keywordargs[3];
                string aname = keywordargs[2];
                Type attachtype = SpawnerType.GetType(keywordargs[1]);

                // allow empty string specifications to be used to indicate a null string which will match any name
                if (aname == "") aname = null;

                ArrayList attachments = XmlAttach.FindAttachments(o, attachtype, aname);

                if (attachments != null && attachments.Count > 0)
                {
                    // change the object, object type, and propname to refer to the attachment
                    o = attachments[0];
                    propname = apropname;

                    if (o == null)
                    {
                        return "Null object";
                    }

                    type = o.GetType();
                    props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
                }
                else
                    return "Attachment not found";

            }
            else if (keywordargs[0] == "SKILL")
            {
                if (keywordargs.Length < 2)
                {
                    return "Invalid SKILL format";
                }
                bool found = true;
                try
                {
                    SkillName skillname = (SkillName)Enum.Parse(typeof(SkillName), keywordargs[1], true);
                    if (o is Mobile)
                    {

                        Skill skill = ((Mobile)o).Skills[skillname];

                        skill.Base = double.Parse(value);

                        return "Property has been set.";
                    }
                    else
                        return "Object is not mobile";
                }
                catch { found = false; }

                if (!found)
                    return "Invalid SKILL reference.";
            }
            else if (keywordargs[0] == "STEALABLE")
            {

                bool found = true;
                try
                {
                    if (o is Item)
                    {

                        ItemFlags.SetStealable(o as Item, bool.Parse(value));

                        return "Property has been set.";
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:divinity,代码行数:101,代码来源:BaseXmlSpawner.cs


示例6: RemoveFromTagList

 public static void RemoveFromTagList(XmlSpawner spawner, KeywordTag tag)
 {
     for (int i = 0; i < spawner.m_KeywordTagList.Count; i++)
     {
         if (tag == spawner.m_KeywordTagList[i])
         {
             spawner.m_KeywordTagList.RemoveAt(i);
             break;
         }
     }
 }
开发者ID:greeduomacro,项目名称:divinity,代码行数:11,代码来源:BaseXmlSpawner.cs


示例7: LookupPropertyInfo

        public static PropertyInfo LookupPropertyInfo(XmlSpawner spawner, Type type, string propname)
        {
            if (spawner == null || type == null || propname == null) return null;

            // look up the info in the current list

            if (spawner.PropertyInfoList == null) spawner.PropertyInfoList = new ArrayList();

            PropertyInfo pinfo = null;
            TypeInfo tinfo = null;

            foreach (TypeInfo to in spawner.PropertyInfoList)
            {
                // check the type
                if (to.t == type)
                {
                    // found it
                    tinfo = to;

                    // now search the property list
                    foreach (PropertyInfo p in to.plist)
                    {
                        if (Insensitive.Equals(p.Name, propname))
                        {
                            pinfo = p;
                        }
                    }
                }
            }

            // did we find the property?
            if (pinfo != null)
            {
                return pinfo;
            }
            else
            {
                // if it cant be found, then do the full search and add it to the list

                PropertyInfo[] props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                foreach (PropertyInfo p in props)
                {
                    if (Insensitive.Equals(p.Name, propname))
                    {
                        // did we find the type at least?
                        if (tinfo == null)
                        {
                            // if not then add the type to the list
                            tinfo = new TypeInfo();
                            tinfo.t = type;

                            spawner.PropertyInfoList.Add(tinfo);
                        }

                        // and add the property to the tinfo property list
                        tinfo.plist.Add(p);
                        return p;
                    }
                }
            }

            return null;
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:64,代码来源:BaseXmlSpawner.cs


示例8: GetFromTagList

 public static KeywordTag GetFromTagList(XmlSpawner spawner, int serial)
 {
     for (int i = 0; i < spawner.m_KeywordTagList.Count; i++)
     {
         if (serial == ((KeywordTag)spawner.m_KeywordTagList[i]).Serial)
         {
             return ((KeywordTag)spawner.m_KeywordTagList[i]);
         }
     }
     return (null);
 }
开发者ID:greeduomacro,项目名称:divinity,代码行数:11,代码来源:BaseXmlSpawner.cs


示例9: ApplySubstitution

        public static string ApplySubstitution(XmlSpawner spawner, object o, Mobile trigmob, string typeName)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            // go through the string looking for instances of {keyword}
            string remaining = typeName;

            while (remaining != null && remaining.Length > 0)
            {

                int startindex = remaining.IndexOf('{');

                if (startindex == -1 || startindex + 1 >= remaining.Length)
                {
                    // if there are no more delimiters then append the remainder and finish
                    sb.Append(remaining);
                    break;
                }

                // might be a substitution, check for keywords
                int endindex = remaining.Substring(startindex + 1).IndexOf("}");

                // if the ending delimiter cannot be found then just append and finish
                if (endindex == -1)
                {
                    sb.Append(remaining);
                    break;
                }

                // get the string up to the delimiter
                string firstpart = remaining.Substring(0, startindex);
                sb.Append(firstpart);

                string keypart = remaining.Substring(startindex + 1, endindex);

                // try to evaluate and then substitute the arg
                Type ptype;

                string value = ParseForKeywords(spawner, o, keypart.Trim(), trigmob, true, out ptype);

                // trim off the " from strings
                if (value != null)
                {
                    value = value.Trim('"');
                }

                // replace the parsed value for the keyword
                sb.Append(value);

                // continue processing the rest of the string
                if (endindex + startindex + 2 >= remaining.Length) break;

                remaining = remaining.Substring(endindex + startindex + 2, remaining.Length - endindex - startindex - 2);
            }
            return sb.ToString();
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:56,代码来源:BaseXmlSpawner.cs


示例10: AddAttachmentToTarget

        public static bool AddAttachmentToTarget(XmlSpawner spawner, object o, string[] keywordargs, string[] arglist, Mobile trigmob,
            object refobject, out string remainder, out string status_str)
        {
            remainder = "";
            status_str = null;

            if (o == null || keywordargs == null || arglist == null) return false;

            // Use the format /ATTACH,drop_probability/attachmenttype,name[,args]/
            // or /ATTACH,drop_probability/<attachmenttype,name[,args]/propname1/value1/propname2/value2/...>/
            double drop_probability = 1;

            if (keywordargs.Length > 1)
            {
                bool converterror = false;
                try { drop_probability = Convert.ToDouble(keywordargs[1], CultureInfo.InvariantCulture); }
                catch { status_str = "Invalid drop probability : " + arglist[1]; converterror = true; }

                if (converterror) return false;
            }

            // o is the object to which the attachment will be attached

            // handle the nested item property specification using <>
            string attachargstring = null;

            // attachtypestr will be the actual attachment type to be created.  In the simple form  it will be arglist[1]
            // for the string /arg1/ATTACH/arg2/arg3/arg4/arg5 arglist [0] will contain ATTACH , arglist[1] will be arg2,
            // and arglist[2] will be arg3/arg4/arg5
            // if nested property specs
            // arglist[1] will be <arg2 and arglist[2] will be arg3/ar4>/arg5
            // the drop probability will be in probargs
            string[] probargs = ParseString(arglist[0], 2, ",");

            string attachtypestr = arglist[1];

            // get the argument list after the < if any , note for the string /arg1/ATTACH/<arg2/arg3/arg4>/arg5 arglist [0] will contain ATTACH
            // arglist[1] will be <arg2 and arglist[2] will be arg3/ar4>/arg5
            // but note arglist[1] could also be <arg2>
            // remainder will have ATTACH/<arg2/arg3/arg4>/arg5
            //
            // can also deal with nested cases of ATTACH/<args/ADD/<args>>  and ATTACH/<args/ADD/<args>/ADD/<args>> although there is no clear
            // reason why this syntax should be used at this time
            string addattachstr = arglist[1];

            if (arglist.Length > 2)
                addattachstr = arglist[1] + "/" + arglist[2];

            // check to see if the first char is a "<"
            if (addattachstr.IndexOf("<") == 0)
            {
                // attacharglist[1] will contain arg2/arg3/arg4>/arg5
                // addattachstr should have the full list of args <arg2/arg3/arg4>/arg5 if they are there.  In the case of /arg1/ADD/arg2
                // it will just have arg2
                string[] attacharglist = ParseString(addattachstr, 2, "<");

                // take that argument list that should like like arg2/ag3/arg4>/arg5
                // need to find the matching ">"
                //string[] attachargs = ParseString(attacharglist[1],2,">");

                string[] attachargs = ParseToMatchingParen(attacharglist[1], '<', '>');

                // and get the first part of the string without the >  so attachargs[0] should be arg2/ag3/arg4
                attachargstring = attachargs[0];

                // and attachargs[1] should be the remainder
                if (attachargs.Length > 1)
                {
                    // but have to get rid of any trailing / that might be after the >
                    string[] trailstr = ParseSlashArgs(attachargs[1], 2);
                    if (trailstr.Length > 1)
                        remainder = trailstr[1];
                    else
                        remainder = attachargs[1];
                }
                else
                    remainder = "";

                // get the type info by pulling out the first arg in attachargstring
                string[] tempattacharg = ParseSlashArgs(attachargstring, 2);

                // and get the type info from it
                attachtypestr = tempattacharg[0];

            }
            else
            {
                // otherwise its just a regular case with arglist[2] containing the rest of the arguments
                if (arglist.Length > 2)
                    remainder = arglist[2];
                else
                    remainder = "";
            }

            // test the drop probability
            if (Utility.RandomDouble() >= drop_probability) return true;

            Type type = null;
            if (attachtypestr != null)
            {
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:divinity,代码行数:101,代码来源:BaseXmlSpawner.cs


示例11: ApplyObjectStringProperties

        // added in arg parsing to handle object property setting
        public static bool ApplyObjectStringProperties(XmlSpawner spawner, string str, object o, Mobile trigmob, object refobject, out string status_str)
        {
            status_str = null;

            if (str == null || str.Length <= 0 || o == null) return false;

            // object strings will be of the form "object/modifier" where the modifier string is of the form "propname/value/propname/value/..."
            // some keywords do not have value arguments so the modifier could take the form "propname/propname/value/..."
            // this is handled by parsing into both forms

            // make sure the string is properly terminated to assure proper parsing of any final keywords
            bool terminated = false;
            str = str.Trim();

            if (str[str.Length - 1] != '/')
            {
                str += "/";
                terminated = true;
            }

            string[] arglist;

            arglist = ParseSlashArgs(str, 2);

            string remainder = null;

            // place the modifier section of the string in remainder
            if (arglist.Length > 1)
                remainder = arglist[1];

            bool no_error = true;

            // process the modifier string if there is anything
            while (arglist.Length > 1)
            {
                // place into arglist the parsed modifier up to this point
                // arglist[0] will contain the propname
                // arglist[1] will contain the value
                // arglist[2] will contain the reset of the modifier
                arglist = ParseSlashArgs(remainder, 3);

                // singlearglist will contain the propname and the remainder
                // for those keywords that do not have value args
                string[] singlearglist = ParseSlashArgs(remainder, 2);

                if (arglist.Length > 1)
                {
                    // handle value keywords that may take comma args

                    // itemarglist[1] will contain arg2/arg3/arg4>/arg5
                    // additemstr should have the full list of args <arg2/arg3/arg4>/arg5 if they are there.  In the case of /arg1/ADD/arg2
                    // it will just have arg2
                    string[] groupedarglist = ParseString(arglist[1], 2, "[");

                    // take that argument list that should like like arg2/ag3/arg4>/arg5
                    // need to find the matching ">"

                    string[] groupargs = null;
                    string groupargstring = null;
                    if (groupedarglist.Length > 1)
                    {
                        groupargs = ParseToMatchingParen(groupedarglist[1], '[', ']');

                        // and get the first part of the string without the >  so itemargs[0] should be arg2/ag3/arg4
                        groupargstring = groupargs[0];
                    }

                    // need to handle comma args that may be grouped with the () such as the (ATTACHMENT,args) arg

                    //string[] value_keywordargs = ParseString(groupedarglist[0],10,",");
                    string[] value_keywordargs = groupedarglist[0].Trim().Split(',');
                    if (groupargstring != null && groupargstring.Length > 0)
                    {

                        if (value_keywordargs != null && value_keywordargs.Length > 0)
                            value_keywordargs[value_keywordargs.Length - 1] = groupargstring;
                    }

                    // handle propname keywords that may take comma args
                    //string[] keywordargs = ParseString(arglist[0],10,",");
                    string[] keywordargs = arglist[0].Trim().Split(',');

                    // this quick optimization can determine whether this is a regular prop/value assignment
                    // since most prop modification strings will use regular propnames and not keywords, it makes sense to check for that first
                    if (value_keywordargs[0].Length > 0 && !Char.IsUpper(value_keywordargs[0][0]) &&
                        arglist[0].Length > 0 && !Char.IsUpper(arglist[0][0]))
                    {
                        // all of this code is also included in the keyword candidate tests
                        // this is because regular props can also be entered with uppercase so the lowercase test is not definitive

                        // restricted properties
                        //if(arglist[0].ToLower() == "accesslevel")
                        //{
                        //	status_str = "accesslevel is a protected property";
                        //	if(arglist.Length < 3) break;
                        //	remainder = arglist[2];
                        //}
                        //else
                        {
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:divinity,代码行数:101,代码来源:BaseXmlSpawner.cs


示例12: AddToRecentSpawnerSearchList

        public static void AddToRecentSpawnerSearchList(XmlSpawner spawner, XmlSpawner target)
        {
            if (spawner == null || target == null) return;

            if (spawner.RecentSpawnerSearchList == null)
            {
                spawner.RecentSpawnerSearchList = new ArrayList();
            }
            spawner.RecentSpawnerSearchList.Add(target);

            // check the length and truncate if it gets too long
            if (spawner.RecentSpawnerSearchList.Count > 100)
            {
                spawner.RecentSpawnerSearchList.RemoveAt(0);
            }
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:16,代码来源:BaseXmlSpawner.cs


示例13: AddSpawnItem

        public static void AddSpawnItem(XmlSpawner spawner, object invoker, XmlSpawner.SpawnObject theSpawn, Item item, Point3D location, Map map, Mobile trigmob, bool requiresurface,
            List<XmlSpawner.SpawnPositionInfo> spawnpositioning, string propertyString, bool smartspawn, out string status_str)
        {
            status_str = null;
            if (item == null || theSpawn == null) return;

            // add the item to the spawned list
            theSpawn.SpawnedObjects.Add(item);

            item.Spawner = spawner;

            if (spawner != null)
            {
                // this is being called by a spawner so use spawner information for placement
                if (!spawner.Deleted)
                {
                    // set the item amount
                    if (spawner.StackAmount > 1 && item.Stackable)
                    {
                        item.Amount = spawner.StackAmount;
                    }
                    // if this is in any container such as a pack then add to the container.
                    if (spawner.Parent is Container)
                    {
                        Container c = (Container)spawner.Parent;

                        Point3D loc = spawner.Location;

                        if (!smartspawn)
                        {
                            item.OnBeforeSpawn(loc, map);
                        }

                        item.Location = loc;

                        // check to see whether we drop or add the item based on the spawnrange
                        // this will distribute multiple items around the spawn point, and allow precise
                        // placement of single spawns at the spawn point
                        if (spawner.SpawnRange > 0)
                            c.DropItem(item);
                        else
                            c.AddItem(item);

                    }
                    else
                    {
                        // if the spawn entry is in a subgroup and has a packrange, then get the packcoord

                        Point3D packcoord = Point3D.Zero;
                        if (theSpawn.PackRange >= 0 && theSpawn.SubGroup > 0)
                        {
                            packcoord = spawner.GetPackCoord(theSpawn.SubGroup);
                        }
                        Point3D loc = spawner.GetSpawnPosition(requiresurface, theSpawn.PackRange, packcoord, spawnpositioning);

                        if (!smartspawn)
                        {
                            item.OnBeforeSpawn(loc, map);
                        }

                        // standard placement for all items in the world
                        item.MoveToWorld(loc, map);
                    }
                }
                else
                {
                    // if the spawner has already been deleted then delete the item since it cannot be cleaned up by spawner deletion any longer
                    item.Delete();
                    return;
                }
            }
            else
            {
                if (!smartspawn)
                {
                    item.OnBeforeSpawn(location, map);
                }
                // use the location and map info passed in
                // this allows AddSpawnItem to be called by objects other than spawners as long as they pass in a valid SpawnObject
                item.MoveToWorld(location, map);
            }

            // clear the taken flag on all newly spawned items
            ItemFlags.SetTaken(item, false);

            if (!smartspawn)
            {
                item.OnAfterSpawn();
            }

            // apply the parsed arguments from the typestring using setcommand
            // be sure to do this after setting map and location so that errors dont place the mob on the internal map
            BaseXmlSpawner.ApplyObjectStringProperties(spawner, propertyString, item, trigmob, spawner, out status_str);

            // if the object has an OnAfterSpawnAndModify method, then invoke it
            //InvokeOnAfterSpawnAndModify(item);
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:97,代码来源:BaseXmlSpawner.cs


示例14: FindMobileByName

        public static Mobile FindMobileByName(XmlSpawner fromspawner, string name, string typestr)
        {
            if (name == null) return (Mobile)null;

            int count = 0;

            Mobile foundmobile = FindInRecentMobileSearchList(fromspawner, name, typestr);

            if (foundmobile != null) return foundmobile;

            Type targettype = null;
            if (typestr != null)
            {
                targettype = SpawnerType.GetType(typestr);
            }

            // search through all mobiles in the world and find one with a matching name
            foreach (Mobile mobile in World.Mobiles.Values)
            {
                Type mobtype = mobile.GetType();
                if (!mobile.Deleted && (typestr == null ||
                    (mobtype != null && targettype != null && (mobtype.Equals(targettype) || mobtype.IsSubclassOf(targettype))))
                    && ((name.Length == 0 || String.Compare(mobile.Name, name, true) == 0)))
                {

                    foundmobile = mobile;
                    count++;
                    // added the break in to return the first match instead of forcing uniqueness (overrides the count test)
                    break;
                }
                //if(count > 1) break;
            }

            // if a unique item is found then success
            if (count == 1)
            {
                // add this to the recent search list
                AddToRecentMobileSearchList(fromspawner, foundmobile);

                return (foundmobile);
            }
            else
                return (Mobile)null;
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:44,代码来源:BaseXmlSpawner.cs


示例15: FindSpawnerByName

        public static XmlSpawner FindSpawnerByName(XmlSpawner fromspawner, string name)
        {
            if (name == null) return (XmlSpawner)null;

            int count = 0;

            // do a quick search through the recent search list to see if it is there
            XmlSpawner foundspawner = FindInRecentSpawnerSearchList(fromspawner, name);

            if (foundspawner != null) return foundspawner;

            // search through all xmlspawners in the world and find one with a matching name
            foreach (Item item in World.Items.Values)
            {
                if (item is XmlSpawner)
                {
                    XmlSpawner spawner = (XmlSpawner)item;
                    if (!spawner.Deleted && (String.Compare(spawner.Name, name, true) == 0))
                    {
                        foundspawner = spawner;

                        count++;
                        // added the break in to return the first match instead of forcing uniqueness (overrides the count test)
                        break;
                    }
                    //if(count > 1) break;
                }
            }

            // if a unique item is found then success
            if (count == 1)
            {
                // add this to the recent search list
                AddToRecentSpawnerSearchList(fromspawner, foundspawner);

                return (foundspawner);
            }
            else
                return (XmlSpawner)null;
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:40,代码来源:BaseXmlSpawner.cs


示例16: ApplyToProperty

        // -------------------------------------------------------------
        // End modified Beta-36 Properties.cs code
        // -------------------------------------------------------------
        public static string ApplyToProperty(XmlSpawner spawner, object getobject, object setobject, string getpropertystring, string setpropertystring)
        {
            Type ptype;

            string getvalue = GetPropertyValue(spawner, getobject, getpropertystring, out ptype);

            if (getvalue == null)
            {
                return "Null object or property";
            }

            if (ptype == null)
            {
                return getvalue;
            }

            string value2 = ParseGetValue(getvalue, ptype);

            if (value2 != null)
            {
                // set the property value using returned get value as the the value
                string result = SetPropertyValue(spawner, setobject, setpropertystring, value2);

                // see if it was successful
                if (result != "Property has been set.")
                {
                    return setpropertystring + " : " + result;
                }
            }

            return null;
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:35,代码来源:BaseXmlSpawner.cs


示例17: GetPropertyValue

        public static string GetPropertyValue(XmlSpawner spawner, object o, string name, out Type ptype)
        {
            ptype = null;
            if (o == null || name == null) return null;

            Type type = o.GetType();
            object po = null;

            if ( o != null && o is PlayerMobile && ((PlayerMobile)o).AccessLevel >= AccessLevel.Administrator )
                return "Access denied";

            PropertyInfo[] props = null;

            try
            {
                props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
            }
            catch
            {
                Console.WriteLine("GetProperties error with type {0}", type);
                return null;
            }

            // parse the strings of the form property.attribute into two parts
            // first get the property
            string[] arglist = ParseString(name, 2, ".");
            string propname = arglist[0];
            // parse up to 4 comma separated args for special keyword properties
            string[] keywordargs = ParseString(propname, 4, ",");

            // check for special keywords
            if (keywordargs[0] == "ATTACHMENT")
            {
                // syntax is ATTACHMENT,type,name,property
                if (keywordargs.Length < 4)
                {
                    return "Invalid ATTACHMENT format";
                }

                string apropname = keywordargs[3];
                string aname = keywordargs[2];
                Type attachtype = SpawnerType.GetType(keywordargs[1]);

                // allow empty string specifications to be used to indicate a null string which will match any name
                if (aname == "") aname = null;

                ArrayList attachments = XmlAttach.FindAttachments(o, attachtype, aname);

                if (attachments != null && attachments.Count > 0)
                {
                    string getvalue = GetPropertyValue(spawner, attachments[0], apropname, out ptype);

                    return getvalue;
                }
                else
                    return "Attachment not found";
            }
            else
                if (keywordargs[0] == "SKILL")
                {
                    // syntax is SKILL,skillname
                    if (keywordargs.Length < 2)
                    {
                        return "Invalid SKILL format";
                    }
                    bool found = true;
                    try
                    {
                        SkillName skillname = (SkillName)Enum.Parse(typeof(SkillName), keywordargs[1], true);

                        if (o is Mobile)
                        {
                            Skill skill = ((Mobile)o).Skills[skillname];
                            ptype = skill.Value.GetType();

                            return String.Format("{0} = {1}", skillname, skill.Value);
                        }
                        else
                            return "Object is not mobile";
                    }
                    catch { found = false; }

                    if (!found)
                        return "Skill not found.";
                }
                else
                    if (keywordargs[0] == "SERIAL")
                    {

                        bool found = true;
                        try
                        {
                            if (o is Mobile)
                            {
                                ptype = ((Mobile)o).Serial.GetType();

                                return String.Format("Serial = {0}", ((Mobile)o).Serial);
                            }
                            else
                                if (o is Item)
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:divinity,代码行数:101,代码来源:BaseXmlSpawner.cs


示例18: AddItemToTarget

        public static bool AddItemToTarget(XmlSpawner spawner, object o, string[] keywordargs, string[] arglist, Mobile trigmob,
            object refobject, bool equip, out string remainder, out string status_str)
        {
            remainder = "";
            status_str = null;

            if (o == null || keywordargs == null || arglist == null) return false;

            // if the object is a mobile then add the item in the next arg to its pack.  Use the format /ADD,drop_probability/itemtype/
            // or /ADD,drop_probability/<itemtype/propname1/value1/propname2/value2/...>/
            double drop_probability = 1;

            if (keywordargs.Length > 1)
            {
                bool converterror = false;
                try { drop_probability = Convert.ToDouble(keywordargs[1], CultureInfo.InvariantCulture); }
                catch { status_str = "Invalid drop probability : " + arglist[1]; converterror = true; }

                if (converterror) return false;
            }

            Mobile m = null;
            if (o is Mobile || (o is Container))
            {
                Container pack = null;

                if (o is Mobile)
                {
                    m = (Mobile)o;

                    if (!m.Deleted)
                    {
                        pack = m.Backpack;

                        // auto add a pack if the mob doesnt have one
                        if (pack == null)
                        {
                            pack = new Backpack();
                            m.AddItem(pack);
                        }
                    }
                }
                else
                {
                    pack = o as Container;

                }

                if (pack != null)
                {
                    // handle the nested item property specification using <>
                    string itemargstring = null;

                    // itemtypestr will be the actual item type to be created.  In the simple form  it will be arglist[1]
                    // for the string /arg1/ADD/arg2/arg3/arg4/arg5 arglist [0] will contain ADD , arglist[1] will be arg2,
                    // and arglist[2] will be arg3/arg4/arg5
                    // if nested property specs
                    // arglist[1] will be <arg2 and arglist[2] will be arg3/ar4>/arg5
                    // the drop probability will be in probargs
                    string[] probargs = ParseCommaArgs(arglist[0], 2);

                    string itemtypestr = arglist[1];

                    // get the argument list after the < if any , note for the string /arg1/ADD/<arg2/arg3/arg4>/arg5 arglist [0] will contain ADD
                    // arglist[1] will be <arg2 and arglist[2] will be arg3/ar4>/arg5
                    // but note arglist[1] could also be <arg2>
                    // remainder will have ADD/<arg2/arg3/arg4>/arg5
                    //
                    // also need to deal with nested cases of ADD/<args/ADD/<args>>  and ADD/<args/ADD/<args>/ADD<args>>
                    string additemstr = arglist[1];

                    if (arglist.Length > 2)
                        additemstr = arglist[1] + "/" + arglist[2];

                    // check to see if the first char is a "<"
                    if (additemstr.IndexOf("<") == 0)
                    {
                        // itemarglist[1] will contain arg2/arg3/arg4>/arg5
                        // additemstr should have the full list of args <arg2/arg3/arg4>/arg5 if they are there.  In the case of /arg1/ADD/arg2
                        // it will just have arg2
                        string[] itemarglist = ParseString(additemstr, 2, "<");

                        // take that argument list that should like like arg2/ag3/arg4>/arg5
                        // need to find the matching ">"
                        //string[] itemargs = ParseString(itemarglist[1],2,">");

                        string[] itemargs = ParseToMatchingParen(itemarglist[1], '<', '>');

                        // and get the first part of the string without the >  so itemargs[0] should be arg2/ag3/arg4
                        itemargstring = itemargs[0];

                        // and itemargs[1] should be the remainder
                        if (itemargs.Length > 1)
                        {
                            // but have to get rid of any trailing / that might be after the >
                            str 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Multis.BaseBoat类代码示例发布时间:2022-05-26
下一篇:
C# Mobiles.Spawner类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap