本文整理汇总了C#中Terraria.Item.AffixName方法的典型用法代码示例。如果您正苦于以下问题:C# Item.AffixName方法的具体用法?C# Item.AffixName怎么用?C# Item.AffixName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terraria.Item
的用法示例。
在下文中一共展示了Item.AffixName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Item
TextSnippet ITagHandler.Parse(string text, Color baseColor, string options)
{
Item obj = new Item();
int result1;
if (int.TryParse(text, out result1))
obj.netDefaults(result1);
else
obj.SetDefaults(text);
if (obj.itemId <= 0)
return new TextSnippet(text);
obj.stack = 1;
if (options != null)
{
string[] strArray = options.Split(',');
for (int index = 0; index < strArray.Length; ++index)
{
if (strArray[index].Length != 0)
{
switch (strArray[index][0])
{
case 'p':
int result2;
if (int.TryParse(strArray[index].Substring(1), out result2))
{
obj.Prefix(Utils.Clamp<int>(result2, 0, 84));
continue;
}
continue;
case 's':
case 'x':
int result3;
if (int.TryParse(strArray[index].Substring(1), out result3))
{
obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
continue;
}
continue;
default:
continue;
}
}
}
}
string str = "";
if (obj.stack > 1)
str = " (" + obj.stack + ")";
ItemSnippet itemSnippet = new ItemSnippet(obj);
itemSnippet.Text = "[" + obj.AffixName() + str + "]";
itemSnippet.CheckForHover = true;
itemSnippet.DeleteWhole = true;
return itemSnippet;
}
示例2: MouseText
/// <summary>
/// Draws Item information at the mouse
/// </summary>
/// <param name="i">The Item to get the info from</param>
public static void MouseText(Item i)
{
Main.toolTip = i;
MouseText(i.AffixName() + (i.stack > 1 ? " (" + i.stack + ")" : ""));
Main.toolTip = new Item();
}
示例3: NewText
public static void NewText(Item newItem, int stack, bool noStack = false, bool longText = false)
{
if (!Main.showItemText)
{
return;
}
if (newItem.name == null || !newItem.active)
{
return;
}
if (Main.netMode == 2)
{
return;
}
for (int i = 0; i < 20; i++)
{
if (Main.itemText[i].active && Main.itemText[i].name == newItem.name && !Main.itemText[i].NoStack && !noStack)
{
string text = string.Concat(new object[]
{
newItem.name,
" (",
Main.itemText[i].stack + stack,
")"
});
string text2 = newItem.name;
if (Main.itemText[i].stack > 1)
{
object obj = text2;
text2 = string.Concat(new object[]
{
obj,
" (",
Main.itemText[i].stack,
")"
});
}
Vector2 vector = Main.fontMouseText.MeasureString(text2);
vector = Main.fontMouseText.MeasureString(text);
if (Main.itemText[i].lifeTime < 0)
{
Main.itemText[i].scale = 1f;
}
Main.itemText[i].lifeTime = 60;
Main.itemText[i].stack += stack;
Main.itemText[i].scale = 0f;
Main.itemText[i].rotation = 0f;
Main.itemText[i].position.X = newItem.position.X + (float)newItem.width * 0.5f - vector.X * 0.5f;
Main.itemText[i].position.Y = newItem.position.Y + (float)newItem.height * 0.25f - vector.Y * 0.5f;
Main.itemText[i].velocity.Y = -7f;
return;
}
}
int num = -1;
for (int j = 0; j < 20; j++)
{
if (!Main.itemText[j].active)
{
num = j;
break;
}
}
if (num == -1)
{
double num2 = (double)Main.bottomWorld;
for (int k = 0; k < 20; k++)
{
if (num2 > (double)Main.itemText[k].position.Y)
{
num = k;
num2 = (double)Main.itemText[k].position.Y;
}
}
}
if (num >= 0)
{
string text3 = newItem.AffixName();
if (stack > 1)
{
object obj2 = text3;
text3 = string.Concat(new object[]
{
obj2,
" (",
stack,
")"
});
}
Vector2 vector2 = Main.fontMouseText.MeasureString(text3);
Main.itemText[num].alpha = 1f;
Main.itemText[num].alphaDir = -1;
Main.itemText[num].active = true;
Main.itemText[num].scale = 0f;
Main.itemText[num].NoStack = noStack;
Main.itemText[num].rotation = 0f;
Main.itemText[num].position.X = newItem.position.X + (float)newItem.width * 0.5f - vector2.X * 0.5f;
Main.itemText[num].position.Y = newItem.position.Y + (float)newItem.height * 0.25f - vector2.Y * 0.5f;
Main.itemText[num].color = Color.White;
if (newItem.rare == 1)
{
//.........这里部分代码省略.........
示例4: HackedInventory
public static bool HackedInventory(TSPlayer player)
{
bool check = false;
Item[] inventory = player.TPlayer.inventory;
Item[] armor = player.TPlayer.armor;
for (int i = 0; i < NetItem.maxNetInventory; i++)
{
if (i < 49)
{
Item item = new Item();
if (inventory[i] != null && inventory[i].netID != 0)
{
item.netDefaults(inventory[i].netID);
item.Prefix(inventory[i].prefix);
item.AffixName();
if (inventory[i].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack),
Color.Cyan);
}
}
}
else
{
Item item = new Item();
if (armor[i - 48] != null && armor[i - 48].netID != 0)
{
item.netDefaults(armor[i - 48].netID);
item.Prefix(armor[i - 48].prefix);
item.AffixName();
if (armor[i - 48].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[i - 48].stack),
Color.Cyan);
}
}
}
}
return check;
}
示例5: CheckInventory
public static bool CheckInventory(TSPlayer player)
{
PlayerData playerData = player.PlayerData;
bool check = true;
if (player.TPlayer.statLifeMax > playerData.maxHealth)
{
player.SendMessage("Error: Your max health exceeded (" + playerData.maxHealth + ") which is stored on server",
Color.Cyan);
check = false;
}
Item[] inventory = player.TPlayer.inventory;
Item[] armor = player.TPlayer.armor;
for (int i = 0; i < NetItem.maxNetInventory; i++)
{
if (i < 49)
{
Item item = new Item();
Item serverItem = new Item();
if (inventory[i] != null && inventory[i].netID != 0)
{
if (playerData.inventory[i].netID != inventory[i].netID)
{
item.netDefaults(inventory[i].netID);
item.Prefix(inventory[i].prefix);
item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.",
Color.Cyan);
check = false;
}
else if (playerData.inventory[i].prefix != inventory[i].prefix)
{
item.netDefaults(inventory[i].netID);
item.Prefix(inventory[i].prefix);
item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your item (" + item.name + ") needs to be deleted.",
Color.Cyan);
check = false;
}
else if (inventory[i].stack > playerData.inventory[i].stack)
{
item.netDefaults(inventory[i].netID);
item.Prefix(inventory[i].prefix);
item.AffixName();
player.SendMessage(
player.IgnoreActionsForInventory =
"Your item (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" +
playerData.inventory[i].stack + ").", Color.Cyan);
check = false;
}
}
}
else
{
Item item = new Item();
Item serverItem = new Item();
if (armor[i - 48] != null && armor[i - 48].netID != 0)
{
if (playerData.inventory[i].netID != armor[i - 48].netID)
{
item.netDefaults(armor[i - 48].netID);
item.Prefix(armor[i - 48].prefix);
item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.",
Color.Cyan);
check = false;
}
else if (playerData.inventory[i].prefix != armor[i - 48].prefix)
{
item.netDefaults(armor[i - 48].netID);
item.Prefix(armor[i - 48].prefix);
item.AffixName();
player.SendMessage(player.IgnoreActionsForInventory = "Your armor (" + item.name + ") needs to be deleted.",
Color.Cyan);
check = false;
}
else if (armor[i - 48].stack > playerData.inventory[i].stack)
{
item.netDefaults(armor[i - 48].netID);
item.Prefix(armor[i - 48].prefix);
item.AffixName();
player.SendMessage(
player.IgnoreActionsForInventory =
"Your armor (" + item.name + ") (" + inventory[i].stack + ") needs to have it's stack decreased to (" +
playerData.inventory[i].stack + ").", Color.Cyan);
check = false;
}
}
}
}
return check;
}
示例6: HackedInventory
/// <summary>HackedInventory - Checks to see if a user has a hacked inventory. In addition, messages players the result.</summary>
/// <param name="player">player - The TSPlayer object.</param>
/// <returns>bool - True if the player has a hacked inventory.</returns>
public static bool HackedInventory(TSPlayer player)
{
bool check = false;
Item[] inventory = player.TPlayer.inventory;
Item[] armor = player.TPlayer.armor;
Item[] dye = player.TPlayer.dye;
Item[] miscEquips = player.TPlayer.miscEquips;
Item[] miscDyes = player.TPlayer.miscDyes;
Item[] piggy = player.TPlayer.bank.item;
Item[] safe = player.TPlayer.bank2.item;
Item trash = player.TPlayer.trashItem;
for (int i = 0; i < NetItem.MaxInventory; i++)
{
if (i < NetItem.InventorySlots)
{
//0-58
Item item = new Item();
if (inventory[i] != null && inventory[i].netID != 0)
{
item.netDefaults(inventory[i].netID);
item.Prefix(inventory[i].prefix);
item.AffixName();
if (inventory[i].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack),
Color.Cyan);
}
}
}
else if (i < NetItem.InventorySlots + NetItem.ArmorSlots)
{
//59-78
Item item = new Item();
var index = i - NetItem.InventorySlots;
if (armor[index] != null && armor[index].netID != 0)
{
item.netDefaults(armor[index].netID);
item.Prefix(armor[index].prefix);
item.AffixName();
if (armor[index].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[index].stack),
Color.Cyan);
}
}
}
else if (i < NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots)
{
//79-88
Item item = new Item();
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots);
if (dye[index] != null && dye[index].netID != 0)
{
item.netDefaults(dye[index].netID);
item.Prefix(dye[index].prefix);
item.AffixName();
if (dye[index].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove dye {0} ({1}) and then rejoin", item.name, dye[index].stack),
Color.Cyan);
}
}
}
else if (i <
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots)
{
//89-93
Item item = new Item();
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots);
if (miscEquips[index] != null && miscEquips[index].netID != 0)
{
item.netDefaults(miscEquips[index].netID);
item.Prefix(miscEquips[index].prefix);
item.AffixName();
if (miscEquips[index].stack > item.maxStack)
{
check = true;
player.SendMessage(
String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, miscEquips[index].stack),
Color.Cyan);
}
}
}
else if (i <
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots
+ NetItem.MiscDyeSlots)
{
//93-98
Item item = new Item();
//.........这里部分代码省略.........
示例7: NewText
public static void NewText(Item newItem, int stack, bool noStack = false, bool longText = false)
{
bool flag = newItem.type >= 71 && newItem.type <= 74;
if (!Main.showItemText)
{
return;
}
if (newItem.name == null || !newItem.active)
{
return;
}
if (Main.netMode == 2)
{
return;
}
for (int i = 0; i < 20; i++)
{
if (Main.itemText[i].active && (Main.itemText[i].name == newItem.AffixName() || (flag && Main.itemText[i].coinText)) && !Main.itemText[i].NoStack && !noStack)
{
string text = string.Concat(new object[]
{
newItem.name,
" (",
Main.itemText[i].stack + stack,
")"
});
string text2 = newItem.name;
if (Main.itemText[i].stack > 1)
{
object obj = text2;
text2 = string.Concat(new object[]
{
obj,
" (",
Main.itemText[i].stack,
")"
});
}
Vector2 vector = Main.fontMouseText.MeasureString(text2);
vector = Main.fontMouseText.MeasureString(text);
if (Main.itemText[i].lifeTime < 0)
{
Main.itemText[i].scale = 1f;
}
if (Main.itemText[i].lifeTime < 60)
{
Main.itemText[i].lifeTime = 60;
}
if (flag && Main.itemText[i].coinText)
{
int num = 0;
if (newItem.type == 71)
{
num += newItem.stack;
}
else if (newItem.type == 72)
{
num += 100 * newItem.stack;
}
else if (newItem.type == 73)
{
num += 10000 * newItem.stack;
}
else if (newItem.type == 74)
{
num += 1000000 * newItem.stack;
}
Main.itemText[i].coinValue += num;
text = ItemText.ValueToName(Main.itemText[i].coinValue);
vector = Main.fontMouseText.MeasureString(text);
Main.itemText[i].name = text;
if (Main.itemText[i].coinValue >= 1000000)
{
if (Main.itemText[i].lifeTime < 300)
{
Main.itemText[i].lifeTime = 300;
}
Main.itemText[i].color = new Color(220, 220, 198);
}
else if (Main.itemText[i].coinValue >= 10000)
{
if (Main.itemText[i].lifeTime < 240)
{
Main.itemText[i].lifeTime = 240;
}
Main.itemText[i].color = new Color(224, 201, 92);
}
else if (Main.itemText[i].coinValue >= 100)
{
if (Main.itemText[i].lifeTime < 180)
{
Main.itemText[i].lifeTime = 180;
}
Main.itemText[i].color = new Color(181, 192, 193);
}
else if (Main.itemText[i].coinValue >= 1)
{
if (Main.itemText[i].lifeTime < 120)
{
Main.itemText[i].lifeTime = 120;
//.........这里部分代码省略.........
示例8: NetHooks_GetData
//.........这里部分代码省略.........
if (player.GetState() != SettingState.None)
//if player is still setting something - end his setting
player.SetState(SettingState.None);
}
break;
case PacketTypes.TileKill:
case PacketTypes.Tile:
using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
try
{
var reader = new BinaryReader(data);
if (e.MsgID == PacketTypes.Tile)
{
byte type = reader.ReadByte();
if (!(type == 0 || type == 4))
return;
}
int x = reader.ReadInt32();
int y = reader.ReadInt32();
reader.Close();
if (Chest.TileIsChest(x, y)) //if is Chest
{
int id = Terraria.Chest.FindChest(x, y);
CPlayer player = Players[e.Msg.whoAmI];
TPPlayer tplayer = tPulse.Players[e.Msg.whoAmI];
//dirty fix for finding chest, try to find chest point around
if (id == -1)
try
{
id = Terraria.Chest.FindChest(x - 1, y); //search one tile left
if (id == -1)
{
id = Terraria.Chest.FindChest(x - 1, y - 1);
//search one tile left and one tile up
if (id == -1)
id = Terraria.Chest.FindChest(x, y - 1); //search one tile up
}
}
catch (Exception ex)
{
Log.Write(ex.ToString(), LogLevel.Error);
}
if (id != -1) //if have found chest
{
Chest chest = ChestManager.GetChest(id);
if (chest.HasOwner()) //if owned stop removing
{
if (tplayer.Group.HasPermission("removechestprotection") ||
chest.IsOwnerConvert(player))
//display more verbose info to player who has permission to remove protection on this chest
player.SendMessage(
"This chest is protected. To remove it, first remove protection using \"/cunset\" command.",
Color.Red);
else
player.SendMessage("This chest is protected!", Color.Red);
player.SendTileSquare(x, y);
e.Handled = true;
}
}
}
}
catch (Exception ex)
{
Log.Write(ex.ToString(), LogLevel.Error);
}
break;
case PacketTypes.ChestItem:
using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
{
var reader = new BinaryReader(data);
short id = reader.ReadInt16();
byte slot = reader.ReadByte();
byte stack = reader.ReadByte();
byte prefix = reader.ReadByte();
short type = reader.ReadByte();
if (id != -1)
{
Chest chest = ChestManager.GetChest(id);
if (chest.IsRefill())
e.Handled = true;
if (!e.Handled)
{
var item = Main.chest[id].item[slot];
var newitem = new Item();
newitem.netDefaults(type);
newitem.Prefix(prefix);
newitem.AffixName();
Log.Write(string.Format("{0}({1}) in slot {2} in chest at {3}x{4} was modified to {5}({6}) by {7}",
item.name, item.stack, slot, Main.chest[id].x, Main.chest[id].y, newitem.name, stack, tPulse.Players[e.Msg.whoAmI].UserAccountName),
LogLevel.Info, false);
}
}
}
break;
}
}
示例9: DeepCopyItems
private Item[] DeepCopyItems( Item[] source )
{
Item[] result = null;
if ( source.Length > 0 )
{
result = new Item[source.Length];
for ( int i = 0; i < source.Length; i++ )
{
var oldItem = source[i];
if ( oldItem != null )
{
var newItem = new Item();
newItem.netDefaults( oldItem.netID );
newItem.Prefix( oldItem.prefix );
newItem.AffixName();
//if ( oldItem.type != 0 )
// Log.Write( "DCI (id:" + ID + ") " + oldItem.name + "," + newItem.name + "," + oldItem.netID + "," + newItem.netID, LogLevel.Debug );
result[i] = newItem;
result[i].stack = oldItem.stack;
} // if
} // for
} // if
return result;
}
示例10: Prefixes
//public Terraria.Item GetN
public List<string> Prefixes()
{
var result = new List<string> { string.Empty };
var curitem = new Terraria.Item();
curitem.name = "";
for (int prefix = 1; prefix < byte.MaxValue; prefix++)
{
curitem.prefix = (byte)prefix;
string affixName = curitem.AffixName();
if (string.IsNullOrWhiteSpace(affixName))
break;
result.Add(affixName);
}
return result;
}
示例11: GetPrefixByName
/// <summary>
/// Gets a list of prefixes by name
/// </summary>
/// <param name="name">Name</param>
/// <returns>List of prefix IDs</returns>
public static List<int> GetPrefixByName(string name)
{
Item item = new Item();
item.SetDefaults(0);
string lowerName = name.ToLower();
var found = new List<int>();
for (int i = FirstItemPrefix; i <= LastItemPrefix; i++)
{
item.prefix = (byte)i;
string prefixName = item.AffixName().Trim().ToLower();
if (prefixName == lowerName)
return new List<int>() { i };
else if (prefixName.StartsWith(lowerName)) // Partial match
found.Add(i);
}
return found;
}
示例12: GetPrefixById
/// <summary>
/// Gets a prefix based on its id
/// </summary>
/// <param name="id">ID</param>
/// <returns>Prefix name</returns>
public static string GetPrefixById(int id)
{
var item = new Item();
item.SetDefaults(0);
item.prefix = (byte)id;
item.AffixName();
return item.name.Trim();
}
示例13: NewText
public static void NewText(Item newItem, int stack, bool noStack = false, bool longText = false)
{
bool flag = newItem.itemId >= 71 && newItem.itemId <= 74;
if (!Main.showItemText || newItem.name == null || (!newItem.active || Main.netMode == 2))
return;
for (int index = 0; index < 20; ++index)
{
if (Main.itemText[index].active && (Main.itemText[index].name == newItem.AffixName() || flag && Main.itemText[index].coinText) && (!Main.itemText[index].NoStack && !noStack))
{
string text1 = string.Concat(new object[4]
{
(object) newItem.name,
(object) " (",
(object) (Main.itemText[index].stack + stack),
(object) ")"
});
string text2 = newItem.name;
if (Main.itemText[index].stack > 1)
text2 = string.Concat(new object[4]
{
(object) text2,
(object) " (",
(object) Main.itemText[index].stack,
(object) ")"
});
Main.fontMouseText.MeasureString(text2);
Vector2 vector2 = Main.fontMouseText.MeasureString(text1);
if (Main.itemText[index].lifeTime < 0)
Main.itemText[index].scale = 1f;
if (Main.itemText[index].lifeTime < 60)
Main.itemText[index].lifeTime = 60;
if (flag && Main.itemText[index].coinText)
{
int num = 0;
if (newItem.itemId == 71)
num += newItem.stack;
else if (newItem.itemId == 72)
num += 100 * newItem.stack;
else if (newItem.itemId == 73)
num += 10000 * newItem.stack;
else if (newItem.itemId == 74)
num += 1000000 * newItem.stack;
Main.itemText[index].coinValue += num;
string text3 = ItemText.ValueToName(Main.itemText[index].coinValue);
vector2 = Main.fontMouseText.MeasureString(text3);
Main.itemText[index].name = text3;
if (Main.itemText[index].coinValue >= 1000000)
{
if (Main.itemText[index].lifeTime < 300)
Main.itemText[index].lifeTime = 300;
Main.itemText[index].color = new Color(220, 220, 198);
}
else if (Main.itemText[index].coinValue >= 10000)
{
if (Main.itemText[index].lifeTime < 240)
Main.itemText[index].lifeTime = 240;
Main.itemText[index].color = new Color(224, 201, 92);
}
else if (Main.itemText[index].coinValue >= 100)
{
if (Main.itemText[index].lifeTime < 180)
Main.itemText[index].lifeTime = 180;
Main.itemText[index].color = new Color(181, 192, 193);
}
else if (Main.itemText[index].coinValue >= 1)
{
if (Main.itemText[index].lifeTime < 120)
Main.itemText[index].lifeTime = 120;
Main.itemText[index].color = new Color(246, 138, 96);
}
}
Main.itemText[index].stack += stack;
Main.itemText[index].scale = 0.0f;
Main.itemText[index].rotation = 0.0f;
Main.itemText[index].position.X = (float)((double)newItem.position.X + (double)newItem.width * 0.5 - (double)vector2.X * 0.5);
Main.itemText[index].position.Y = (float)((double)newItem.position.Y + (double)newItem.height * 0.25 - (double)vector2.Y * 0.5);
Main.itemText[index].velocity.Y = -7f;
if (!Main.itemText[index].coinText)
return;
Main.itemText[index].stack = 1;
return;
}
}
int index1 = -1;
for (int index2 = 0; index2 < 20; ++index2)
{
if (!Main.itemText[index2].active)
{
index1 = index2;
break;
}
}
if (index1 == -1)
{
double num = (double)Main.bottomWorld;
for (int index2 = 0; index2 < 20; ++index2)
{
if (num > (double)Main.itemText[index2].position.Y)
{
index1 = index2;
//.........这里部分代码省略.........
示例14: NewText
public static void NewText(Item newItem, int stack)
{
if ((Main.showItemText && ((newItem.name != null) && newItem.active)) && (Main.netMode != 2))
{
for (int i = 0; i < 20; i++)
{
if (Main.itemText[i].active && (Main.itemText[i].name == newItem.name))
{
string text = string.Concat(new object[] { newItem.name, " (", Main.itemText[i].stack + stack, ")" });
string name = newItem.name;
if (Main.itemText[i].stack > 1)
{
object obj2 = name;
name = string.Concat(new object[] { obj2, " (", Main.itemText[i].stack, ")" });
}
Vector2 vector = Main.fontMouseText.MeasureString(name);
vector = Main.fontMouseText.MeasureString(text);
if (Main.itemText[i].lifeTime < 0)
{
Main.itemText[i].scale = 1f;
}
Main.itemText[i].lifeTime = 60;
ItemText text1 = Main.itemText[i];
text1.stack += stack;
Main.itemText[i].scale = 0f;
Main.itemText[i].rotation = 0f;
Main.itemText[i].position.X = (newItem.position.X + (newItem.width * 0.5f)) - (vector.X * 0.5f);
Main.itemText[i].position.Y = (newItem.position.Y + (newItem.height * 0.25f)) - (vector.Y * 0.5f);
Main.itemText[i].velocity.Y = -7f;
return;
}
}
int index = -1;
for (int j = 0; j < 20; j++)
{
if (!Main.itemText[j].active)
{
index = j;
break;
}
}
if (index == -1)
{
double bottomWorld = Main.bottomWorld;
for (int k = 0; k < 20; k++)
{
if (bottomWorld > Main.itemText[k].position.Y)
{
index = k;
bottomWorld = Main.itemText[k].position.Y;
}
}
}
if (index >= 0)
{
string str3 = newItem.AffixName();
if (stack > 1)
{
object obj3 = str3;
str3 = string.Concat(new object[] { obj3, " (", stack, ")" });
}
Vector2 vector2 = Main.fontMouseText.MeasureString(str3);
Main.itemText[index].alpha = 1f;
Main.itemText[index].alphaDir = -1;
Main.itemText[index].active = true;
Main.itemText[index].scale = 0f;
Main.itemText[index].rotation = 0f;
Main.itemText[index].position.X = (newItem.position.X + (newItem.width * 0.5f)) - (vector2.X * 0.5f);
Main.itemText[index].position.Y = (newItem.position.Y + (newItem.height * 0.25f)) - (vector2.Y * 0.5f);
Main.itemText[index].color = Color.White;
if (newItem.rare == 1)
{
Main.itemText[index].color = new Color(150, 150, 0xff);
}
else if (newItem.rare == 2)
{
Main.itemText[index].color = new Color(150, 0xff, 150);
}
else if (newItem.rare == 3)
{
Main.itemText[index].color = new Color(0xff, 200, 150);
}
else if (newItem.rare == 4)
{
Main.itemText[index].color = new Color(0xff, 150, 150);
}
else if (newItem.rare == 5)
{
Main.itemText[index].color = new Color(0xff, 150, 0xff);
}
else if (newItem.rare == -1)
{
Main.itemText[index].color = new Color(130, 130, 130);
}
else if (newItem.rare == 6)
{
Main.itemText[index].color = new Color(210, 160, 0xff);
}
Main.itemText[index].name = newItem.AffixName();
Main.itemText[index].stack = stack;
//.........这里部分代码省略.........
示例15: ParseData
// ParseData +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
private void ParseData( GetDataEventArgs args )
{
try
{
PacketTypes packet = args.MsgID;
using ( var data = new MemoryStream( args.Msg.readBuffer, args.Index, args.Length ) )
{
TSPlayer player = TShock.Players[args.Msg.whoAmI];
switch ( packet )
{
case PacketTypes.ChestItem:
{
string action, itemName;
short chestID = data.ReadInt16();
byte itemSlot = data.ReadInt8();
byte itemStack = data.ReadInt8();
byte prefix = data.ReadInt8();
short itemType = data.ReadInt16();
var oldItem = Main.chest[chestID].item[itemSlot];
if ( oldItem.name != null && oldItem.name.Length > 0 )
{
action = "cGet";
itemName = oldItem.name;
} // if
else
{
var newItem = new Item();
newItem.netDefaults( itemType );
newItem.Prefix( prefix );
newItem.AffixName();
action = "cPut";
itemName = newItem.name;
} // else
if ( itemType != prevItemType )
{
_ircClient.SendMessage( SendType.Message, _actionChannel,
string.Format( "{0} ({1}): {2}: {3}",
player.Name, player.Group.Name, action, itemName ) );
prevItemType = itemType;
} // if
break;
} // case
} // switch
} // using
} // try
catch ( Exception exception )
{
Console.WriteLine( exception.Message + "(" + exception.StackTrace + ")" );
} // catch
}