示例#1
0
        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            var item = Trade.CurrentSchema.GetItem(schemaItem.Defindex);

            Log.Success("User added: " + schemaItem.ItemName);
            if (invalidItem >= 4)
            {
                Trade.CancelTrade();
                Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Stop messing around. This bot is used for scrapbanking, and will only accept craftable weapons.");
            }
            else if ((item.CraftClass == "weapon" || item.CraftMaterialType == "weapon") && !inventoryItem.IsNotCraftable)
            {
                userWepAdded++;
                UnverifiedAmount += TF2Value.Scrap * 0.5;
            }
            else if (item.Defindex == 5000)
            {
                UnverifiedAmount += TF2Value.Scrap;
            }
            else if (item.Defindex == 5001)
            {
                UnverifiedAmount += TF2Value.Reclaimed;
            }
            else if (item.Defindex == 5002)
            {
                UnverifiedAmount += TF2Value.Refined;
            }
            else
            {
                Trade.SendMessage(schemaItem.ItemName + " is not a valid item! Please remove it from the trade.");
                invalidItem++;
            }
            SendTradeMessage("I now owe you: {0} ref, {1} rec, and {2} scrap", UnverifiedAmount.RefinedPart, UnverifiedAmount.ReclaimedPart, UnverifiedAmount.ScrapPart);
        }
示例#2
0
        public override void OnTradeRemoveItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            var item = Trade.CurrentSchema.GetItem(schemaItem.Defindex);

            Log.Success("User removed: " + schemaItem.ItemName);
            if ((item.CraftClass == "weapon" || item.CraftMaterialType == "weapon") && !inventoryItem.IsNotCraftable)
            {
                userWepAdded--;
                UnverifiedAmount -= TF2Value.Scrap * 0.5;
            }
            else if (item.Defindex == 5000)
            {
                UnverifiedAmount -= TF2Value.Scrap;
            }
            else if (item.Defindex == 5001)
            {
                UnverifiedAmount -= TF2Value.Reclaimed;
            }
            else if (item.Defindex == 5002)
            {
                UnverifiedAmount -= TF2Value.Refined;
            }
            else
            {
                invalidItem--;
            }
            SendTradeMessage("I now owe you: {0} ref, {1} rec, and {2} scrap", UnverifiedAmount.RefinedPart, UnverifiedAmount.ReclaimedPart, UnverifiedAmount.ScrapPart);
        }
示例#3
0
 public override void OnTradeRemoveItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
 {
     if (ActiveOrder != null && ActiveOrder.MatchesItem(inventoryItem))
     {
         ActiveOrder = null;
         Trade.RemoveAllItems();
     }
     else
     {
         if (schemaItem.Defindex == TF2Value.SCRAP_DEFINDEX)
         {
             AmountAdded -= TF2Value.Scrap;
         }
         else if (schemaItem.Defindex == TF2Value.RECLAIMED_DEFINDEX)
         {
             AmountAdded -= TF2Value.Reclaimed;
         }
         else if (schemaItem.Defindex == TF2Value.REFINED_DEFINDEX)
         {
             AmountAdded -= TF2Value.Refined;
         }
         else if (schemaItem.Defindex == TF2Value.KEY_DEFINDEX)
         {
             AmountAdded -= TF2Value.Key;
         }
     }
 }
示例#4
0
        public override void OnTradeRemoveItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            var item = Trade.CurrentSchema.GetItem(schemaItem.Defindex);

            Bot.log.Success("User removed: " + schemaItem.ItemName);
            if ((item.CraftClass == "weapon" || item.CraftMaterialType == "weapon") && !inventoryItem.IsNotCraftable)
            {
                if (inventoryItem.Quality.ToString() != "6" || item.Name.Contains("Festive"))
                {
                    invalidItem--;
                    Bot.log.Warn("User removed special item.");
                }
                else
                {
                    userWepAdded--;
                }
                if (userWepAdded < botScrapAdded * 2 && userWepAdded != 0)
                {
                    Trade.RemoveItemByDefindex(5000);
                    botScrapAdded--;
                    inventoryScrap++;
                    Bot.log.Warn("I removed: Scrap Metal");
                }
            }
            else if (item.Defindex == 5000)
            {
                userScrapAdded--;
            }
            else
            {
                invalidItem--;
            }
        }
