public void Collect() { for (int i = 0; i < Trap.TrapInfo.Size; i++) { Drop drop = DropTable.GetDrop(); double chance = 1; GameItem dropItem = ItemManager.Instance.GetItemByName(drop.ItemName); Console.WriteLine("Got a " + drop.ItemName); foreach (Requirement req in dropItem.Requirements) { if (req.Skill == "Hunting") { if (Player.Instance.GetLevel("Hunting") >= req.SkillLevel) { chance = 1; } else { chance = 1 / (req.SkillLevel - Player.Instance.GetLevel("Hunting")); } continue; } } if (chance >= rand.NextDouble()) { MessageManager.AddMessage("You find a " + drop.ItemName + " in the trap."); Player.Instance.GainExperience(dropItem.ExperienceGained); Player.Instance.Inventory.AddDrop(drop); } else { MessageManager.AddMessage("You find evidence a " + drop.ItemName + " escaped the trap."); } } }
void DropLoot() { Item item = DropTable.GetDrop(); if (item != null) { PickupItem instance = Instantiate(pickupItem, transform.position, Quaternion.identity); instance.ItemDrop = item; } }
public virtual void DropLoot() { Item item = DropTable.GetDrop(); if (item != null) { PickupItem instance = Instantiate(PickupItemPrefab, transform.position, Quaternion.identity); instance.transform.SetParent(CurrentMap.Instance.pickupItems); instance.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Icons/Items/" + item.Name); instance.transform.localScale = new Vector3(1, 1, 1); instance.ItemDrop = item; } CashDrop.DropCash(Cash, transform); }
public void Collect() { for (int i = 0; i < Size; i++) { try { Drop drop = DropTable.GetDrop(); double chance = 1; foreach (Requirement req in drop.Item.Requirements) { if (req.Skill == "Hunting") { if (Player.Instance.GetLevel("Hunting") >= req.SkillLevel) { chance = 1; } else { chance = 1 / (req.SkillLevel - Player.Instance.GetLevel("Hunting")); } continue; } } if (chance >= rand.NextDouble()) { MessageManager.AddMessage("You find a " + drop.Item + " in the trap."); Player.Instance.GainExperience(drop.Item.ExperienceGained); Player.Instance.Inventory.AddDrop(drop); } else { MessageManager.AddMessage("You find evidence a " + drop.Item.Name + " escaped the trap."); } } catch (Exception e) { Console.WriteLine("Drop was null."); Console.WriteLine(e); MessageManager.AddMessage("You find nothing in the trap. It's strange... It shouldn't be this way..."); } } State = "Unset"; }