本文整理汇总了C#中ItemStack.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ItemStack.Add方法的具体用法?C# ItemStack.Add怎么用?C# ItemStack.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemStack
的用法示例。
在下文中一共展示了ItemStack.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addItem
internal void addItem(int itemID, int templateID, int X, int Y, int Z, int H, string Var)
{
CatalogueManager.itemTemplate Template = CatalogueManager.getTemplate(templateID);
int Length = 0;
int Width = 0;
if (Z == 2 || Z == 6)
{
Length = Template.Length;
Width = Template.Width;
}
else
{
Length = Template.Width;
Width = Template.Length;
}
for (int jX = X; jX < X + Width; jX++)
for (int jY = Y; jY < Y + Length; jY++)
{
ItemStack Stack = _Room._sqStack[jX, jY];
if (Stack == null)
{
if (Template.typeID != 2 && Template.typeID != 3)
{
Stack = new ItemStack();
Stack.Add(itemID);
}
}
else
Stack.Add(itemID);
_Room._sqState[jX, jY] = (Room.squareState)Template.typeID;
if (Template.typeID == 2 || Template.typeID == 3)
{
_Room._sqItemHeight[jX, jY] = H + Template.Height;
_Room._sqItemRot[jX, jY] = Convert.ToByte(Z);
}
else
{
if (Template.typeID == 4)
_Room._sqItemHeight[jX, jY] = H;
}
_Room._sqStack[jX, jY] = Stack;
}
FloorItem Item = new FloorItem(itemID, templateID, X, Y, Z, H, Var);
_Items.Add(itemID, Item);
}
示例2: placeItem
internal void placeItem(int itemID, int templateID, int X, int Y, byte typeID, byte Z)
{
if (_Items.ContainsKey(itemID))
return;
try
{
CatalogueManager.itemTemplate Template = CatalogueManager.getTemplate(templateID);
int Length = 0;
int Width = 0;
if (Z == 2 || Z == 6)
{
Length = Template.Length;
Width = Template.Width;
}
else
{
Length = Template.Width;
Width = Template.Length;
}
int testH = _Room._sqHeight[X, Y];
int H = testH;
if (_Room._sqStack[X, Y] != null)
{
FloorItem topItem = (FloorItem)_Items[_Room._sqStack[X, Y].topItemID()];
H = topItem.H + CatalogueManager.getTemplate(topItem.TypeDBID).Height;
}
for (int jX = X; jX < X + Width; jX++)
{
for (int jY = Y; jY < Y + Length; jY++)
{
if (_Room._sqUnit[jX, jY])
return;
Room.squareState jState = _Room._sqState[jX, jY];
if (jState != Room.squareState.Open)
{
if (jState == Room.squareState.Blocked)
{
if (_Room._sqStack[jX, jY] == null)
return;
else
{
FloorItem topItem = (FloorItem)_Items[_Room._sqStack[jX, jY].topItemID()];
CatalogueManager.itemTemplate topItemTemplate = CatalogueManager.getTemplate(topItem.TypeDBID);
if (topItemTemplate.Height == 0 || topItemTemplate.typeID == 2 || topItemTemplate.typeID == 3) // No stacking on seat/bed
return;
else
{
if (topItem.H + topItemTemplate.Height > H)
H = topItem.H + topItemTemplate.Height;
}
}
}
else
return;
}
}
}
for (int jX = X; jX < X + Width; jX++)
{
for (int jY = Y; jY < Y + Length; jY++)
{
ItemStack Stack = null;
if (_Room._sqStack[jX, jY] == null)
{
if ((Template.typeID == 1 && Template.Height > 0) || Template.typeID == 4)
{
Stack = new ItemStack();
Stack.Add(itemID);
}
}
else
{
Stack = _Room._sqStack[jX, jY];
Stack.Add(itemID);
}
_Room._sqState[jX, jY] = (Room.squareState)Template.typeID;
_Room._sqStack[jX, jY] = Stack;
if (Template.typeID == 2 || Template.typeID == 3)
{
_Room._sqItemHeight[jX, jY] = H + Template.Height;
_Room._sqItemRot[jX, jY] = Z;
}
else if (Template.typeID == 4)
_Room._sqItemHeight[jX, jY] = H;
}
}
MySQL.runQuery("UPDATE items SET room = '" + _Room.RoomID + "',tile = '" + X + "_" + Y + "',h = '" + Z + "' WHERE id = '" + itemID + "' LIMIT 1");
FloorItem Item = new FloorItem(itemID, templateID, X, Y, Z, H, "");
_Items.Add(itemID, Item);
_Room.sendData("A]" + Item.ToString());
}
catch { }
//.........这里部分代码省略.........
示例3: relocateItem
//.........这里部分代码省略.........
int oldWidth = 1;
if (Template.Length > 1 || Template.Width > 1)
{
if (Item.Z == 2 || Item.Z == 6)
{
oldLength = Template.Length;
oldWidth = Template.Width;
}
else
{
oldLength = Template.Width;
oldWidth = Template.Length;
}
}
for (int jX = Item.X; jX < Item.X + oldWidth; jX++)
{
for (int jY = Item.Y; jY < Item.Y + oldLength; jY++)
{
ItemStack Stack = _Room._sqStack[jX, jY];
if (Stack != null && Stack.Count > 1)
{
if (itemID == Stack.bottomItemID())
{
if (CatalogueManager.getTemplate(((FloorItem)_Items[Stack.topItemID()]).TypeDBID).typeID == 2)
_Room._sqState[jX, jY] = Room.squareState.Seat;
else
_Room._sqState[jX, jY] = Room.squareState.Open;
}
else if (itemID == Stack.topItemID())
{
FloorItem belowItem = (FloorItem)_Items[Stack.getBelowItemID(itemID)];
int typeID = CatalogueManager.getTemplate(belowItem.TypeDBID).typeID;
_Room._sqState[jX, jY] = (Room.squareState)typeID;
if (typeID == 2 || typeID == 3)
{
_Room._sqItemRot[jX, jY] = (byte)belowItem.Z;
_Room._sqItemHeight[jX, jY] = belowItem.H + CatalogueManager.getTemplate(belowItem.TypeDBID).Height;
}
else if (typeID == 4)
_Room._sqItemHeight[jX, jY] = belowItem.H;
}
Stack.Remove(itemID);
_Room._sqStack[jX, jY] = Stack;
}
else
{
_Room._sqState[jX, jY] = 0;
_Room._sqItemHeight[jX, jY] = 0;
_Room._sqItemRot[jX, jY] = 0;
_Room._sqStack[jX, jY] = null;
}
if (Template.typeID == 2 || Template.typeID == 3)
_Room.refreshCoord(jX, jY);
}
}
Item.X = X;
Item.Y = Y;
Item.Z = Z;
Item.H = H;
//_Room.sendData("A_" + Item.ToString());
//DB.runQuery("UPDATE furniture SET x = '" + X + "',y = '" + Y + "',z = '" + Z + "',h = '" + H.ToString().Replace(',', '.') + "' WHERE id = '" + itemID + "' LIMIT 1");
for (int jX = X; jX < X + Width; jX++)
{
for (int jY = Y; jY < Y + Length; jY++)
{
ItemStack Stack = null;
if (_Room._sqStack[jX, jY] == null)
{
if (Template.Height > 0 && Template.typeID != 2 && Template.typeID != 3 && Template.typeID != 4)
{
Stack = new ItemStack();
Stack.Add(itemID);
}
}
else
{
Stack = _Room._sqStack[jX, jY];
Stack.Add(itemID);
}
_Room._sqState[jX, jY] = (Room.squareState)Template.typeID;
_Room._sqStack[jX, jY] = Stack;
if (Template.typeID == 2 || Template.typeID == 3)
{
_Room._sqItemHeight[jX, jY] = H + Template.Height;
_Room._sqItemRot[jX, jY] = Z;
_Room.refreshCoord(jX, jY);
}
else if (Template.typeID == 4)
_Room._sqItemHeight[jX, jY] = H;
}
}
}
catch { }
}