示例#5
0
        /// <summary>
        /// Removes an item, retrying 10 times if neccessary
        /// </summary>
        /// <returns>True if successful.</returns>
        protected bool RemoveItem(Inventory.Item item)
        {
            int x = 0;

            Success = false;
            Log.Debug("Removing item: " + item.Defindex);
            while (Success == false && x < 5)
            {
                x++;
                Log.Debug("Loop #" + x);
                try
                {
                    Success = Trade.RemoveItem(item.Id);
                }
                catch (TradeException te)
                {
                    Log.Warn("Remove Item failed.");
                    var s = string.Format("Loop #{0}{1}Exception:{2}", x, Environment.NewLine, te);
                    Log.Debug(s);
                    Thread.Sleep(250);
                }
                catch (Exception e)
                {
                    Log.Warn("Remove Item failed");
                    var s = string.Format("Loop #{0}{1}Exception:{2}", x, Environment.NewLine, e);
                    Log.Debug(s);
                    Thread.Sleep(250);
                }
            }
            if (!Success)
            {
                Log.Error("Could not remove item" + item.Id);
            }
            return(Success);
        }
        public bool UnequipItem(int itemID)
        {
            bool unequipped = false;

            for (int i = 0; i < this.equipment.items.Length; ++i)
            {
                if (this.equipment.items[i].isEquipped && this.equipment.items[i].itemID == itemID)
                {
                    Inventory.Item item = InventoryManager.Instance.itemsCatalogue[itemID];

                    this.equipment.items[i].isEquipped = false;

                    GameObject instance = Instantiate <GameObject>(
                        item.actionsOnUnequip.gameObject,
                        transform.position,
                        transform.rotation
                        );

                    Actions actions = instance.GetComponent <Actions>();
                    actions.destroyAfterFinishing = true;
                    actions.Execute(gameObject);

                    unequipped = true;
                }
            }

            return(unequipped);
        }
示例#7
0
 public ListOtherOfferings(string itemName, ulong itemID, string price, Inventory.Item item)
 {
     this.itemName = itemName;
     this.itemID   = itemID;
     this.price    = price;
     this.item     = item;
 }
示例#8
0
        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            // USELESS DEBUG MESSAGES -------------------------------------------------------------------------------
            SendTradeMessage("Object AppID: {0}", inventoryItem.AppId);
            SendTradeMessage("Object ContextId: {0}", inventoryItem.ContextId);

            switch (inventoryItem.AppId)
            {
            case 440:
                SendTradeMessage("TF2 Item Added.");
                SendTradeMessage("Name: {0}", schemaItem.Name);
                SendTradeMessage("Quality: {0}", inventoryItem.Quality);
                SendTradeMessage("Level: {0}", inventoryItem.Level);
                SendTradeMessage("Craftable: {0}", (inventoryItem.IsNotCraftable ? "No" : "Yes"));
                break;

            case 753:
                GenericInventory.ItemDescription tmpDescription = OtherSteamInventory.getDescription(inventoryItem.Id);
                SendTradeMessage("Steam Inventory Item Added.");
                SendTradeMessage("Type: {0}", tmpDescription.type);
                SendTradeMessage("Marketable: {0}", (tmpDescription.marketable ? "Yes" : "No"));
                break;

            default:
                SendTradeMessage("Unknown item");
                break;
            }
            // ------------------------------------------------------------------------------------------------------
        }
示例#9
0
 private void exchangePartnerList_Click(object sender, EventArgs e)
 {
     buy            = true;
     buyButton.Text = "buy";
     Inventory.Item i = (Inventory.Item)exchangePartnerList.SelectedItem;
     setCompareTable(1, i);
     findCompareable(i, player.inventory.equipment);
 }
示例#10
0
        /// <summary>
        /// Deletes an item
        /// </summary>
        protected void DeleteItem(Inventory.Item item)
        {
            Log.Info("Deleting item: " + item.Id);
            TF2GC.Items.DeleteItem(Bot, item.Id);

            // Again, some delay seems required for repetive commands - unsure how much.
            Thread.Sleep(100);
        }
示例#11
0
 private void inventoryManager_Click(object sender, EventArgs e)
 {
     buy            = false;
     buyButton.Text = "sell";
     Inventory.Item i = (Inventory.Item)inventoryManager.StuffListBox.SelectedItem;
     setCompareTable(1, i);
     findCompareable(i, player.inventory.equipment);
 }
