예제 #1
0
    public static void loadItems()
    {
        string path = "URI=file:" + Application.dataPath + "/Database/Database.s3db";
        IDbConnection connection;

        connection = (IDbConnection)new SqliteConnection(path);
        connection.Open();
        IDbCommand command = connection.CreateCommand();

        // Items.* = Items.ID, Items.itemName, Items.itemDescription, Items.itemType, Items.strength, Items.intellect, Items.agility, Items.stamina, Items.armor
        string query = "select * from Items;";
        command.CommandText = query;
        IDataReader reader = command.ExecuteReader();
        while (reader.Read())
        {
            BaseItemStats one = new BaseItemStats();
            one.ItemID = reader.GetInt32(0);
            one.ItemName = reader.GetString(1);
            one.ItemDescription = reader.GetString(2);
            one.ItemType = (BaseItemStats.ItemTypes)reader.GetInt32(3);
            one.Strength = reader.GetInt32(4);
            one.Intellect = reader.GetInt32(5);
            one.Agility = reader.GetInt32(6);
            one.Stamina = reader.GetInt32(7);
            one.Armor = reader.GetInt32(8);
            itemsData[one.ItemID] = one;

        }
        reader.Close ();
        command.Dispose();
        connection.Close();
    }
예제 #2
0
파일: Loot.cs 프로젝트: Morthalin/TheGame
 void initEquipment()
 {
     BasePlayer pl = GameObject.Find ("Player").GetComponent<BasePlayer> ();
     emptyItem = pl.inventory.emptyItem;
     equipmentMap = pl.inventory.equipmentMap;
     equipmentOrder = pl.inventory.equipmentOrder;
     activePotions = pl.inventory.activePotions;
 }
예제 #3
0
파일: Loot.cs 프로젝트: Morthalin/TheGame
    void useItem(BaseItemStats item)
    {
        BasePlayer pl = GameObject.Find ("Player").GetComponent<BasePlayer> ();

        pl.strength += item.Strength;
        pl.intellect += item.Intellect;
        pl.agility += item.Agility;
        pl.stamina += item.Stamina;
        pl.healthMax += item.Stamina*10;
        pl.armor += item.Armor;

        if (item.ItemType == BaseItems.ItemTypes.NOTE) {
            //Debug.Log ("NOTE: " + ItemsData.notesData[item.ItemID].NoteText );
            lootList.text = "<b>" + ItemsData.notesData [item.ItemID].NoteText + "</b>";
            lootListLive += 10;
            showLoot (true);
        } else if (item.ItemType == BaseItems.ItemTypes.EQUIPMENT) {

            BaseEquipment.EquipTypes etype = ItemsData.equipmentData [item.ItemID].EquipType;
            int index = (int)etype - 1;
            // kdyz neni prazdne, odecteme vyhody a pridame do inventare
            if (equipmentMap [equipmentOrder [index]].ItemName != emptyItem.ItemName) {
                BaseItemStats bis = equipmentMap [equipmentOrder [index]];
                pl.strength -= bis.Strength;
                pl.intellect -= bis.Intellect;
                pl.agility -= bis.Agility;
                pl.stamina -= bis.Stamina;
                pl.healthMax -= bis.Stamina*10;
                pl.armor -= bis.Armor;
                // pridani do inventare
                itemsQuantity [bis.ItemID]++;
            }
            equipmentMap [equipmentOrder [index]] = item;
            switch((int)etype){
            case 1 :{changeMaterial(0,0,0); break;}
            case 2 :{changeMaterial(1,3,1); break;}
            case 3 :{changeMaterial(4,5,1); break;}
            case 4 :{changeMaterial(6,11,1); break;}
            case 5 :{changeMaterial(12,15,1); break;}
            case 6 :{changeMaterial(16,17,1); break;}
            }
            //zmena materialu

        } else if (item.ItemType == BaseItems.ItemTypes.WEAPON) {
            BaseWeapon.WeaponTypes wtype = ItemsData.weaponsData [item.ItemID].WeaponType;
            int index = (int)wtype - 1 + 6;
            // kdyz neni prazdne, odecteme vyhody a pridame do inventare
            if (equipmentMap [equipmentOrder [index]].ItemName != emptyItem.ItemName) {
                BaseItemStats bis = equipmentMap [equipmentOrder [index]];
                pl.strength -= bis.Strength;
                pl.intellect -= bis.Intellect;
                pl.agility -= bis.Agility;
                pl.stamina -= bis.Stamina;
                pl.healthMax -= bis.Stamina*10;
                pl.armor -= bis.Armor;
                // pridani do inventare
                itemsQuantity [bis.ItemID]++;
            }
            equipmentMap [equipmentOrder [index]] = item;
        } else if (item.ItemType == BaseItems.ItemTypes.POTION) {
            pl.strength -= item.Strength;
            pl.intellect -= item.Intellect;
            pl.agility -= item.Agility;
            pl.stamina -= item.Stamina;
            pl.healthMax -= item.Stamina*10;
            pl.armor -= item.Armor;
            BasePotion bp = ItemsData.potionsData[item.ItemID];
            if(activePotions.ContainsKey(item.ItemID)){
                activePotions[item.ItemID] += bp.PotionDuration;
            } else {
                activePotions[item.ItemID] = bp.PotionDuration;
                potionAction(item.ItemID, true);
            }
        }
    }
예제 #4
0
파일: Loot.cs 프로젝트: Morthalin/TheGame
    private void getItems( string name )
    {
        string path = "URI=file:" + Application.dataPath + "/Database/Database.s3db";
        SqliteConnection connection;

        connection = new SqliteConnection(path);
        connection.Open();

        // Items.* = Items.ID, Items.itemName, Items.itemDescription, Items.itemType, Items.strength, Items.intellect, Items.agility, Items.stamina, Items.armor
        string query = "select Loot.lootChance, Items.* from Creatures join Loot on Creatures.ID = creatureID "
                     + "join Items on ItemID = items.ID "
                     + "where creatureName = '" + name + "';";
        SqliteCommand command = new SqliteCommand (query, connection);
        SqliteDataReader reader = command.ExecuteReader ();

        string gain = "<b>";
        while (reader.Read())
        {
            float probability = (float)reader.GetFloat(0);

            BaseItemStats one = new BaseItemStats();
            one.ItemID = (int)reader.GetInt32(1);
            one.ItemName = (string) reader["itemName"];
            one.ItemDescription = reader.GetString(3);
            one.ItemType = (BaseItemStats.ItemTypes)reader.GetInt32(4); // itemType
            one.Strength = reader.GetInt32(5); // strength
            one.Intellect = reader.GetInt32(6); // intellect
            one.Agility = reader.GetInt32(7); // agility
            one.Stamina = reader.GetInt32(8); // stamina
            one.Armor = reader.GetInt32(9); // armor

            if( UnityEngine.Random.Range(0.0f, 100.0f) <= probability )
            {
                gain += one.ItemName + "\n";
                //inventory.itemsID.Add(one.ItemID);
                itemsData[one.ItemID] = one;
                if(  !itemsQuantity.ContainsKey(one.ItemID) )
                    itemsQuantity[one.ItemID] = 1;
                else
                    itemsQuantity[one.ItemID] ++;
            }
        }

        lootList.text = gain + "</b>";
        showLoot (true);

        lootListLive = 2.0f;
        reader.Close ();
        command.Dispose();
        connection.Close();
    }