Пример #1
0
 /// <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;
 }
Пример #2
0
 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"]);
         }
     }
 }
Пример #3
0
    // 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;
    }
Пример #4
0
    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);
        }
    }
Пример #5
0
    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);
        }
    }
Пример #6
0
 public static void Drop(Vector3 position, ItemDropType type, int itemID, int quantity)
 {
     GameHandler.DropHandler().Drop(position, type, itemID, quantity);
 }
Пример #7
0
 public static void DropFromInventory(ItemDropType type, int itemID, int quantity)
 {
     GameHandler.RemoveFromInventory(type, itemID, quantity);
     GameHandler.DropHandler().Drop(type, itemID, quantity);
 }
Пример #8
0
 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);
     }
 }
Пример #9
0
 public static void BuyToInventory(ItemDropType type, int itemID, int quantity, int price)
 {
     GameHandler.SubMoney(quantity*price);
     GameHandler.AddToInventory(type, itemID, quantity);
 }
Пример #10
0
 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[];
 }
Пример #11
0
 /*
 ============================================================================
 Inventory functions
 ============================================================================
 */
 public static void SellFromInventory(ItemDropType type, int itemID, int quantity, int price)
 {
     GameHandler.AddMoney(quantity*price);
     GameHandler.RemoveFromInventory(type, itemID, quantity);
 }
Пример #12
0
 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[];
 }
Пример #13
0
 /*
 ============================================================================
 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;
 }
Пример #14
0
 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;
 }
Пример #15
0
 public void setEquipmentDropType(ItemDropType equipmentDropType)
 {
     this.equipmentDropType = equipmentDropType;
 }
Пример #16
0
 public string GetItemCollectionString(int id, int n, ItemDropType t)
 {
     return this.GetItemCollectionReplace(this.itemCollectionText[GameHandler.GetLanguage()], id, n, t);
 }
Пример #17
0
 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)};
 }
Пример #18
0
 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;
 }
Пример #19
0
 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);
         }
     }
 }
Пример #20
0
 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));
 }
Пример #21
0
 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]++;
         }
     }
 }
Пример #22
0
 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);
     }
 }
Пример #23
0
 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"]);
 }
Пример #24
0
 /*
 ============================================================================
 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;
 }