示例#12
0
 public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
 {
     Bot.main.Invoke((Action)(() =>
     {
         string itemValue = "";
         string completeName = GetItemName(schemaItem, inventoryItem, out itemValue, false);
         ulong itemID = inventoryItem.Id;
         //string itemValue = Util.GetPrice(schemaItem.Defindex, schemaItem.ItemQuality, inventoryItem);
         double value = 0;
         if (itemValue.Contains("ref"))
         {
             string newValue = ShowTrade.ReplaceLastOccurrence(itemValue, "ref", "");
             value = Convert.ToDouble(newValue);
         }
         else if (itemValue.Contains("key"))
         {
             string newValue = ShowTrade.ReplaceLastOccurrence(itemValue, "keys", "");
             value = Convert.ToDouble(newValue);
             value = value * BackpackTF.KeyPrice;
         }
         else if (itemValue.Contains("bud"))
         {
             string newValue = ShowTrade.ReplaceLastOccurrence(itemValue, "buds", "");
             value = Convert.ToDouble(newValue);
             value = value * BackpackTF.BudPrice;
         }
         ShowTrade.OtherTotalValue += value;
         if (ShowTrade.OtherTotalValue >= BackpackTF.BudPrice * 1.33)
         {
             double formatPrice = ShowTrade.OtherTotalValue / BackpackTF.BudPrice;
             string label = "Total Value: " + formatPrice.ToString("0.00") + " buds";
             ShowTrade.UpdateLabel(label);
         }
         else if (ShowTrade.OtherTotalValue >= BackpackTF.KeyPrice)
         {
             double formatPrice = ShowTrade.OtherTotalValue / BackpackTF.KeyPrice;
             string label = "Total Value: " + formatPrice.ToString("0.00") + " keys";
             ShowTrade.UpdateLabel(label);
         }
         else
         {
             double formatPrice = ShowTrade.OtherTotalValue;
             string label = "Total Value: " + formatPrice.ToString("0.00") + " ref";
             ShowTrade.UpdateLabel(label);
         }
         ListOtherOfferings.Add(completeName, itemID, itemValue);
         ShowTrade.list_otherofferings.SetObjects(ListOtherOfferings.Get());
         ShowTrade.itemsAdded++;
         if (ShowTrade.itemsAdded > 0)
         {
             ShowTrade.check_userready.Enabled = true;
         }
         string itemName = GetItemName(schemaItem, inventoryItem, out itemValue, false);
         ShowTrade.AppendText(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " added: ", itemName);
         ChatTab.AppendLog(OtherSID, "[Trade Chat] " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " added: " + itemName + "\r\n");
         ShowTrade.ResetTradeStatus();
     }));
 }
示例#13
0
 public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
 {
     // USELESS DEBUG MESSAGES -------------------------------------------------------------------------------
     SendTradeMessage("Dota2 Item Added.");
     SendTradeMessage("Name: {0}", schemaItem.Name);
     SendTradeMessage("Price: {0}", schemaItem.Price);
     SendTradeMessage("Quality: {0}", inventoryItem.Quality);
     SendTradeMessage("Level: {0}", inventoryItem.Level);
     SendTradeMessage("Craftable: {0}", (inventoryItem.IsNotCraftable ? "No" : "Yes"));
 }
示例#14
0
 private void findCompareable(Inventory.Item item, BindingList <Inventory.Item> equippment)
 {
     foreach (Inventory.Item i in equippment)
     {
         if (item.type == i.type)
         {
             setCompareTable(2, i);
         }
     }
 }
示例#15
0
        public bool EquipItem(int itemID, int itemType, Action onEquip = null)
        {
            Inventory.Item item = InventoryManager.Instance.itemsCatalogue[itemID];
            if (!item.conditionsEquip.Check(gameObject))
            {
                return(false);
            }

            List <int> itemTypes = new List <int>();

            if (InventoryManager.Instance.itemsCatalogue[itemID].fillAllTypes)
            {
                for (int i = 0; i < ItemType.MAX; ++i)
                {
                    if (((item.itemTypes >> i) & 1) > 0)
                    {
                        itemTypes.Add(i);
                    }
                }
            }
            else
            {
                itemTypes.Add(itemType);
            }

            int numToUnequip  = 0;
            int numUnequipped = 0;

            for (int i = 0; i < itemTypes.Count; ++i)
            {
                if (this.equipment.items[itemTypes[i]].isEquipped)
                {
                    numToUnequip += 1;
                    this.UnequipItem(this.equipment.items[itemTypes[i]].itemID, () =>
                    {
                        numUnequipped += 1;
                        if (numUnequipped >= numToUnequip)
                        {
                            this.ExecuteActions(item.actionsOnEquip, onEquip);
                        }
                    });
                }

                this.equipment.items[itemTypes[i]].isEquipped = true;
                this.equipment.items[itemTypes[i]].itemID     = itemID;
            }

            if (numToUnequip == 0)
            {
                this.ExecuteActions(item.actionsOnEquip, onEquip);
            }

            return(true);
        }
示例#16
0
    private void Awake()
    {
        beginRotation = transform.GetChild(0).transform.rotation;
        inventory     = FindObjectOfType <Inventory>();

        if (inventory != null)
        {
            inventory = inventory.GetComponent <Inventory>();
            itemType  = SetItemType(gameObject.name);
        }
    }
