本文整理汇总了C#中MUDEngine.CharData.GetObjWear方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.GetObjWear方法的具体用法?C# CharData.GetObjWear怎么用?C# CharData.GetObjWear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MUDEngine.CharData
的用法示例。
在下文中一共展示了CharData.GetObjWear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compare
/// <summary>
/// Compares two objects to see which one is better.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Compare(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj2 = null;
if (ch.IsNPC())
return;
if (str.Length < 1 || String.IsNullOrEmpty(str[0]))
{
ch.SendText("&nCompare what to what?\r\n");
return;
}
Object obj1 = ch.GetObjCarrying(str[0]);
if (!obj1)
{
ch.SendText("&nYou do not have that item.\r\n");
return;
}
if (str.Length < 2 || String.IsNullOrEmpty(str[1]))
{
foreach (Object obj3 in ch.Carrying)
{
if (obj3.WearLocation != ObjTemplate.WearLocation.none
&& CharData.CanSeeObj(ch, obj3)
&& obj1.ItemType == obj3.ItemType
&& (obj1.WearFlags[0] & obj3.WearFlags[0] & ~ObjTemplate.WEARABLE_CARRY.Vector) != 0)
{
obj2 = obj3;
break;
}
}
if (!obj2)
{
ch.SendText("&nYou aren't wearing anything comparable.\r\n");
return;
}
}
else
{
obj2 = ch.GetObjCarrying(str[1]);
if (!obj2)
{
/* Strip off number argument, subtrDescriptor._actFlags one, paste it together */
int number = MUDString.NumberArgument(str[1], ref str[1]);
if (number > 1)
number--;
string newArg2 = String.Format("{0}.{1}", number, str[1]);
obj2 = ch.GetObjWear(newArg2);
if (!obj2)
{
ch.SendText("&nYou do not have that item.\r\n");
return;
}
if ((obj1.WearFlags[0] & obj2.WearFlags[0] & ~ObjTemplate.WEARABLE_CARRY.Vector) == 0)
{
ch.SendText("&nThey are not comparable items.\r\n");
return;
}
}
}
string msg = null;
int value1 = 0;
int value2 = 0;
if (obj1 == obj2)
{
msg = "You compare $p&n to itself. It looks about the same.";
}
else if (obj1.ItemType != obj2.ItemType)
{
msg = "$p&n and $P&n are not the same type of item.";
}
else
{
switch (obj1.ItemType)
{
default:
msg = "You can't compare $p&n and $P&n.";
break;
case ObjTemplate.ObjectType.trash:
msg = "They're both junk.";
break;
case ObjTemplate.ObjectType.armor:
case ObjTemplate.ObjectType.clothing:
//.........这里部分代码省略.........
示例2: Zap
/// <summary>
/// Zap a wand, using its spell power.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Zap(CharData ch, string[] str)
{
if( ch == null ) return;
Object wand = null;
Object obj = null;
CharData victim;
int level;
if (str.Length == 0 && ch.Fighting == null)
{
ch.SendText("Zap whom or what?\r\n");
return;
}
if (!String.IsNullOrEmpty(str[0]) && !(wand = ch.GetObjWear(str[0])))
{
if (!(wand = Object.GetEquipmentOnCharacter(ch, ObjTemplate.WearLocation.hand_one)))
{
ch.SendText("You hold nothing in your hand.\r\n");
return;
}
}
else /* Wand was first argument.. arg is now second argument. */
if (wand.ItemType != ObjTemplate.ObjectType.wand)
{
ch.SendText("You can zap only with a wand.\r\n");
return;
}
level = wand.Level;
if (String.IsNullOrEmpty(str[0]))
{
if (ch.Fighting != null)
{
victim = ch.Fighting;
}
else
{
ch.SendText("Zap whom or what?\r\n");
return;
}
}
else
{
if (((victim = ch.GetCharRoom(str[0])) == null)
&& (obj = ch.GetObjHere(str[0])) == null)
{
ch.SendText("You can't find your _targetType.\r\n");
return;
}
}
if (ch.IsNPC() && !ch.IsFreewilled())
{
SocketConnection.Act("You try to zap $p&n, but you have no free will.",
ch, wand, null, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n tries to zap $p&n, but has no free will.",
ch, wand, null, SocketConnection.MessageTarget.room);
return;
}
String spellName = SpellNumberToTextMap.GetSpellNameFromNumber(wand.Values[3]);
if (String.IsNullOrEmpty(spellName))
{
ch.SendText("You try to zap, but your wand fizzles.\r\n");
Log.Error("Zap: Spell number " + wand.Values[3] + " not found in SpellNumberToTextMap for object " + wand.ObjIndexNumber + ".");
return;
}
Spell spell = StringLookup.SpellLookup(spellName);
if (!spell)
{
ch.SendText("You try to zap, but your wand fizzles.\r\n");
Log.Error("Zap: Spell '" + spellName + "' not found for object " + wand.ObjIndexNumber + ". Check that it exists in the spells file.");
return;
}
ch.PracticeSkill("wands");
if (wand.Values[2] > 0)
{
if (victim != null)
{
if (victim == ch)
{
SocketConnection.Act("You zap yourself with $p&n.", ch, wand, null, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n zaps $mself with $p&n.", ch, wand, null, SocketConnection.MessageTarget.room);
}
else
{
SocketConnection.Act("You zap $N&n with $p&n.", ch, wand, victim, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n zaps $N&n with $p&n.", ch, wand, victim, SocketConnection.MessageTarget.room);
}
}
//.........这里部分代码省略.........
示例3: Use
/// <summary>
/// Use an object. Forwards to the "zap" or "brandish" command for wands
/// and staves, otherwise does nothing.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Use(CharData ch, string[] str)
{
if( ch == null ) return;
Object item;
if (str.Length == 0)
{
ch.SendText("Use what?\r\n");
return;
}
if (!(item = ch.GetObjWear(str[0])))
{
ch.SendText("You can't find it!\r\n");
return;
}
if (item.ItemType == ObjTemplate.ObjectType.wand)
{
Zap(ch, str);
return;
}
if (item.ItemType == ObjTemplate.ObjectType.staff)
{
Brandish(ch, str);
return;
}
ch.SendText("You can only use staves or wands.\r\n");
return;
}
示例4: Remove
/// <summary>
/// Remove a piece of equipment.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Remove(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj;
if (ch.IsAffected(Affect.AFFECT_HOLD) || ch.IsAffected(Affect.AFFECT_MINOR_PARA))
{
ch.SendText("You no longer have control of your body!\r\n");
return;
}
if (str.Length == 0)
{
ch.SendText("Remove what?\r\n");
return;
}
if (str[0] != "all" && MUDString.IsPrefixOf("all.", str[0]))
{
/* 'remove obj' */
if (!(obj = ch.GetObjWear(str[0])))
{
ch.SendText("You do not have that item.\r\n");
return;
}
if (ch.CarryNumber + 1 > Limits.MAX_CARRY)
{
ch.SendText("You have your hands full.\r\n");
return;
}
ch.RemoveObject(obj.WearLocation, true);
if (obj.Trap != null && obj.Trap.CheckTrigger( Trap.TriggerType.unequip))
{
ch.SetOffTrap(obj);
if (ch.CurrentPosition == Position.dead)
return;
}
}
else
{
/* 'remove all' or 'remove all.obj' */
bool found = false;
foreach (Object iobj in ch.Carrying)
{
if (str.Length < 2 || (MUDString.NameContainedIn(str[0].Substring(4), iobj.Name)
&& iobj.WearLocation != ObjTemplate.WearLocation.none))
{
found = true;
if (ch.CarryNumber + 1 > Limits.MAX_CARRY)
{
ch.SendText("You have your hands full.\r\n");
return;
}
ch.RemoveObject(iobj.WearLocation, true);
if (iobj.Trap != null && iobj.Trap.CheckTrigger(Trap.TriggerType.unequip))
{
ch.SetOffTrap(iobj);
if (ch.CurrentPosition == Position.dead)
{
return;
}
}
}
}
if (!found)
{
if (str.Length == 0 || str[0].Length < 4)
{
ch.SendText("You can't find anything to remove.\r\n");
}
else
{
SocketConnection.Act("You can't find any $T&n to remove.",
ch, null, str[0].Substring(4), SocketConnection.MessageTarget.character);
}
}
}
return;
}
示例5: LookCommand
//.........这里部分代码省略.........
SocketConnection.Act("$p&n contains:", ch, obj, null, SocketConnection.MessageTarget.character, true);
Look.ShowListToCharacter(obj.Contains, ch, true, true);
break;
case ObjTemplate.ObjectType.portal:
SocketConnection.Act("A $p&n leads to:", ch, obj, null, SocketConnection.MessageTarget.character);
output += Room.GetRoom(obj.Values[0]).Title + "\r\n";
output += Room.GetRoom(obj.Values[0]).Description;
output += "\r\n";
ch.SendText(output);
break;
}
return;
}
// Look at another char.
if (args.Count > 0)
{
CharData victim = ch.GetCharRoom(args[0]);
if (victim != null)
{
Look.ShowCharacterToCharacterFull(victim, ch);
return;
}
}
// Look at an object.
if (args.Count > 0)
{
// Check inventory.
obj = ch.GetObjCarrying(args[0]);
// If not in inventory, check eq.
if (obj == null)
obj = ch.GetObjWear(args[0]);
// If not on character, check room.
if (obj == null)
obj = Object.GetObjFromList(ch.InRoom.Contents, ch, args[0]);
// If object found, show it to the char.
if (obj != null)
{
pdesc = (Database.GetExtraDescription(args[0], obj.ExtraDescription));
if (pdesc.Length != 0)
{
ch.SendText(pdesc);
}
else if ((pdesc = (Database.GetExtraDescription(args[0], obj.ObjIndexData.ExtraDescriptions))).Length > 0)
{
ch.SendText(pdesc);
}
else if (obj.FullDescription.Length > 0)
{
ch.SendText(obj.FullDescription);
ch.SendText("\r\n");
}
if (obj.HasAffect(Affect.AffectType.skill, "poison weapon"))
{
if (ch.IsClass(CharClass.Names.thief) || ch.IsClass(CharClass.Names.assassin)
|| MUDMath.NumberPercent() < ch.GetCurrInt() / 2)
ch.SendText("It has a &+Gsickly &+Lcolored&n hue.\r\n");
}
return;
}
}
// Look at an object in the room
if (args.Count > 0)
示例6: Invoke
public static void Invoke(CharData ch, string[] str)
{
if( ch == null ) return;
if (str.Length == 0)
{
ch.SendText("Invoke what?\r\n");
return;
}
Object obj = ch.GetObjWear(str[0]);
if (!obj)
{
ch.SendText("You do not have that item equipped.\r\n");
return;
}
Object.Invoke(ch, obj);
return;
}