本文整理汇总了C#中ItemSlot类的典型用法代码示例。如果您正苦于以下问题:C# ItemSlot类的具体用法?C# ItemSlot怎么用?C# ItemSlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemSlot类属于命名空间,在下文中一共展示了ItemSlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Raycast
/// <summary>
/// Raycasts from the mouse
/// returns true if something was hit
///
/// uses out to return relevant menu scripts
///
/// </summary>
/// <param name="hitInfo"></param>
/// <param name="items"></param>
/// <param name="itemSlots"></param>
/// <returns></returns>
public bool Raycast(out RaycastHit[] hitInfo, out Item[] items, out ItemSlot[] itemSlots)
{
items = new Item[0];
itemSlots = new ItemSlot[0];
hitInfo = Physics.RaycastAll (m_MainCamera.ScreenPointToRay (Input.mousePosition), RAYCAST_DISTANCE, m_RaycastMask.value);
Debug.DrawLine (m_MainCamera.ScreenPointToRay(Input.mousePosition).origin, m_MainCamera.ScreenPointToRay(Input.mousePosition).origin + (m_MainCamera.ScreenPointToRay(Input.mousePosition).direction * RAYCAST_DISTANCE), Color.black, 1.0f);
if(hitInfo.Length > 0)
{//hit at least one menu thing
List<Item> itemsFound = new List<Item>();
List<ItemSlot> itemSlotsFound = new List<ItemSlot>();
for(int i = 0; i < hitInfo.Length; i++)
{
Item item = hitInfo[i].collider.gameObject.GetComponent<Item>();
if (item != null)
itemsFound.Add(item);
ItemSlot itemSlot = hitInfo[i].collider.gameObject.GetComponent<ItemSlot>();
if (itemSlot != null)
itemSlotsFound.Add(itemSlot);
}
items = itemsFound.ToArray();
itemSlots = itemSlotsFound.ToArray();
return true;
}
return false;
}
示例2: DrawItem
/// <summary>
/// Отрисовка предмета в инвентаре
/// </summary>
/// <param name="item">Рисуемый предмет</param>
/// <param name="offsetX">Смещение (позиция) инвентаря по x</param>
/// <param name="offsetY">Смещение (позиция) инвентаря по y</param>
/// <param name="fixWebPosition">при fixWebPosition=true предмет рисуется "в сетке"</param>
/// <param name="drawIcon">при drawIcon=false, предмет рисуется без иконки</param>
public void DrawItem(ItemSlot item, float offsetX, float offsetY, bool fixWebPosition = true, bool drawIcon = true)
{
Rect cellRectangle;
if (fixWebPosition) {
cellRectangle = new Rect(offsetX + CellSettings.cellPaddingX + (item.position.X - 1) * CellSettings.cellWidth+shadowSize,
offsetY + CellSettings.cellPaddingY + (item.position.Y - 1) * CellSettings.cellHeight+shadowSize,
CellSettings.cellWidth,
CellSettings.cellHeight);
} else {
cellRectangle = new Rect(offsetX+shadowSize,
offsetY+shadowSize,
CellSettings.cellWidth,
CellSettings.cellHeight);
}
string description = item.item.getCount()>1? item.item.getCount().ToString()+CLang.getInstance().get(Dictionary.K_COUNT) : "";
GUI.Box(cellRectangle, description, labelShadow);
cellRectangle.x-=shadowSize;
cellRectangle.y-=shadowSize;
if (drawIcon)
labelStyle.normal.background = item.item.resource.icon;
GUI.color = new Color(1f,1f,1f,1f);
GUI.Box(cellRectangle, description, labelStyle);
}
示例3: CraftingGrid
public CraftingGrid(GameWorld GameWorld, Vector2 Position)
{
this.Position = Position;
RecipePartIdMatching = new int[5, 5];
for (int y = 0; y < 5; y++)
{
for (int x = 0; x < 5; x++)
{
RecipeSlots[x, y] = new ItemSlot(GameWorld);
RecipeSlots[x, y].Visible = true;
Vector2 UpperLeftPos = Position + new Vector2(x * 34, y * 34);
RecipeSlots[x, y].Position = new Rectangle((int)UpperLeftPos.X, (int)UpperLeftPos.Y, 32, 32);
RecipeSlots[x, y].OnStackModified += UpdateGrid;
RecipePartIdMatching[x, y] = -1;
}
}
OutputSlot = new ItemSlot(GameWorld);
OutputSlot.Visible = true;
OutputSlot.State = ItemSlot.SlotState.InputLocked;
OutputSlot.Position = new Rectangle((int)Position.X + 5 * 32 + 10, (int)Position.Y + 2 * 32, 32, 32);
OutputSlot.OnStackModified += ItemCrafted;
}
示例4: SwapItemsNoReAdding
public static void SwapItemsNoReAdding(ItemSlot slot1, ItemSlot slot2)
{
Item tempItem = slot1.getItem();
slot1.m_Item = slot2.getItem();
slot2.m_Item = tempItem;
slot1.getItem().OnMount(slot1);
slot2.getItem().OnMount(slot2);
}
示例5: DrawCellsItem
public void DrawCellsItem(float offsetX, float offsetY, ItemSlot item, Texture2D image)
{
Rect cellRect = new Rect();
cellRect.x = offsetX + (item.getPosition().X - 1) * CellSettings.cellWidth + CellSettings.cellPaddingX;
cellRect.y = offsetY + (item.getPosition().Y - 1) * CellSettings.cellHeight + CellSettings.cellPaddingY;
cellRect.width = CellSettings.cellWidth * item.item.getSize().getWidth();
cellRect.height = CellSettings.cellHeight * item.item.getSize().getHeight();
GUI.DrawTextureWithTexCoords(cellRect, image, textCoords);
}
示例6: Swap
public void Swap (ItemSlot other) {
if (!CanSwap (other))
return;
var swapper = other.currentItem;
other.currentItem = currentItem;
currentItem = swapper;
RestoreItem ();
other.RestoreItem ();
}
示例7: SetItem
public EquipmentItem SetItem(ItemSlot slot, EquipmentItem item)
{
if (!(item is EquipmentItem))
return null;
var eqItem = item as EquipmentItem;
if (eqItem.RequiredSpecialisation != Specialisation.NONE
&& eqItem.RequiredSpecialisation != this.Specialisation)
return null;
EquipmentItem oldItem = null;
if (Items.ContainsKey(slot))
oldItem = Items[slot];
Items[slot] = eqItem;
return oldItem;
}
示例8: UnitInventory
/// <summary>
/// C'tor
/// </summary>
/// <param name="_slotsData">Data about slot: slot key && available item types for the slot</param>
/// <param name="onEquipmentUpdate"></param>
public UnitInventory(Dictionary<EUnitEqupmentSlot, EItemType[]> _slotsData, ArrayRO<ItemSlot> _initialItems, Action<EUnitEqupmentSlot, EItemKey, EItemKey> onEquipmentUpdate) {
_slotsConfig = _slotsData;
_equipment = new ItemSlot[_slotsConfig.Count];
int i = 0;
foreach(KeyValuePair<EUnitEqupmentSlot, EItemType[]> kvp in _slotsConfig) {
_equipment[i] = new ItemSlot(kvp.Key, EItemKey.None);
i++;
}
for (i = 0; i < _initialItems.Length; i++) {
Equip(_initialItems[i].SlotName, _initialItems[i].ItemKey);
}
_onEquipmentUpdate = onEquipmentUpdate;
}
示例9: Show
public void Show(ItemSlot itemSlot)
{
Vector3 pos = Input.mousePosition;
pos.x = Mathf.Clamp01(pos.x / Screen.width);
pos.y = Mathf.Clamp01(pos.y / Screen.height);
if(_tempRightClick == null)
{
_itemSlot = itemSlot;
_tempRightClick = NGUITools.AddChild(this.gameObject.transform.parent.gameObject, RightClickPrefab);
_tempRightClick.transform.position = _camera.ViewportToWorldPoint(pos);
RightClickMaker m = _tempRightClick.GetComponent<RightClickMaker>();
m.Make(_itemSlot);
}
}
示例10: SetItemInSlot
private void SetItemInSlot(Item value, ItemSlot slot)
{
if (!CanEquip(value, slot))
return;
var old = Equip.FirstOrDefault(i => i.Slot == slot);
if (old != null)
{
Equip.Remove(old);
old.Slot = ItemSlot.Unequipable;
}
if (value != null)
{
value.Slot = slot;
Equip.Add(value);
}
OnPropertyChanged(slot.ToString());
RefreshItemAttributes();
}
示例11: JsonDeserializer
// Reader
public static object JsonDeserializer(Jboy.JsonReader reader)
{
if(reader.TryReadNull())
return null;
var itemSlot = new ItemSlot();
reader.ReadObjectStart();
// ID
reader.ReadPropertyName("item");
itemSlot.item = Jboy.Json.ReadObject<Item>(reader);
// Count
reader.ReadPropertyName("count");
itemSlot.count = (ulong)reader.ReadNumber();
reader.ReadObjectEnd();
return itemSlot;
}
示例12: SetEquipStatus
void SetEquipStatus(ItemSlot itemSlot)
{
var type = itemSlot.GetType();
if(type == typeof(StorageSlot))
{
EquipButton.SetActive(true);
UnequipButton.SetActive(false);
}
else if(type == typeof(EquipmentSlot))
{
EquipButton.SetActive(false);
UnequipButton.SetActive(true);
}
else
{
EquipButton.SetActive(false);
UnequipButton.SetActive(true);
}
}
示例13: Make
public void Make(ItemSlot itemSlot)
{
Item item = itemSlot.item;
SetStackable(item);
switch(item.Type)
{
case ItemType.Armor:
SetArmorButtons(itemSlot);
break;
case ItemType.Consumable:
SetConsumable(itemSlot);
break;
case ItemType.Enhancer:
SetEnhancer(itemSlot);
break;
case ItemType.Generator:
SetGenerator(itemSlot);
break;
case ItemType.LaserWeapon:
SetLaserWeapon(itemSlot);
break;
case ItemType.LegacyWeapon:
SetLegacyWeapon(itemSlot);
break;
case ItemType.MagneticWeapon:
SetMagneticWeapon(itemSlot);
break;
case ItemType.Melee:
SetMelee(itemSlot);
break;
case ItemType.Misc:
SetMisc(itemSlot);
break;
case ItemType.Quest:
SetQuest(itemSlot);
break;
}
}
示例14: GetEquippedBySlot
public ushort GetEquippedBySlot(ItemSlot slot)
{
Equip eqp;
if (EquippedItems.TryGetValue(slot, out eqp))
{
return eqp.ItemID;
}
else return ushort.MaxValue;
}
示例15: RaiseSmthMoveItem
// called by engine
void RaiseSmthMoveItem(Critter from_cr, Item item, ItemSlot from_slot)
{
if (SmthMoveItem != null)
SmthMoveItem(this, new CritterSmthMoveItemEventArgs(this, from_cr, item, from_slot));
}