示例#17
0
        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            if (schemaItem == null || inventoryItem == null)
            {
                Trade.CancelTrade();
                Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "I'm sorry. I believe SteamAPI is down. Please try to trade again in a few minutes.");
                Bot.log.Warn("Issue getting inventory item. API down? Closing trade.");
                return;
            }
            string ItemAddedMsg = String.Format("User added {0} {1} {2} {3}", inventoryItem.IsNotCraftable.ToString().ToLower() == "true" ? "NonCraftable" : "Craftable", clsFunctions.ConvertQualityToString(schemaItem.ItemQuality), schemaItem.ItemName, schemaItem.CraftMaterialType); //ready ItemRemovedMsg

            Bot.log.Success("User donated: " + ItemAddedMsg);
        }
        public bool EquipItem(int itemID, int itemType)
        {
            Inventory.Item item = InventoryManager.Instance.itemsCatalogue[itemID];
            if (!item.conditionsEquip.Check(gameObject))
            {
                return(false);
            }

            List <int> itemTypes = new List <int>();

            if (InventoryManager.Instance.itemsCatalogue[itemID].fillAllTypes)
            {
                for (int i = 0; i < ItemType.MAX; ++i)
                {
                    if (((item.itemTypes >> i) & 1) > 0)
                    {
                        itemTypes.Add(i);
                    }
                }
            }
            else
            {
                itemTypes.Add(itemType);
            }

            for (int i = 0; i < itemTypes.Count; ++i)
            {
                if (this.equipment.items[itemTypes[i]].isEquipped)
                {
                    this.UnequipItem(this.equipment.items[itemTypes[i]].itemID);
                }

                this.equipment.items[itemTypes[i]].isEquipped = true;
                this.equipment.items[itemTypes[i]].itemID     = itemID;
            }

            GameObject instance = Instantiate <GameObject>(
                item.actionsOnEquip.gameObject,
                transform.position,
                transform.rotation
                );

            Actions actions = instance.GetComponent <Actions>();

            actions.destroyAfterFinishing = true;
            actions.Execute(gameObject);

            return(true);
        }
示例#19
0
        // returns true if the user has weird crap in their trade window.
        public bool HasNonPureInTrade()
        {
            foreach (TradeUserAssets asset in Trade.OtherOfferedItems)
            {
                Inventory.Item item       = Trade.OtherInventory.GetItem(asset.assetid);
                Schema.Item    schemaItem = Trade.CurrentSchema.GetItem(item.Defindex);

                if (!schemaItem.IsPure())
                {
                    return(true);
                }
            }

            return(false);
        }
示例#20
0
        string GetItemName(Schema.Item schemaItem, Inventory.Item inventoryItem, bool id = false)
        {
            var    currentItem = Trade.CurrentSchema.GetItem(schemaItem.Defindex);
            string name        = "";
            var    type        = Convert.ToInt32(inventoryItem.Quality.ToString());

            if (Util.QualityToName(type) != "Unique")
            {
                name += Util.QualityToName(type) + " ";
            }
            name += string.IsNullOrWhiteSpace(inventoryItem.CustomName) ? currentItem.ItemName : "\"" + inventoryItem.CustomName + "\"";
            if (id)
            {
                name += " :" + inventoryItem.Id;
            }
            return(name);
        }
示例#21
0
        private string GetTooltipText(Inventory.Item item)
        {
            var text       = "<div align=\"center\">";
            var schemaitem = Trade.CurrentSchema.GetItem(item.Defindex);
            var itemname   = (Util.QualityToName(int.Parse(item.Quality)) == "" ||
                              Util.QualityToName(int.Parse(item.Quality)) == "Unique"
                ? ""
                : Util.QualityToName(int.Parse(item.Quality)) + " ")
                             + schemaitem.ItemName;
            var name = string.IsNullOrWhiteSpace(item.CustomName)
                           ? itemname
                           : string.Format("\"{0}\" ({1})", item.CustomName, itemname);
            var type = (Util.QualityToName(int.Parse(item.Quality)) == "" ||
                        Util.QualityToName(int.Parse(item.Quality)) == "Unique"
                ? ""
                : Util.QualityToName(int.Parse(item.Quality)) + " ") +
                       (Trade.CurrentItemsGame.GetItemRarity(item.Defindex.ToString())) + " " + schemaitem.ItemTypeName;
            var desc = string.IsNullOrWhiteSpace(item.CustomDescription)
                           ? schemaitem.ItemDescription
                           : string.Format("\"{0}\" ({1})", item.CustomDescription, schemaitem.ItemDescription);

            text += string.Format(@"<span class=""name"" style=""color:{0}"">{1}</span><br>",
                                  Util.GetQualityColor(item.Quality), name);
            text += string.Format(@"<span class=""type"" style=""color:{0}"">{1}</span><br>",
                                  Trade.CurrentItemsGame.GetRarityColor(Trade.CurrentItemsGame.GetItemRarity(item.Defindex.ToString())), type);
            if (item.Attributes != null)
            {
                foreach (var attribute in item.Attributes)
                {
                    var attribname = Trade.CurrentSchema.GetAttributeName(attribute.Defindex, item.Attributes,
                                                                          attribute.FloatValue != null ? attribute.FloatValue : 0f,
                                                                          attribute.Value ?? "");
                    if (attribname != "")
                    {
                        text += string.Format(@"<span class=""effect"">{0}</span><br>", attribname);
                    }
                }
            }
            if (item.Style != null)
            {
                text += string.Format(@"<span class=""effect"">Style: {0}</span><br>",
                                      Trade.CurrentSchema.GetStyle(item.Defindex, (int)item.Style));
            }
            text += string.Format(@"<span class=""description"">{0}</span>", desc);
            return(text);
        }
