void ShowToolTip(LootStats ls) { Text nameTxt = transform.Find("Item Name").GetComponent <Text>(); Text statsTxt = transform.Find("Stats").GetComponent <Text>(); nameTxt.color = rarityColor.RarityColors[ls.Rarity]; if (ls.IsIdentified()) { nameTxt.text = ls.name; statsTxt.text = ""; foreach (ItemMod im in ls.itemMods) { if (statsTxt.text != "") { statsTxt.text += "\n"; } statsTxt.text += im.Stat.ToString() + (im.Value >= 0 ? " +" : " ") + im.Value; } } else { // NOT IDENTIFIED nameTxt.text = "UNIDENTIFIED"; statsTxt.text = ls.IdentTimeLeft().ToString("#.##"); } this.transform.SetAsLastSibling(); Tooltip.Show(); }
/// <summary> /// Return the "true" bag slot that this item will get placed in, /// or null if there's no space here /// </summary> /// <param name="l"></param> /// <returns></returns> public BagSlot CanDropHere(Loot l) { if (Backpack == null) { // This is char inventory LootStats ls = l.GetComponent <LootStats>(); if (ls.IsIdentified() == false || ls.itemType.ToString() != this.gameObject.name) { return(null); } return(this); } int x = PosX; int y = PosY; // First, correct if we're too close to the edge if (x + l.GridWidth > Backpack.BagWidth) { x = Backpack.BagWidth - l.GridWidth; } if (y + l.GridHeight > Backpack.BagHeight) { y = Backpack.BagHeight - l.GridHeight; } if (x != PosX || y != PosY) { // position was corrected, so send job to new tile return(Backpack.GetSlotAt(x, y)); } // Correct bag slot, so check that all slots that will be used for this item // have at most one other item if (Backpack.GetLootsInArea(x, y, l.GridWidth, l.GridHeight).Length > 1) { // Not a valid tile for placement return(null); } return(this); }