private static void RepairClickedItem(InventoryGrid grid, UIInputHandler element, Inventory inventory) { Vector2i buttonPos = Traverse.Create(grid).Method("GetButtonPos", new object[] { element.gameObject }).GetValue <Vector2i>(); ItemDrop.ItemData itemData = inventory.GetItemAt(buttonPos.x, buttonPos.y); if (itemData == null) { return; } if (Traverse.Create(InventoryGui.instance).Method("CanRepair", new object[] { itemData }).GetValue <bool>()) { CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); itemData.m_durability = itemData.GetMaxDurability(); if (currentCraftingStation) { currentCraftingStation.m_repairItemDoneEffects.Create(currentCraftingStation.transform.position, Quaternion.identity, null, 1f); } Player.m_localPlayer.Message(MessageHud.MessageType.Center, Localization.instance.Localize("$msg_repaired", new string[] { itemData.m_shared.m_name }), 0, null); } }
static void Postfix(InventoryGrid ___m_playerGrid) { if (!modEnabled.Value || !addEquipmentRow.Value) { return; } Traverse t = Traverse.Create(Player.m_localPlayer); Inventory inv = Player.m_localPlayer.GetInventory(); int offset = inv.GetWidth() * (inv.GetHeight() - 1); SetSlotText(helmetText.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++)); SetSlotText(chestText.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++)); SetSlotText(legsText.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++)); SetSlotText(backText.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++)); SetSlotText(utilityText.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++)); SetSlotText(hotKey1.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++), false); SetSlotText(hotKey2.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++), false); SetSlotText(hotKey3.Value, ___m_playerGrid.m_gridRoot.transform.GetChild(offset++), false); if (displayEquipmentRowSeparate.Value) { offset = inv.GetWidth() * (inv.GetHeight() - 1); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(678, 0); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(748, -35); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(678, -70); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(748, -105); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(678, -140); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(643, -210); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(713, -210); ___m_playerGrid.m_gridRoot.transform.GetChild(offset++).GetComponent <RectTransform>().anchoredPosition = new Vector2(783, -210); } }
protected void InventoryGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { if (e.CommandName.StartsWith("Do_")) { switch (e.CommandName) { case "Do_Pub": // TOGGLE VISIBILITY int productId = AlwaysConvert.ToInt(e.CommandArgument); Product product = ProductDataSource.Load(productId); switch (product.Visibility) { case CatalogVisibility.Public: product.Visibility = CatalogVisibility.Hidden; break; case CatalogVisibility.Hidden: product.Visibility = CatalogVisibility.Private; break; default: product.Visibility = CatalogVisibility.Public; break; } product.Save(); InventoryGrid.DataBind(); break; } } }
// Use this for initialization void Start() { if (networkView.isMine) { myTransform = transform; firePointTransform = myTransform.FindChild("FirePoint"); menu = GameObject.Find("MultiplayerManager").GetComponent <Menu>(); inv = gameObject.GetComponent <InventoryGrid>(); sk = gameObject.GetComponent <ShopKeeper>(); spawn = GameObject.Find("SpawnManager").GetComponent <SpawnScript>(); if (spawn.amIOnTheRedTeam) { iAmOnTheRedTeam = true; } if (spawn.amIOnTheBlueTeam) { iAmOnTheBlueTeam = true; } } else { enabled = false; } source = gameObject.GetComponent <AudioSource>(); }
private void PlaceItem(GridItem item) { if (item.Orientation == GridItemOrient.Landscape) { item.Sprite.pivot = UIWidget.Pivot.BottomLeft; } else { item.Sprite.pivot = UIWidget.Pivot.TopLeft; } item.Sprite.transform.parent = item.Boundary.transform.parent; item.Sprite.depth = (int)InventoryItemDepth.Normal; item.transform.localPosition = item.Boundary.transform.localPosition; InventoryGrid grid = item.transform.parent.GetComponent <InventoryGrid>(); grid.GetColumnRowFromLocalPos(item.transform.localPosition, out item.ColumnPos, out item.RowPos); item.Quantity.transform.parent = item.Sprite.transform.parent; item.Quantity.transform.localPosition = item.Sprite.transform.localPosition + new Vector3(4, 4, 0); NGUITools.AddWidgetCollider(item.gameObject); NGUITools.MarkParentAsChanged(_windowPanel.gameObject); //item.State = GridItemState.None; item.Initialize(FocusedGrid); FocusedGrid.Items.Add(item); SelectedItem = null; FocusedBodySlot = null; GameManager.Inst.SoundManager.UI.PlayOneShot(GameManager.Inst.SoundManager.GetClip("PlaceItemBackpack"), 0.2f); }
private void InventoryForm_VisibleChanged(object sender, EventArgs e) { if (Visible && inventoryID == -1) { InventoryGrid.ClearSelection(); } }
public static bool Prefix(InventoryGui __instance, InventoryGrid grid, ItemDrop.ItemData item, Vector2i pos, InventoryGrid.Modifier mod) { // if we're not moving from the spellbars, do nothing (normal flow) if (__instance.m_dragInventory?.m_name != "spellsBarInventory") { return(true); } // if we moving TO the spellsbars, do nothing (normal flow) if (grid.m_inventory?.m_name == "spellsBarInventory") { return(true); } // so if we're moving from the spellsbar to another inventory ItemDrop.ItemData itemAt = grid.GetInventory().GetItemAt(pos.x, pos.y); if (itemAt != null) { // and there is an item at the destination var runeData = itemAt.GetRuneData(); // and its not a rune if (runeData == null) { // we cant swap that! Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You can't swap a rune for a non-rune item."); return(false); } } return(true); }
public override void OnInspectorGUI() { DrawDefaultInspector(); grid = (target as InventoryGrid); parent = grid.transform.parent.GetComponent <RectTransform>(); triger = GUILayout.Toggle(triger, "Resize parent"); try { Refresh(); } catch (InvalidOperationException prefabException) { Debug.LogError("No Panic-" + prefabException.Message); } if (GUILayout.Button("Создать - обновить сетку")) { Refresh(); grid.ConstructGrid(); } if (GUILayout.Button("Удалить сетку")) { grid.DisposeGrid(); } }
// Use this for initialization void Start() { if (networkView.isMine) { shopButton = new Rect(nativeWidth - 560, nativeHeight - 50, 100, 40); hoverBox = new Rect(nativeWidth / 2 - 280, nativeHeight / 2 - 250, 200, 200); hoverLabel = new Rect(nativeWidth / 2 - 275, nativeHeight / 2 - 230, 190, 190); tex = null; inv = gameObject.GetComponent <InventoryGrid>(); spawn = GameObject.Find("SpawnManager").GetComponent <SpawnScript>(); soundEffects = GameObject.Find("AudioEffectsManager").GetComponent <SoundEffects>(); itemBuyValue = new float[6] { 40f, 50f, 30f, 25f, 60f, 20f }; itemSellValue = new float[6] { 20f, 25f, 15f, 10f, 30f, 10f }; typeOfPotion = new string[6] { "Health", "Mana", "Speed", "Attack Damage", "Max Health", "Spell Damage" }; itemEffectValue = new int[6] { 30, 40, 100, 20, 50, 20 }; } else { enabled = false; } }
public Vendor(World world, int snoId, TagMap tags) : base(world, snoId, tags) { this.Attributes[GameAttribute.MinimapActive] = true; _vendorGrid = new InventoryGrid(this, 1, 20, (int)EquipmentSlotId.Vendor); PopulateItems(); }
public Inventory(Player owner) { this._owner = owner; this._equipment = new Equipment(owner); this._inventoryGrid = new InventoryGrid(owner, owner.Attributes[GameAttribute.Backpack_Slots] / 10, 10); this._stashGrid = new InventoryGrid(owner, owner.Attributes[GameAttribute.Shared_Stash_Slots] / 7, 7, (int)EquipmentSlotId.Stash); this._skillSocketRunes = new uint[6]; }
// Start is called before the first frame update void Start() { inventoryGrid = FindObjectOfType <InventoryGrid>(); colorManager = FindObjectOfType <ColorManager>(); GenerateItem(); CreateTriggers(); }
static bool Prefix(InventoryGrid __instance, UIInputHandler element, Inventory ___m_inventory) { if (modEnabled.Value && AedenthornUtils.CheckKeyHeld(modKey.Value) && !leftClick.Value && InventoryGui.instance) { RepairClickedItem(__instance, element, ___m_inventory); return(false); } return(true); }
static void Postfix(InventoryGrid ___m_playerGrid) { if (!modEnabled.Value) { return; } ___m_playerGrid.m_onSelected = (Action <InventoryGrid, ItemDrop.ItemData, Vector2i, InventoryGrid.Modifier>)Delegate.Combine(___m_playerGrid.m_onSelected, new Action <InventoryGrid, ItemDrop.ItemData, Vector2i, InventoryGrid.Modifier>(OnSelectedItem)); }
void Start() { inventoryGrid = GetComponent <InventoryGrid>(); for (var i = 0; i < differentItems; i++) { inventory.Add(0); } }
public static void Postfix(ref InventoryGui __instance, ref InventoryGrid ___m_playerGrid) { RectTransform container = __instance.m_container; RectTransform player = __instance.m_player; player.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 494); container.offsetMax = new Vector2(610, -582); container.offsetMin = new Vector2(40, -924); }
private void Awake() { parentObj = GameObject.FindGameObjectWithTag("InventoryCanvas"); equipGrid = GameObject.FindGameObjectWithTag("EquipGrid").GetComponent <InventoryGrid>(); useGrid = GameObject.FindGameObjectWithTag("UseGrid").GetComponent <InventoryGrid>(); etcGrid = GameObject.FindGameObjectWithTag("EtcGrid").GetComponent <InventoryGrid>(); itemDB = GameObject.FindGameObjectWithTag("GameController").GetComponent <ItemDB>(); }
public void SimpleEnter(int index) { if (index >= currentContent.Count) { return; } Audio.PlaySound("Select"); items[index].img.enabled = true; currentDetail = InventoryGrid.ShowItemDetails(currentContent[index].item, detailPos.position, transform.parent); }
private void Awake() { elements = I_elements; inventoryGrid = I_inventoryGrid; usedMat = I_usedMat; grayScaleMat = I_grayScaleMat; inventoryGrid.Initialize(boardRadius, tileXDelta, centerPos); inventoryGrid.CreateGrid(); }
protected override void OnDragDropStart() { base.OnDragDropStart(); transform.parent = transform.root.Find("Panel_top").transform; InventoryGrid ig = this.GetComponent <InventoryGrid>(); ig.SetDragItem(); num = ig.count; drugID = ig.ID; }
public Vendor(World world, int snoId, TagMap tags) : base(world, snoId, tags) { // Interactions.Add(new Unknown4Interaction()); // Interactions.Add(new InventoryInteraction()); this.Field7 = 1; this.Attributes[GameAttribute.MinimapActive] = true; ItemCreated = false; _vendorGrid = new InventoryGrid(this, 1, 100, (int)EquipmentSlotId.Vendor); //PopulateItems(); }
/// <summary> /// 设置物品信息 /// </summary> /// <param name="item"></param> public void SetItem(MarketItem item) { InventoryGrid grid = goItem.GetComponent <InventoryGrid>(); if (grid == null) { grid = goItem.AddComponent <InventoryGrid>(); } if (item.marketItemType == MarkItemType.MarketItem) { grid.iconID = item.resData.itemId; } if (item.marketItemType == MarkItemType.LevelPacks) { grid.iconID = (item as GiftItem).resData.item; } if (item.marketItemType == MarkItemType.WingItem) { grid.iconID = item.resData.itemId; } // 物品BoxCollider区域添加滑动 MogoButton mogoButton = goItem.GetComponent <MogoButton>(); if (mogoButton == null) { mogoButton = goItem.AddComponent <MogoButton>(); } mogoButton.pressHandler = MarketView.Instance.ListView.PressHandlerOutSide; mogoButton.dragHandler = MarketView.Instance.ListView.DragHandlerOutSide; ResetItem(); data = item; m_lblItemName.text = data.name; // 设置Grid的名称 switch (data.marketItemType) { case MarkItemType.MarketItem: case MarkItemType.WingItem: //m_lblItemName.effectStyle = UILabel.Effect.None; SetMarketItem(); // 商城出售物品,翅膀 break; case MarkItemType.LevelPacks: //m_lblItemName.effectStyle = UILabel.Effect.Outline; //m_lblItemName.effectColor = new Color32(50, 39, 9, 255); SetLevelPacks(); // 等级礼包 break; default: break; } }
public static void Postfix(InventoryGrid __instance) { foreach (ItemDrop.ItemData item in __instance.m_inventory.m_inventory) { InventoryGrid.Element element = __instance.GetElement(item.m_gridPos.x, item.m_gridPos.y, __instance.m_width); if (element != null && item.HasMagicEffect(MagicEffectType.Indestructible)) { element.m_durability.gameObject.SetActive(false); } } }
void Start() { var rect = GetComponent <RectTransform>(); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, items[turnPhase].GetYSize() * size.y); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, items[turnPhase].GetXSize() * size.x); group = GetComponent <CanvasGroup>(); grid = GetComponentInParent <InventoryGrid>(); }
public static void UnsetMostThings() { invBarGrid = null; hotkeysGrid = null; invBarRect = null; hotkeysRect = null; mapBindingText = new Dictionary <string, Text>(); mapRankText = new Dictionary <string, Text>(); mapCooldownText = new Dictionary <string, Text>(); isVisible = false; }
public static void Postfix(InventoryGrid __instance, Player player, ItemDrop.ItemData dragItem) { foreach (var element in __instance.m_elements) { var magicItemTransform = element.m_go.transform.Find("magicItem"); if (magicItemTransform != null) { var magicItem = magicItemTransform.GetComponent <Image>(); if (magicItem != null) { magicItem.enabled = false; } } var setItemTransform = element.m_go.transform.Find("setItem"); if (setItemTransform != null) { var setItem = setItemTransform.GetComponent <Image>(); if (setItem != null) { setItem.enabled = false; } } } foreach (var item in __instance.m_inventory.m_inventory) { var element = __instance.GetElement(item.m_gridPos.x, item.m_gridPos.y, __instance.m_inventory.GetWidth()); if (element == null) { EpicLoot.LogError($"Could not find element for item ({item.m_shared.m_name}: {item.m_gridPos}) in inventory: {__instance.m_inventory.m_name}"); continue; } var magicItem = ItemBackgroundHelper.CreateAndGetMagicItemBackgroundImage(element.m_go, element.m_equiped.gameObject, true); if (item.UseMagicBackground()) { magicItem.enabled = true; magicItem.sprite = EpicLoot.GetMagicItemBgSprite(); magicItem.color = item.GetRarityColor(); } var setItemTransform = element.m_go.transform.Find("setItem"); if (setItemTransform != null) { var setItem = setItemTransform.GetComponent <Image>(); if (setItem != null) { setItem.enabled = item.IsSetItem(); } } } }
//Sell items from kanp public void SellItem() { float price = clickItem.it.sellPrice * clickItem.count; int value = int.Parse(coinLabel.text); coinLabel.text = (value + price).ToString(); //clear grid and info clickItem.count = 0; clickItem.Clear(); desLabel.text = ""; clickItem = null; }
/// <summary> /// Resizes the inventory panel, taking into account the number of rows/columns, the padding and margin /// </summary> protected void ResizeInventoryDisplay() { float newWidth = PaddingLeft + SlotSize.x * NumberOfColumns + SlotMargin.x * (NumberOfColumns - 1) + PaddingRight; float newHeight = PaddingTop + SlotSize.y * NumberOfRows + SlotMargin.y * (NumberOfRows - 1) + PaddingBottom; TargetInventory.ResizeArray(NumberOfRows * NumberOfColumns); Vector2 newSize = new Vector2(newWidth, newHeight); InventoryRectTransform.sizeDelta = newSize; InventoryGrid.GetComponent <RectTransform>().sizeDelta = newSize; }
private void EquipmentItemDetails(int obj) { var info = typeof(CharacterEquipment).GetField(types[obj]); if (info.GetValue(CharacterStats.characterEquipment) != null) { InventoryItems item = info.GetValue(CharacterStats.characterEquipment) as InventoryItems; Vector2 pos = transform.GetChild(obj).transform.position; pos = obj < 4 ? pos : new Vector2(pos.x - 2f, pos.y); _obj = InventoryGrid.ShowItemDetails(item, pos, transform, true); } }
internal void Init(InventoryGrid data, GridPos gp) { Data = data; Data.SetStateHandler = OnSetState; if (ShowGridPosDebugText) { GridPosText.text = gp.ToString(); } else { GridPosText.text = ""; } }
public void Initialize(InventoryGrid grid) { _grid = grid; State = GridItemState.None; }
private bool FindNearestGridSlot(List<InventoryGrid> grids, out int fitColumn, out int fitRow) { fitColumn = 0; fitRow = 0; Vector3 bottomLeftPos = SelectedItem.transform.localPosition - new Vector3(SelectedItem.ColumnSize * BackpackGrid.BlockSize / 2, SelectedItem.RowSize * BackpackGrid.BlockSize / 2, 0); Vector3 centerPos = SelectedItem.transform.localPosition; //see which grid we are at FocusedGrid = null; foreach(InventoryGrid grid in grids) { if(centerPos.x >= grid.Grid.transform.localPosition.x && centerPos.x <= grid.Grid.transform.localPosition.x + grid.Columns * grid.BlockSize && centerPos.y >= grid.Grid.transform.localPosition.y && centerPos.y <= grid.Grid.transform.localPosition.y + grid.Rows * grid.BlockSize) { FocusedGrid = grid; } } if(FocusedGrid == null) { return false; } //starting from 1 block down-left of bottomLeftPos, check if there's room to fit the item int col = 0; int row = 0; bool result = false; int [] xArray = new int[]{0, -1, 0, -1, 1, 0, 1}; int [] yArray = new int[]{0, -1, -1, 0, 0, 1, 1}; int count = 0; while(!result && count < 7) { result = FocusedGrid.GetColumnRowFromPos(bottomLeftPos + new Vector3(BackpackGrid.BlockSize * xArray[count], BackpackGrid.BlockSize * yArray[count], 0), out col, out row); if(result) { //check if this col/row can fit the item GridItem replace = null; if(ReplaceItem != null) { ReplaceItem.Sprite.alpha = 1; } if(FocusedGrid.CanItemFitHere(col, row, SelectedItem.ColumnSize, SelectedItem.RowSize, out replace)) { ReplaceItem = replace; if(ReplaceItem != null) { ReplaceItem.Sprite.alpha = 0.5f; } fitColumn = col; fitRow = row; return true; } } count++; } if(!result) { return false; } return false; }