示例#22
0
        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            var item = Trade.CurrentSchema.GetItem(schemaItem.Defindex);

            Bot.log.Success("User added: " + schemaItem.ItemName);
            if (invalidItem >= ConfigObject.AllowedInvalidItemAttempts)
            {
                Trade.CancelTrade();
                Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Stop messing around. This bot is used for scrapbanking, and he will only accept metal or craftable weapons.");
            }
            else if ((item.CraftClass == "weapon" || item.CraftMaterialType == "weapon") && inventoryItem.IsCraftable)
            {
                if (inventoryItem.Quality.ToString() != "6" || item.Name.Contains("Festive"))
                {
                    Trade.SendMessage(schemaItem.ItemName + " is not a valid item! Please remove it from the trade.");
                    invalidItem++;
                    Bot.log.Warn("This is a special weapon and will not be accepted.");
                }
                else
                {
                    userWepAdded++;
                }
                if (inventoryScrap == 0)
                {
                    Trade.SendMessage("I have no more scrap so I can't accept any more weapons! Please remove the item.");
                    Bot.log.Warn("I don't have enough scrap to give to the user.");
                }
                else if (userWepAdded % 2 == 0 && userWepAdded != 0)
                {
                    Trade.AddItemByDefindex(5000);
                    botScrapAdded++;
                    inventoryScrap--;
                    Bot.log.Warn("I added: Scrap Metal");
                }
            }
            else if (item.Defindex == 5000)
            {
                userScrapAdded++;
            }
            else
            {
                Trade.SendMessage(schemaItem.ItemName + " is not a valid item! Please remove it from the trade.");
                invalidItem++;
            }
        }
        }//OnTradeInit()

        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            if (schemaItem == null || inventoryItem == null)
            {
                Trade.CancelTrade();
                Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "I'm sorry. I believe SteamAPI is down. Please try again to trade in a few minutes.");
                Bot.log.Warn("Issue getting inventory item. API down? Closing trade.");
                return;
            }
            if (schemaItem.ItemName == "Mann Co. Supply Crate Key" || inventoryItem.Defindex == 5021)
            {
                UserKeyAdded++;
                Bot.log.Success("User added a key");
            }
            else if (schemaItem.CraftMaterialType == "craft_bar")
            {
                switch (inventoryItem.Defindex)
                {
                case 5000:
                    Bot.log.Success("User added a scrap metal.");
                    UserScrapAdded++;
                    Bot.userCurrency.AddScrap();
                    break;

                case 5001:
                    Bot.log.Success("User added a reclaimed metal.");
                    UserRecAdded++;
                    Bot.userCurrency.AddRec();
                    break;

                case 5002:
                    Bot.log.Success("User added a refined metal.");
                    UserRefAdded++;
                    Bot.userCurrency.AddRef();
                    break;
                }
            }
            else
            {
                Trade.SendMessage(String.Format("{0} is not a hat I will pay for!", schemaItem.ItemName));
                Bot.log.Warn(String.Format("User added non hat item: {0} {1} {2} {3}", inventoryItem.IsNotCraftable.ToString().ToLower() == "true" ? "Uncraftable" : "Craftable", clsFunctions.ConvertQualityToString(schemaItem.ItemQuality), schemaItem.ItemName, schemaItem.CraftMaterialType));
            }
            Test();
        }
示例#24
0
        public void Lock()
        {
            var row = TableSheets.MaterialItemSheet.First;

            Assert.NotNull(row);
            var material  = ItemFactory.CreateMaterial(row);
            var item      = new Inventory.Item(material, 1);
            var orderLock = new OrderLock(Guid.NewGuid());

            Assert.False(item.Locked);

            item.LockUp(orderLock);

            Assert.True(item.Locked);

            item.Unlock();

            Assert.False(item.Locked);
        }
示例#25
0
 public override void OnTradeRemoveItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
 {
     if (inventoryItem.Defindex == 5000)
     {
         OtherScrapPutUp--;
     }
     else if (inventoryItem.Defindex == 5001)
     {
         OtherScrapPutUp -= 3;
     }
     else if (inventoryItem.Defindex == 5002)
     {
         OtherScrapPutUp -= 9;
     }
     else if (schemaItem.CraftMaterialType == "hat" && !inventoryItem.IsNotCraftable)
     {
         OtherHatsPutUp--;
     }
 }
