/// <summary> /// Gets the available drop. /// </summary> /// <returns> /// The available drop. /// </returns> /// <param name='itemDropType'> /// Item drop type. /// </param> public ItemDrop GetAvailableDrop(ItemDropType itemDropType) { foreach (ItemDrop drop in availableWeaponDrops) { if (drop.DropType == itemDropType) { return drop; } } foreach (ItemDrop drop in availableHatDrops) { if (drop.DropType == itemDropType) { return drop; } } foreach (ItemDrop drop in availableMouthDrops) { if (drop.DropType == itemDropType) { return drop; } } foreach (ItemDrop drop in availableAmmoDrops) { if (drop.DropType == itemDropType) { return drop; } } return null; }
public void SetData(Hashtable ht) { if(ht.ContainsKey("itemchance")) { this.stealItem = true; this.itemChance = int.Parse((string)ht["itemchance"]); this.itemBonus = float.Parse((string)ht["itembonus"]); if(ht.ContainsKey("item")) { this.fixItem = true; this.itemType = (ItemDropType)System.Enum.Parse( typeof(ItemDropType), (string)ht["itemtype"]); this.itemID = int.Parse((string)ht["item"]); } } if(ht.ContainsKey("moneychance")) { this.stealMoney = true; this.moneyChance = int.Parse((string)ht["moneychance"]); this.moneyBonus = float.Parse((string)ht["moneybonus"]); if(ht.ContainsKey("money")) { this.fixMoney = true; this.money = int.Parse((string)ht["money"]); } } }
// Initialize each CombatCharacter's variables protected override void Start() { base.Start(); tag = "CombatCharacter"; health = GetComponent <Health> (); isAlive = true; attackDamage = 1; isFreezable = true; isFrozen = false; freezeTime = 1.0F; itemDropPercentage = 10; itemDropType = ItemDropType.COMMON; }
public void Drop(ItemDropType type, int itemID, int quantity) { bool drop = false; if(ItemDropType.ITEM.Equals(type)) { drop = DataHolder.Item(itemID).dropable; } else if(ItemDropType.WEAPON.Equals(type)) { drop = DataHolder.Weapon(itemID).dropable; } else if(ItemDropType.ARMOR.Equals(type)) { drop = DataHolder.Armor(itemID).dropable; } if(drop) { this.Drop(GameHandler.GetPlayer().transform.position, type, itemID, quantity); } }
public void Drop(Vector3 position, ItemDropType type, int itemID, int quantity) { // drop to world DropInfo info = new DropInfo(position, type, itemID, quantity); info.Drop(); // save position if(DataHolder.GameSettings().saveDrops) { ArrayList scene = null; if(this.drops.ContainsKey(Application.loadedLevelName)) { scene = (ArrayList)this.drops[Application.loadedLevelName]; this.drops.Remove(Application.loadedLevelName); } else { scene = new ArrayList(); } scene.Add(info); this.drops.Add(Application.loadedLevelName, scene); } }
public static void Drop(Vector3 position, ItemDropType type, int itemID, int quantity) { GameHandler.DropHandler().Drop(position, type, itemID, quantity); }
public static void DropFromInventory(ItemDropType type, int itemID, int quantity) { GameHandler.RemoveFromInventory(type, itemID, quantity); GameHandler.DropHandler().Drop(type, itemID, quantity); }
public static void AddToInventory(ItemDropType type, int itemID, int quantity) { if(ItemDropType.ITEM.Equals(type)) { GameHandler.AddItem(itemID, quantity); } else if(ItemDropType.WEAPON.Equals(type)) { GameHandler.AddWeapon(itemID, quantity); } else if(ItemDropType.ARMOR.Equals(type)) { GameHandler.AddArmor(itemID, quantity); } }
public static void BuyToInventory(ItemDropType type, int itemID, int quantity, int price) { GameHandler.SubMoney(quantity*price); GameHandler.AddToInventory(type, itemID, quantity); }
public static ItemDropType[] Remove(int index, ItemDropType[] list) { ArrayList tmp = new ArrayList(); foreach(ItemDropType str in list) tmp.Add(str); tmp.RemoveAt(index); return tmp.ToArray(typeof(ItemDropType)) as ItemDropType[]; }
/* ============================================================================ Inventory functions ============================================================================ */ public static void SellFromInventory(ItemDropType type, int itemID, int quantity, int price) { GameHandler.AddMoney(quantity*price); GameHandler.RemoveFromInventory(type, itemID, quantity); }
public static ItemDropType[] Add(ItemDropType n, ItemDropType[] list) { ArrayList tmp = new ArrayList(); foreach(ItemDropType str in list) tmp.Add(str); tmp.Add(n); return tmp.ToArray(typeof(ItemDropType)) as ItemDropType[]; }
/* ============================================================================ Text functions ============================================================================ */ public string GetItemText(int itemID, int count, ItemDropType type) { string text = this.itemText[GameHandler.GetLanguage()] as string; if(ItemDropType.ITEM.Equals(type)) { text = text.Replace(BattleEnd.REPLACE_NAME, DataHolder.Items().GetName(itemID)); } else if(ItemDropType.WEAPON.Equals(type)) { text = text.Replace(BattleEnd.REPLACE_NAME, DataHolder.Weapons().GetName(itemID)); } else if(ItemDropType.ARMOR.Equals(type)) { text = text.Replace(BattleEnd.REPLACE_NAME, DataHolder.Armors().GetName(itemID)); } text = text.Replace(BattleEnd.REPLACE_NUMBER, count.ToString()); return text; }
public static bool HasInInventory(ItemDropType type, int itemID, int quantity) { bool has = false; if(ItemDropType.ITEM.Equals(type)) { has = GameHandler.HasItem(itemID, quantity); } else if(ItemDropType.WEAPON.Equals(type)) { has = GameHandler.HasWeapon(itemID, quantity); } else if(ItemDropType.ARMOR.Equals(type)) { has = GameHandler.HasArmor(itemID, quantity); } return has; }
public void setEquipmentDropType(ItemDropType equipmentDropType) { this.equipmentDropType = equipmentDropType; }
public string GetItemCollectionString(int id, int n, ItemDropType t) { return this.GetItemCollectionReplace(this.itemCollectionText[GameHandler.GetLanguage()], id, n, t); }
public string[] GetItemCollectionChoice(int id, int n, ItemDropType t) { return new string[] { this.GetItemCollectionReplace(this.itemCollectionYesText[GameHandler.GetLanguage()], id, n, t), this.GetItemCollectionReplace(this.itemCollectionNoText[GameHandler.GetLanguage()], id, n, t)}; }
private string GetItemCollectionReplace(string txt, int id, int n, ItemDropType t) { if(ItemDropType.ITEM.Equals(t)) txt = txt.Replace("%n", DataHolder.Items().GetName(id)); else if(ItemDropType.WEAPON.Equals(t)) txt = txt.Replace("%n", DataHolder.Weapons().GetName(id)); else if(ItemDropType.ARMOR.Equals(t)) txt = txt.Replace("%n", DataHolder.Armors().GetName(id)); txt = txt.Replace("%", n.ToString()); return txt; }
private void ShowStealInfo(string user, ItemDropType t, int id, int m) { if(DataHolder.BattleSystemData().showInfo) { // item text display if(id >= 0 && DataHolder.BattleSystemData().showStealItem) { string name = ""; if(ItemDropType.ITEM.Equals(t)) name = DataHolder.Items().GetName(id); else if(ItemDropType.WEAPON.Equals(t)) name = DataHolder.Weapons().GetName(id); else if(ItemDropType.ARMOR.Equals(t)) name = DataHolder.Armors().GetName(id); GameHandler.GetLevelHandler().ShowBattleInfo( DataHolder.BattleSystemData().GetStealItemText(user, name), DataHolder.BattleSystemData().infoPosition); } else if(this.stealItem && DataHolder.BattleSystemData().showStealItemFail) { GameHandler.GetLevelHandler().ShowBattleInfo( DataHolder.BattleSystemData().GetStealItemFailText(user), DataHolder.BattleSystemData().infoPosition); } // money text display if(m > 0 && DataHolder.BattleSystemData().showStealMoney) { GameHandler.GetLevelHandler().ShowBattleInfo( DataHolder.BattleSystemData().GetStealMoneyText(user, m.ToString()), DataHolder.BattleSystemData().infoPosition); } else if(this.stealMoney && DataHolder.BattleSystemData().showStealMoneyFail) { GameHandler.GetLevelHandler().ShowBattleInfo( DataHolder.BattleSystemData().GetStealMoneyFailText(user), DataHolder.BattleSystemData().infoPosition); } } }
public static void ItemTypeQuantitySelection(ref ItemDropType type, ref int id, ref int quantity) { ItemDropType tmp = type; type = (ItemDropType)EditorGUILayout.EnumPopup("Type", type, GUILayout.Width(mWidth)); if(!type.Equals(tmp)) id = 0; if(ItemDropType.ITEM.Equals(type)) { id = EditorGUILayout.Popup("Item", id, DataHolder.Items().GetNameList(true), GUILayout.Width(mWidth)); } else if(ItemDropType.WEAPON.Equals(type)) { id = EditorGUILayout.Popup("Weapon", id, DataHolder.Weapons().GetNameList(true), GUILayout.Width(mWidth)); } else if(ItemDropType.ARMOR.Equals(type)) { id = EditorGUILayout.Popup("Armor", id, DataHolder.Armors().GetNameList(true), GUILayout.Width(mWidth)); } quantity = EditorGUILayout.IntField("Quantity", quantity, GUILayout.Width(mWidth)); }
public void ItemCreated(int id, ItemDropType t) { if(this.logCreatedItems) this.createdItems++; if(this.logSingleCreated) { if(ItemDropType.ITEM.Equals(t) && id <this.singleCreatedItems.Length) { this.singleCreatedItems[id]++; } else if(ItemDropType.WEAPON.Equals(t) && id < this.singleCreatedWeapons.Length) { this.singleCreatedWeapons[id]++; } else if(ItemDropType.ARMOR.Equals(t) && id < this.singleCreatedArmors.Length) { this.singleCreatedArmors[id]++; } } }
public static void RemoveFromInventory(ItemDropType type, int itemID, int quantity) { if(ItemDropType.ITEM.Equals(type)) { GameHandler.RemoveItem(itemID, quantity); } else if(ItemDropType.WEAPON.Equals(type)) { GameHandler.RemoveWeapon(itemID, quantity); } else if(ItemDropType.ARMOR.Equals(type)) { GameHandler.RemoveArmor(itemID, quantity); } }
public void SetData(Hashtable ht) { if(ht.ContainsKey("ismoney")) this.isMoney = true; else { this.type = (ItemDropType)System.Enum.Parse(typeof(ItemDropType), (string)ht["type"]); this.id = int.Parse((string)ht["itemid"]); } this.quantity = int.Parse((string)ht["quantity"]); }
/* ============================================================================ Name functions ============================================================================ */ public static string GetItemName(ItemDropType type, int id) { string name = ""; if(ItemDropType.ITEM.Equals(type)) name = DataHolder.Items().GetName(id); else if(ItemDropType.WEAPON.Equals(type)) name = DataHolder.Weapons().GetName(id); else if(ItemDropType.ARMOR.Equals(type)) name = DataHolder.Armors().GetName(id); return name; }