示例#26
0
        private string GetTooltipText(Inventory.Item item)
        {
            var text       = "";
            var schemaitem = Trade.CurrentSchema.GetItem(item.Defindex);
            var itemname   = (Util.QualityToName(int.Parse(item.Quality)) == "" ||
                              Util.QualityToName(int.Parse(item.Quality)) == "Unique"
                ? ""
                : Util.QualityToName(int.Parse(item.Quality)) + " ")
                             + schemaitem.ItemName;
            var name = string.IsNullOrWhiteSpace(item.CustomName)
                           ? itemname
                           : string.Format("\"{0}\" ({1})", item.CustomName, itemname);
            var type = (Util.QualityToName(int.Parse(item.Quality)) == "" ||
                        Util.QualityToName(int.Parse(item.Quality)) == "Unique"
                ? ""
                : Util.QualityToName(int.Parse(item.Quality)) + " ") +
                       (Trade.CurrentItemsGame.GetItemRarity(item.Defindex.ToString())) + " " + schemaitem.ItemTypeName;
            var desc = string.IsNullOrWhiteSpace(item.CustomDescription)
                           ? schemaitem.ItemDescription
                           : string.Format("\"{0}\" ({1})", item.CustomDescription, schemaitem.ItemDescription);

            text += string.Format(@"{0} | ", type);
            if (item.Attributes != null)
            {
                foreach (var attribute in item.Attributes)
                {
                    var attribname = Trade.CurrentSchema.GetAttributeName(attribute.Defindex, item.Attributes,
                                                                          attribute.FloatValue != null ? attribute.FloatValue : 0f,
                                                                          attribute.Value ?? "");
                    if (attribname != "")
                    {
                        text += string.Format(@"{0} | ", attribname);
                    }
                }
            }
            if (item.Style != null)
            {
                text += string.Format(@"Style: {0}",
                                      Trade.CurrentSchema.GetStyle(item.Defindex, (int)item.Style));
            }
            text = text.TrimEnd(new[] { '|', ' ' });
            return(text);
        }
示例#27
0
        public bool UnequipItem(int itemID, Action onUnequip = null)
        {
            bool unequipped = false;

            int itemsToUnequip  = 0;
            int itemsUnequipped = 0;

            for (int i = 0; i < this.equipment.items.Length; ++i)
            {
                if (this.equipment.items[i].isEquipped && this.equipment.items[i].itemID == itemID)
                {
                    Inventory.Item item = InventoryManager.Instance.itemsCatalogue[itemID];

                    this.equipment.items[i].isEquipped = false;

                    GameObject instance = Instantiate <GameObject>(
                        item.actionsOnUnequip.gameObject,
                        transform.position,
                        transform.rotation
                        );

                    itemsToUnequip += 1;

                    Actions actions = instance.GetComponent <Actions>();
                    actions.destroyAfterFinishing = true;
                    actions.onFinish.AddListener(() =>
                    {
                        itemsUnequipped += 1;
                        if (itemsUnequipped >= itemsToUnequip && onUnequip != null)
                        {
                            onUnequip.Invoke();
                        }
                    });

                    actions.Execute(gameObject);
                    unequipped = true;
                }
            }

            return(unequipped);
        }
示例#28
0
 public override void OnTradeRemoveItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
 {
     Debug.WriteLine("Item removed: ID: {0} | DefIndex: {1}", inventoryItem.Id, inventoryItem.Defindex);
     Bot.main.Invoke((Action)(() =>
     {
         string itemValue = "";
         string completeName = GetItemName(schemaItem, inventoryItem, out itemValue, false);
         ulong itemID = inventoryItem.Id;
         ShowTrade.list_otherofferings.SetObjects(ListOtherOfferings.Get());
         ShowTrade.itemsAdded--;
         if (ShowTrade.itemsAdded <= 0)
         {
             ShowTrade.check_userready.Enabled = false;
         }
         string itemName = GetItemName(schemaItem, inventoryItem, out itemValue, false);
         ShowTrade.AppendText(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " removed: ", itemName);
         var count = ListOtherOfferings.Get().Count(x => x.Item.Defindex == inventoryItem.Defindex);
         ShowTrade.AppendText(string.Format("Number of {0}: {1}", schemaItem.ItemName, count));
         ChatTab.AppendLog(OtherSID, "[Trade Chat] " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " removed: " + itemName + "\r\n");
         ShowTrade.ResetTradeStatus();
     }));
 }
示例#29
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        string name        = "";
        string description = "";

        if (Equipped == false)
        {
            Inventory.Item item = Inventory.Items[Index];
            if (item.type == Inventory.ItemType.ability)
            {
                PlayerController.Ability ability = PlayerController.AbilityInformation.abilities[item.id];
                name        = ability.name;
                description = ability.description;
            }
            else if (item.type == Inventory.ItemType.weapon)
            {
                PlayerController.Weapon weapon = PlayerController.WeaponInformation.weapons[item.id];
                name        = weapon.name;
                description = weapon.description;
            }
        }
        else
        {
            // If equipped, read from equipped items
            if (Type == Inventory.ItemType.ability)
            {
                PlayerController.Ability ability = PlayerController.Abilities[SlotNumber];
                name        = ability.name;
                description = ability.description;
            }
            else if (Type == Inventory.ItemType.weapon)
            {
                PlayerController.Weapon weapon = PlayerController.CurrentWeapon;
                name        = weapon.name;
                description = weapon.description;
            }
        }
        ItemInformation.SetDisplay(name, description);
    }
示例#30
0
        public override void OnTradeAddItem(Schema.Item schemaItem, Inventory.Item inventoryItem)
        {
            if (schemaItem != null)
            {
                if (inventoryItem.Defindex == 5000)
                {
                    OtherScrapPutUp++;
                }
                else if (inventoryItem.Defindex == 5001)
                {
                    OtherScrapPutUp += 3;
                }
                else if (inventoryItem.Defindex == 5002)
                {
                    OtherScrapPutUp += 9;
                }
                else if (schemaItem.CraftMaterialType == "hat" && !inventoryItem.IsNotCraftable)
                {
                    OtherHatsPutUp++;
                }
                switch (Bot.currentRequest.TradeType)
                {
                case Bot.TradeTypes.BuySpecific:
                    if (schemaItem.CraftMaterialType != "craft_bar")
                    {
                        Trade.SendMessage(String.Format("Sorry, but {0} is not metal... but feel free to donate :P", schemaItem.ItemName));
                    }
                    break;

                case Bot.TradeTypes.Sell:
                    if (schemaItem.CraftMaterialType == "hat" || inventoryItem.IsNotCraftable)
                    {
                        Trade.SendMessage(String.Format("Sorry, but {0} is not craftable hat/misc... but feel free to donate :P", schemaItem.ItemName));
                    }
                    break;
                }
            }
        }
示例#31
0
文件: Player.cs 项目: unodeej/Unity
    public void HandleTrainer()
    {
        //swap pokemon
        if (!click && !pokemonActive){
            Pokemon oldPokemonSelection = pokemon;

            for(int i = 1; i <= trainer.party.Count(); i++) {
                if (Rebind.GetInputDown("SELECT_POKE_PARTY_" + i))
                    trainer.party.Select(i - 1);
            }

            if (Rebind.GetInputDown("SELECT_POKE_PREV"))
                trainer.party.SelectPrev();
            else if (Rebind.GetInputDown("SELECT_POKE_NEXT"))
                trainer.party.SelectNext();

            if (oldPokemonSelection!=pokemon){
                click = true;
                if (oldPokemonSelection.obj!=null){
                    oldPokemonSelection.obj.Return();
                    trainer.ThrowPokemon(pokemon);
                }
            }
        }

        if (item != null && trainer.inventory.GetQuantity(item.id) == 0)			item = null;
        var itemsCount = trainer.inventory.items.Count;
        if (item==null && itemsCount>0)	item = trainer.inventory.items[itemsCount - 1];

        //throw pokemon
        if (!click && Input.GetKey(KeyCode.Return)){
            if (pokemon != null && pokemon.obj==null){
                trainer.ThrowPokemon(pokemon);
            }else{
                if (pokemonActive){
                    pokemon.obj.Return();
                    pokemonActive = false;
                }else{
                    pokemonActive = true;
                }
            }
            click = true;
        }

        //activate menu
        if (Input.GetKeyDown(KeyCode.Escape) && !click){
            if (pokemonActive)
                pokemonActive = false;
            else
                GameGUI.menuActive = !GameGUI.menuActive;
            click = true;
        }

        //capture pokemon
        if(Input.GetKeyDown("c")) {
            GameGUI gamegui = GetComponent<GameGUI>();
            CapturePokemon();
            click = true;
        }

        //chat window
        if(Input.GetKeyDown ("i")){
            if(GameGUI.chatActive)
                GameGUI.chatActive=false;
            else
                GameGUI.chatActive=true;

            click = true;
        }

        if (Input.GetKeyDown ("h")) {
            PokeCenter.HealPokemon ();
        }
        /*
         * don't try using this right now, because it doesn't exist!
        if (Input.GetKeyDown ("k")) {
            Populate okasf = new Populate();
            okasf.Test();
        }
        */
        //anticlick
        bool anti = false;
        for(int i = 1; i <= 10 && !anti; i++) {
            if (Rebind.GetInput("SELECT_POKE_PARTY_" + i))
                anti = true;
        }
    }
示例#32
0
        /// <summary>
        /// Crafts all scrap into reclaimed, then all reclaimed into refined.
        /// </summary>
        protected void CombineAllMetal()
        {
            if (Bot.CurrentGame != 440)
            {
                Bot.SetGamePlaying(440);
            }
            // May use for inventory management
            //List<Inventory.Item> myScrap = new List<Inventory.Item>();
            //List<Inventory.Item> myReclaimed = new List<Inventory.Item>();
            //List<Inventory.Item> myRefined = new List<Inventory.Item>();

            Log.Info("Combining all metal");

            // Scrap, Reclaimed, and Refined are defindex 5000, 5001, 5002 respectively

            List<Inventory.Item> ScrapToCraft = new List<Inventory.Item>();

            Log.Debug("Getting Inventory");
            Thread.Sleep(300); // Just another pause to be sure inventory has updated.
            Bot.GetInventory();

            ScrapToCraft = Bot.MyInventory.GetItemsByDefindex(5000);

            Log.Debug("Total Scrap: " + ScrapToCraft.Count);
            Log.Debug("Crafting " + (ScrapToCraft.Count / 3) + " Reclaimed.");

            while (ScrapToCraft.Count > 2)
            {
                Inventory.Item[] CraftItems = new Inventory.Item[3];
                CraftItems[0] = ScrapToCraft[0];
                CraftItems[1] = ScrapToCraft[1];
                CraftItems[2] = ScrapToCraft[2];
                Craft(CraftItems);
                for (int x = 0; x < 3; x++)
                {
                    ScrapToCraft.RemoveAt(0);
                }
            }

            List<Inventory.Item> ReclaimedToCraft = new List<Inventory.Item>();

            Log.Debug("Getting Inventory");
            Thread.Sleep(300); // Just another pause to be sure inventory has updated.
            Bot.GetInventory();

            ReclaimedToCraft = Bot.MyInventory.GetItemsByDefindex(5001);

            Log.Debug("Total Reclaimed: " + ReclaimedToCraft.Count);
            Log.Debug("Crafting " + (ReclaimedToCraft.Count / 3) + " Refined.");

            while (ReclaimedToCraft.Count > 2)
            {
                Inventory.Item[] craftIds = new Inventory.Item[3];
                craftIds[0] = ReclaimedToCraft[0];
                craftIds[1] = ReclaimedToCraft[1];
                craftIds[2] = ReclaimedToCraft[2];
                Craft(craftIds);
                for (int x = 0; x < 3; x++)
                {
                    ReclaimedToCraft.RemoveAt(0);
                }
            }
        }
示例#33
0
        /// <summary>
        /// Scraps a List of Weapons into scrap.
        /// </summary>
        /// <param name="CleanWeapons">List of all weapons to scrap.</param>
        /// <returns>Number of scrap made.</returns>
        protected int ScrapWeapons(List<Inventory.Item> CleanWeapons)
        {
            if (Bot.CurrentGame != 440)
            {
                Bot.SetGamePlaying(440);
            }

            Log.Info("Sorting items by class.");
            List<List<Inventory.Item>> allWeapons = SortItemsByClass(CleanWeapons);

            List<Inventory.Item> multiWeps = allWeapons[9];

            // Seperate the multi-class weapons again because it's so special
            allWeapons.RemoveAt(9);

            Inventory.Item[] CraftItems;
            int scrapMade = 0;
            Log.Info("Beginning smelt sequence.");

            // Crafting off pairs of weapons in class lists
            foreach (List<Inventory.Item> list in allWeapons)
            {
                while (list.Count > 1)
                {
                    CraftItems = new Inventory.Item[2];
                    CraftItems[0] = list[0];
                    list.RemoveAt(0);
                    CraftItems[1] = list[0];
                    list.RemoveAt(0);
                    Craft(CraftItems);
                    scrapMade++;
                }
            }

            //(Still needs to be optimised) Crafting the remaining multi-class weapons
            Log.Info("Scrapping multi-class weps");
            foreach (List<Inventory.Item> list in allWeapons)
            {
                CraftItems = new Inventory.Item[2];
                if (list.Count > 0)
                {
                    foreach (Inventory.Item item in multiWeps)
                    {
                        List<string> classes = new List<string>(Trade.CurrentSchema.GetItem(item.Defindex).UsableByClasses);
                        string[] itemClass = Trade.CurrentSchema.GetItem(list[0].Defindex).UsableByClasses;
                        if (classes.Contains(itemClass[0]))
                        {
                            CraftItems[0] = item;
                            // I can remove items from this foreach because I'm going to break anyway
                            multiWeps.Remove(item);
                            CraftItems[1] = list[0];
                            list.RemoveAt(0);
                            Craft(CraftItems);
                            scrapMade++;
                            break;
                        }
                    }
                }
            }
            // Clean up any leftover
            while (multiWeps.Count > 1)
            {
                CraftItems = new Inventory.Item[2];
                CraftItems[0] = multiWeps[0];
                multiWeps.RemoveAt(0);
                CraftItems[1] = multiWeps[0];
                multiWeps.RemoveAt(0);
                Craft(CraftItems);
                scrapMade++;
            }
            return scrapMade;
        }