Ejemplo n.º 1
0
    public bool LoadItem(string idToLoad)
    {
        string path = Application.persistentDataPath + "/" + idToLoad + ".txt";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            itemData data = formatter.Deserialize(stream) as itemData;

            stream.Close();

            ID = data.id;

            for (int i = 0; i < data.tags.Length; i++)
            {
                intents.Add(data.tags[i].ToLower(), data.awnsers[i]);
            }

            return(true);
        }
        else
        {
            Debug.LogError("ID not found");
        }

        return(false);
    }
Ejemplo n.º 2
0
    public void loadShopItemList()
    {
//		numItems = shopItems.Length;
        shopItemDisplay = new GameObject[numItemsAvail];

        for (int i = 0; i < numItemsAvail; i++)
        {
            shopItemDisplay[i] = Instantiate(shopItemPrefab);
            shopItemDisplay[i].transform.SetParent(buyMenuContent, false);
            shopItem                    = shopItemDisplay[i].GetComponent <shopItemController>();
            itemData                    = shopItems[i].GetComponent <itemData>();
            shopItem.shopMenu           = this;
            shopItem.name               = shopItems[i].name;
            shopItem.itemID             = itemData.itemID;
            shopItem.itemNumber         = i;
            shopItem.itemName           = shopItem.name;
            shopItem.itemNameText.text  = shopItem.name;
            shopItem.itemSprite         = itemData.itemImage;
            shopItem.itemImage.sprite   = shopItem.itemSprite;
            shopItem.itemDescription    = itemData.itemDescription;
            shopItem.itemPrice          = itemData.cost;
            shopItem.itemPriceText.text = shopItem.itemPrice.ToString();
            shopItem.itemCarryLimit     = itemData.carryLimit;
            shopItem.itemStackSize      = itemData.stackLimit;
            shopItem.inventoryIndex     = itemData.inventoryIndex;
            shopItem.itemInventoryCount = itemData.currentAmount;
            shopItem.numOwned           = itemData.totalOwned;
        }

        shopItem = shopItemDisplay[selectedItemIndex].GetComponent <shopItemController>();
        updateDescription(selectedItemIndex);
    }
    public void removeEquip()
    {
        if (selectedEquipItem != -1)
        {
            equipItemController = equipmentList[selectedEquipItem].GetComponent <equipItemController>();
            int        index         = equipItemController.inventoryIndex;
            itemData   iteminfo      = inventoryController.partyInventory[index].GetComponent <itemData>();
            Characters equippedChara = iteminfo.charaUsing;

            if (equipItemController.isEquipped)
            {
                if (currentChara == equippedChara)
                {
                    charaEquipManager.unequip(EquipSlot);
                    charaStatus.updateStats();
                    equipItemController.isEquipped = false;
                    equipmentList[selectedEquipItem].GetComponentInChildren <Text>().color = unequippedColor;
                }
            }
            displayCurrentEquip();
            loadEquipStats();
            selectedEquipSlot = -1;
            selectedEquipItem = -1;
        }

        if (selectedEquipSlot != -1)
        {
            charaEquipManager.unequip(EquipSlot);
            charaStatus.updateStats();
            displayCurrentEquip();
            loadEquipStats();
            selectedEquipSlot = -1;
            selectedEquipItem = -1;
        }
    }
Ejemplo n.º 4
0
    public void instantiateItem(int slotID, int ID, int quantity)
    {
        if (mySlots.Count <= slotID)
        {
            return; //doesnt exist
        }
        //clear the children
        foreach (Transform child in mySlots[slotID].transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        //check if slot exists and is available (on server, this is just ui logic)

        GameObject newItem  = Instantiate(item);
        itemData   ItemData = lookUpID(ID);

        if (ItemData != null)
        {
            if (ItemData.icon != null)
            {
                newItem.GetComponent <Image>().sprite = ItemData.icon;
            }
        }

        if (quantity > 1)
        {
            newItem.transform.GetChild(0).GetComponent <Text>().text = quantity.ToString();
        }
        newItem.GetComponent <testDrag>().slot = slotID;
        newItem.transform.SetParent(mySlots[slotID].transform);
        newItem.GetComponent <RectTransform>().localPosition = Vector3.zero;
        // newSlot.GetComponent<RectTransform>().localPosition = position;
        //  mySlots.Add(newSlot);
    }
Ejemplo n.º 5
0
 public void initItemData()
 {
     string[][] arrAll = getData("data/item", "\r\n");
     for (int i = 0; i < arrAll.Length; i++)
     {
         string[] arr    = arrAll[i];
         int      itemId = int.Parse(arr[0]);
         itemData item   = new itemData();
         item.itemId           = itemId;
         item.itemName         = arr[1];
         item.itemIcon         = arr[2];
         item.itemInfo         = arr[5];
         item.itemEffectName   = arr[6];
         item.attackType       = int.Parse(arr[3]);
         item.itemType         = int.Parse(arr[4]);
         item.attackNum        = int.Parse(arr[7]);
         item.attackInterval   = float.Parse(arr[8]);
         item.music            = arr[9];
         item.attackRange      = int.Parse(arr[10]);
         item.effectPriotY     = float.Parse(arr[11]);
         item.stateDuration    = int.Parse(arr[12]);//1000开头的是击晕,2000开头的是减速,3000开头的是逆行
         item.stateChance      = float.Parse(arr[13]);
         item.attackDamage     = int.Parse(arr[14]);
         item.startAttackIndex = int.Parse(arr[15]);
         item.shakeScreenNum   = float.Parse(arr[16]);
         //item.converseTime = int.Parse (arr[19]);
         itemDic[itemId] = item;
     }
 }
Ejemplo n.º 6
0
    public void useItem()
    {
//		GameObject[] playerItems
//		int itemIndex = selectedItem;
        itemData   item   = inventoryController.partyInventory[selectedItem].GetComponent <itemData>();
        GameObject target = targets[selectedTarget];
        characterStatusController targetStatus = target.GetComponent <characterStatusController>();

        inventoryController.useItem(selectedItem);
        itemBattleController itemController = playerItems[selectedItemNum].GetComponent <itemBattleController>();

        itemController.itemCount--;

        if (itemController.itemCount > 0)
        {
            itemController.itemCountText.text = itemController.itemCount.ToString();
        }
        else
        {
            foreach (GameObject playerItem in playerItems)
            {
                Destroy(playerItem);
            }
            numItems = 0;
            loadItems();
        }

        targetStatus.calculateDamage(item);

        targetMenu.SetActive(false);
        itemsMenu.SetActive(false);
        selectedItem   = -1;
        selectedTarget = -1;
    }
Ejemplo n.º 7
0
    public void saveEm()
    {
        // string jsonString = PlayerPrefs.GetString("TestSave" + saveIndex);
        //tester = JsonUtility.FromJson<dataContainer>(jsonString);

        tester.dataHolder.Clear();

        tester.newObjectsData.Clear();

        foreach (GameObject obj in items)
        {
            if (tester.alive.Contains(obj.name))
            {
                itemData storage = new itemData {
                    pos = obj.transform.position, counter = obj.GetComponent <ItemPickup>().count
                };
                tester.dataHolder.Add(storage);
            }
            if (tester.objsToInstantiate.Contains(obj.name))
            {
                itemData storage = new itemData {
                    pos = obj.transform.position, counter = obj.GetComponent <ItemPickup>().count, item = obj.GetComponent <ItemPickup>().item
                };
                tester.newObjectsData.Add(storage);
            }
        }
        string json = JsonUtility.ToJson(tester);

        PlayerPrefs.SetString("itemSave" + SceneManager.GetActiveScene().name + id.instance.saveIndex, json);
        PlayerPrefs.Save();
    }
Ejemplo n.º 8
0
    public void addItem(int ID, int quantity)
    {
        //if stackable try adding to non full stacks
        itemData ItemData = myInventory.lookUpID(ID);

        if (ItemData.stackable)
        {
            int currentQuantity = quantity;


            for (int i = 0; i < state.slots; i++)
            {
                if (state.items[i].ID == ID)
                {
                    if (state.items[i].quantity < ItemData.stackSize)
                    {
                        int moveQuanity;

                        int moveSpace = ItemData.stackSize - state.items[i].quantity;

                        if (moveSpace >= quantity)
                        {
                            moveQuanity = quantity;
                        }
                        else
                        {
                            moveQuanity = moveSpace;
                        }

                        state.items[i].quantity += moveQuanity;
                        currentQuantity         -= moveQuanity;
                        if (currentQuantity == 0)
                        {
                            return;
                        }
                    }
                }
            }
        }



        for (int i = 0; i < state.slots; i++)
        {
            if (state.items[i].ID == 0)
            {
                state.items[i].ID       = ID;
                state.items[i].quantity = quantity;
                return;
            }
        }


        Debug.Log("no space");
    }
Ejemplo n.º 9
0
 public bool AddItem(itemData item)
 {
     if (m_itemList.Count == m_capacity)
     {
         // inventory is full
         return(false);
     }
     m_itemList.Add(item);
     item.m_item.transform.parent = transform;
     return(true);
 }
Ejemplo n.º 10
0
            public itemData RandomiseItem(int x, int y)
            {
                itemData item = new itemData();

                item.kind = RandomItemType();
                item.bmp  = itemBitmap(item.kind);
                item.x    = x;
                item.y    = y;

                return(item);
            }
Ejemplo n.º 11
0
    public void SaveItem()
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/" + ID + ".txt";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        itemData data = new itemData(intents);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Ejemplo n.º 12
0
    public itemData RemoveItem(int _index)
    {
        if (_index >= m_capacity)
        {
            return(null);
        }
        itemData item = m_itemList[_index];

        m_itemList.RemoveAt(_index);
        item.m_item.transform.parent = null;
        return(item);
    }
Ejemplo n.º 13
0
    void Start()
    {
        foreach (int NonSpecificId in itemIDs.shopableCatagories)
        {
            switch (NonSpecificId)
            {
            case 1:
                for (int specificID = 0; specificID < itemIDs.swords.Length; specificID++)
                {
                    if (itemIDs.swords[specificID].buyable)
                    {
                        Array.Resize(ref itemsToBuy, itemsToBuy.Length + 1);
                        itemsToBuy[itemsToBuy.Length - 1] = itemIDs.swords[specificID];
                    }
                }
                break;

            case 2:
                for (int specificID = 0; specificID < itemIDs.shurkens.Length; specificID++)
                {
                    if (itemIDs.swords[specificID].buyable)
                    {
                        Array.Resize(ref itemsToBuy, itemsToBuy.Length + 1);
                        itemsToBuy[itemsToBuy.Length - 1] = itemIDs.shurkens[specificID];
                    }
                }
                break;
            }
        }
        int index = 0;

        foreach (itemData item in itemsToBuy)
        {
            // setup the button location
            GameObject clone = Instantiate(transform.GetChild(0).gameObject, transform); // clone the base object
            clone.SetActive(true);                                                       // set it active
            clone.GetComponent <RectTransform>().offsetMin = transform.GetChild(0).GetComponent <RectTransform>().offsetMin + offset * index;
            clone.GetComponent <RectTransform>().offsetMax = transform.GetChild(0).GetComponent <RectTransform>().offsetMax + offset * index;

            // set the item data
            clone.GetComponent <Image>().sprite = item.item.GetComponent <SpriteRenderer>().sprite;                    // set the image
            clone.transform.GetChild(0).GetComponent <Text>().text             = item.itemName;                        // set the item name
            clone.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = "$" + item.price.ToString();          // set the price in the button

            itemData itemBoi = item;                                                                                   // make seconds variable so that the function is not referancing the variable
            clone.transform.GetChild(1).GetComponent <Button>().onClick.AddListener(delegate() { buyItem(itemBoi); }); // add the listener to the button

            index++;
        }
    }
Ejemplo n.º 14
0
 void buyItem(itemData data)
 {
     if (player.Money - data.price < 0)
     {
         print("player cannot buy this item!");
         // display the player cannot buy text, but for now its a print statement
     }
     else
     {
         print(ArrayUtility.FindIndex(inventory.currentStoredItems, x => x.Equals(data.itemID)));
         player.Money = player.Money - data.price;
         if (inventory.currentStoredItems.Contains(data.itemID) && data.stackable)
         {
             //int index = inventory.currentStoredItems.Length
             print(ArrayUtility.FindIndex(inventory.currentStoredItems, x => x.Equals(data.itemID)));
         }
     }
 }
Ejemplo n.º 15
0
    public itemData GetItemData(int id)
    {
        itemData tmp = new itemData();

        try{
            tmp.id          = id;
            tmp.name        = entityCollection.items[id].name;
            tmp.rarity      = entityCollection.items[id].rarity;
            tmp.price       = entityCollection.items[id].price;
            tmp.description = entityCollection.items[id].description;
        }catch (Exception e) {
            tmp.id          = id;
            tmp.name        = "NOTHING!!!!";
            tmp.rarity      = -1;
            tmp.price       = -1;
            tmp.description = "U DON FKED UP:<br>" + e.Message;
        }
        return(tmp);
    }
Ejemplo n.º 16
0
    public void ApplyChanges(string component)
    {
        switch (component)
        {
        case "SpriteEditor":
            SpriteRenderer renderer = currenttile.GetComponent <SpriteRenderer>();
            renderer.sprite = Resources.Load <Sprite>("interiortiles/" + tilepool[currentTileIndex].sprite);
            break;

        case "Property":
            itemData itemdata = currenttile.GetComponent <itemData>();
            itemdata.onlyonce = onlyonce.isOn;
            itemdata.hasText  = hasText.isOn;
            int.TryParse(textId.text, out itemdata.TextID);
            itemdata.itemName = itemname.text;

            break;

        case "Warp":
            TileWarp warp = currenttile.GetComponent <TileWarp>();
            warp.warppos = warpmarker.transform.position;
            break;

        case "TallGrass":
            if (currentmode == Mode.Select)
            {
                foreach (GameObject selectedtile in selectedtiles)
                {
                    TallGrass tg = selectedtile.GetComponent <TallGrass>();
                    int.TryParse(wildgroupid.text, out tg.WildGroupID);
                }
            }
            else if (currentmode == Mode.Edit)
            {
                TallGrass tg = currenttile.GetComponent <TallGrass>();
                int.TryParse(wildgroupid.text, out tg.WildGroupID);
            }

            break;
        }
    }
Ejemplo n.º 17
0
    public void calculateDamage(itemData item)
    {
        int damage      = item.damage;
        int MPRecovered = item.MPRecovered;

//		Debug.Log("chara: " + charaName + ", item: " + item.itemName +
//			", base item dmg: " + damage);
        damageText.color = healColor;

        if (damage > 0)
        {
            damage          -= currentDef;
            damageText.color = damageColor;
        }

//		Debug.Log("item dmg: " + damage + ", currHP: " + currentHP +
//			", newHP: " + (currentHP - damage));
        currentHP      -= damage;
        currentMP      += MPRecovered;
        damageText.text = Mathf.Abs(damage).ToString();
        damageTextTimer = damageTextTimeout;
//		Debug.Log("dmgText: " + damageText + ", damageTextTimer: "
//			+ damageTextTimer);

        if (currentHP > maxHP)
        {
            currentHP = maxHP;
        }

        if (currentMP > maxMP)
        {
            currentMP = maxMP;
        }

        if (currentHP < 0)
        {
            currentHP = 0;
            GameObject.Find("gameController").GetComponent <battleController>().killCharacter(this.gameObject);
        }
        HPSlider.value = currentHP;
    }
    public itemData AttemptSpawnObject(RoomData room, GameObject obj, int ySpawnOffset) // tries to spawn object in random position of a room
    {
        // find random 2d point on ceiling
        Vector3 roomCornerOffset = room.bounds.center - (room.bounds.size / 2);
        int     randomCX         = (int)Random.Range(1, room.bounds.size.x);
        int     randomCY         = (int)Random.Range(1, room.bounds.size.z);
        Vector3 ceilingPos       = roomCornerOffset + new Vector3(randomCX, (float)(room.bounds.size.y - 1), randomCY); // make add from corner of position of room

        while (!validSpawnPosition(ceilingPos, room))
        {
            randomCX   = (int)Random.Range(1, room.bounds.size.x);
            randomCY   = (int)Random.Range(1, room.bounds.size.z);
            ceilingPos = roomCornerOffset + new Vector3(randomCX, (float)(room.bounds.size.y - 1), randomCY);
        }

        //  Ray ray = new Ray(ceilingPos, Vector3.down);
        //    Debug.DrawRay(ray.origin, ray.direction * 10, Color.red, 10);

        RaycastHit hit;
        Ray        ray1 = new Ray(ceilingPos, Vector3.down);

        //  Debug.DrawRay(ray.origin, ray.direction * 1000, Color.red, 100);
        Physics.Raycast(ray1, out hit, room.bounds.size.y);

        itemData temp = new itemData(obj); // make spawn off of prefab later TODOTDO

        temp.pos = hit.point + new Vector3(0, ySpawnOffset, 0);

        // temp.name =(room.name + " object: " + temp.transform.position);
        temp.name = "tempItem";
        //print(temp.name);
        return(temp);


        //when true, add gameObject to room objects list
        //if for some reason can't find a space, return null
    }
Ejemplo n.º 19
0
    public void loadInventoryList()
    {
        numItems       = inventoryController.numItemsPtInventory;
        playerItemList = new GameObject[numItems];

        for (int i = 0; i < numItems; i++)
        {
            playerItemList[i] = Instantiate(inventoryItemPrefab);
            playerItemList[i].transform.SetParent(sellMenuContent, false);
            playerItem                    = playerItemList[i].GetComponent <shopPlayerItemController>();
            itemData                      = inventoryController.partyInventory[i];
            playerItem.shopMenu           = this;
            playerItem.name               = itemData.itemName;
            playerItem.itemID             = itemData.itemID;
            playerItem.inventoryIndex     = i;
            playerItem.itemNumber         = i;
            playerItem.itemName           = playerItem.name;
            playerItem.itemNameText.text  = playerItem.name;
            playerItem.itemSprite         = itemData.itemImage;
            playerItem.itemImage.sprite   = playerItem.itemSprite;
            playerItem.itemDescription    = itemData.itemDescription;
            playerItem.itemPrice          = itemData.sellValue;
            playerItem.itemPriceText.text = playerItem.itemPrice.ToString();
            playerItem.itemInventoryCount = itemData.currentAmount;
            playerItem.isEquipped         = itemData.isEquipped;
            playerItem.numEquipped        = itemData.numEquipped;

            if (playerItem.isEquipped)
            {
                playerItem.itemNameText.color = equippedColor;
            }
        }

        playerItem = playerItemList[selectedItemIndex].GetComponent <shopPlayerItemController>();
        updateDescription(selectedItemIndex);
    }
Ejemplo n.º 20
0
    public void initializeEnemies()
    {
        tester                   = new itemDataContainer();
        tester.dead              = new List <string>();
        tester.alive             = new List <string>();
        tester.pool              = new List <string>();
        tester.newObjectsData    = new List <itemData>();
        tester.objsToInstantiate = new List <string>();
        tester.dataHolder        = new List <itemData>();

        foreach (GameObject enemy in items)
        {
            tester.alive.Add(enemy.name);
            itemData storage = new itemData {
                pos = enemy.transform.position, counter = enemy.GetComponent <ItemPickup>().count
            };
            tester.dataHolder.Add(storage);
        }
        string json = JsonUtility.ToJson(tester);

        PlayerPrefs.SetString("itemSave" + SceneManager.GetActiveScene().name + id.instance.saveIndex, json);

        PlayerPrefs.Save();
    }
Ejemplo n.º 21
0
        public static void ProcessItems()
        {
            String itemDir = "F:\\Dota2Wiki\\scrape\\spider\\www.dotafire.com\\dota-2\\item";
            DirectoryInfo dir = new DirectoryInfo(itemDir);
            IEnumerable<FileInfo> files = dir.EnumerateFiles();

            itemData[] items = new itemData[files.Count()];

            StreamReader reader;
            string line, tempString;

            bool inStatsSection = false;

            int itemIndex = 0;

            int parseIndex = 0;
            int startValueIndex = 0;
            int endValueIndex = 0;

            foreach (FileInfo fi in files)
            {
                reader = fi.OpenText();
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains("Recipe Cost:") || line.Contains("Details"))
                    {
                        inStatsSection = true;
                    }
                    else if (line.Contains("Discussion"))
                    {
                        inStatsSection = false;
                    }

                    if (inStatsSection)
                    {
                        //get to cost line
                        if(line.Contains("Recipe Cost"))
                        {
                            line = reader.ReadLine();

                            parseIndex = line.IndexOf('>');
                            items[itemIndex].cost = Convert.ToInt32(line.Substring(parseIndex+1));
                        }

                        while (!line.Contains("hiliteO"))
                        {
                            line = reader.ReadLine();
                        }

                        parseIndex = line.IndexOf('>');
                        startValueIndex = parseIndex + 1;
                        endValueIndex = line.IndexOf("</h2>");
                        items[itemIndex].itemName = line.Substring(startValueIndex, endValueIndex - startValueIndex);

                        line = reader.ReadLine();

                        if (line.Contains("Damage") || line.Contains("damage"))
                        {
                            startValueIndex = line.IndexOf('+') + 1;
                            endValueIndex = line.IndexOf("Damage", startValueIndex) - 1;
                            if (endValueIndex == -2)
                                endValueIndex = line.IndexOf("damage", startValueIndex) - 1;
                            items[itemIndex].damageMod = line.Substring(startValueIndex, endValueIndex - startValueIndex);
                        }
                        else if (line.Contains("Strength") || line.Contains("strength"))
                        {
                            startValueIndex = line.IndexOf('+') + 1;
                            endValueIndex = line.IndexOf("Strength", startValueIndex) - 1;
                            if(endValueIndex == -2)
                                endValueIndex = line.IndexOf("strength", startValueIndex) - 1;
                            items[itemIndex].strMod = line.Substring(startValueIndex, endValueIndex - startValueIndex);
                        }
                        else if (line.Contains("Intelligence") || line.Contains("intelligence"))
                        {
                            startValueIndex = line.IndexOf('+') + 1;
                            endValueIndex = line.IndexOf("Intelligence", startValueIndex) - 1;
                            if (endValueIndex == -2)
                                endValueIndex = line.IndexOf("intelligence", startValueIndex) - 1;
                            items[itemIndex].intMod = line.Substring(startValueIndex, endValueIndex - startValueIndex);
                        }
                        else if (line.Contains("Agility") || line.Contains("agility"))
                        {
                            startValueIndex = line.IndexOf('+') + 1;
                            endValueIndex = line.IndexOf("Agility", startValueIndex) - 1;
                            if (endValueIndex == -2)
                                endValueIndex = line.IndexOf("agility", startValueIndex) - 1;
                            items[itemIndex].agiMod = line.Substring(startValueIndex, endValueIndex - startValueIndex);
                        }
                        else if (line.Contains("All") || line.Contains("all"))
                        {
                            startValueIndex = line.IndexOf('+') + 1;
                            endValueIndex = line.IndexOf("All", startValueIndex) - 1;
                            if (endValueIndex == -2)
                                endValueIndex = line.IndexOf("all", startValueIndex) - 1;
                            items[itemIndex].allAttributesMod = line.Substring(startValueIndex, endValueIndex - startValueIndex);
                        }

                        inStatsSection = false;
                    }
                }
                itemIndex++;
            }

            int printIter = 0;

            //StreamWriter newFile = new StreamWriter("F:\\Dota2Wiki\\Items.csv");

            //if (newFile != null)
            //{
            //    newFile.AutoFlush = true;
            //    while (printIter < itemIndex)
            //    {
            //        newFile.WriteLine(items[printIter].itemName + ","
            //            + (items[printIter].cost == null ? String.Empty : items[printIter].cost.ToString()) + ","
            //            + (items[printIter].allAttributesMod == null ? String.Empty : items[printIter].allAttributesMod) + ","
            //            + (items[printIter].strMod == null ? String.Empty : items[printIter].strMod) + ","
            //            + (items[printIter].agiMod == null ? String.Empty : items[printIter].agiMod) + ","
            //            + (items[printIter].intMod == null ? String.Empty : items[printIter].intMod) + ","
            //            + (items[printIter].damageMod == null ? String.Empty : items[printIter].damageMod));
            //        printIter++;
            //    }
            //    newFile.Close();
            //}

            SqlConnection localDB = new SqlConnection(Properties.Settings.Default.DOTA2BuildCalculatorConnectionString);

            SqlCommand insertCommand;
            SqlCommand checkCommand;
            SqlDataReader checkResult;

            printIter = 0;

            localDB.Open();

            while (printIter < itemIndex)
            {
                checkCommand = new SqlCommand("Select ItemName from Items where ItemName like '" + items[printIter].itemName + "'", localDB);

                checkResult = checkCommand.ExecuteReader();

                if (!checkResult.HasRows)
                {
                    //(ChampionName, initialStr, initialAgi, initialInt, strGrowth, agiGrowth, intGrowth, movSpeed, armor, range)
                    checkResult.Close();
                    insertCommand = new SqlCommand("INSERT into Items values ('" + items[printIter].itemName + "','"
                        + (items[printIter].cost == null ? String.Empty : items[printIter].cost.ToString()) + "','"
                        + (items[printIter].strMod == null ? String.Empty : items[printIter].strMod) + "','"
                        + (items[printIter].intMod == null ? String.Empty : items[printIter].intMod) + "','"
                        + (items[printIter].agiMod == null ? String.Empty : items[printIter].agiMod) + "','"
                        + (items[printIter].damageMod == null ? String.Empty : items[printIter].damageMod) + "','"
                        + (items[printIter].allAttributesMod == null ? String.Empty : items[printIter].allAttributesMod) + "')", localDB);

                    int rows = insertCommand.ExecuteNonQuery();
                    //insertCommand.
                }
                else
                    checkResult.Close();
                printIter++;
            }

            localDB.Close();

            int poop;
        }
Ejemplo n.º 22
0
    public void equip(int inventoryIndex, EquipmentSlot EquipSlot)
    {
        switch (EquipSlot)
        {
        case EquipmentSlot.mainWpn:
        {
            if (!mainWeapon)
            {
                mainWeapon = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = mainWeapon.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.mainWpn);
                mainWeapon = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = mainWeapon.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }

        case EquipmentSlot.subWpn:
        {
            if (!subWeapon)
            {
                subWeapon = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = subWeapon.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.subWpn);
                subWeapon = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = subWeapon.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }

        case EquipmentSlot.head:
        {
            if (!head)
            {
                head = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = head.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.head);
                head = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = head.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }

        case EquipmentSlot.chest:
        {
            if (!chest)
            {
                chest = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = chest.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.chest);
                chest = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = chest.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }

        case EquipmentSlot.hands:
        {
            if (!hands)
            {
                hands = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = hands.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.hands);
                hands = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = hands.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }

        case EquipmentSlot.legs:
        {
            if (!legs)
            {
                legs = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = legs.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.legs);
                legs = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = legs.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }

        case EquipmentSlot.feet:
        {
            if (!feet)
            {
                feet = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = feet.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.feet);
                feet = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = feet.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }

        case EquipmentSlot.accessory:
        {
            if (!accessory)
            {
                accessory = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = accessory.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            else
            {
                unequip(EquipmentSlot.accessory);
                accessory = partyInventory.transform.GetChild(inventoryIndex).gameObject;
                itemData itemData = accessory.GetComponent <itemData>();
                totalDefense       += itemData.defense;
                totalAttack        += itemData.damage;
                itemData.isEquipped = true;
                itemData.charaUsing = character;
                masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped++;
            }
            break;
        }
        }
    }
Ejemplo n.º 23
0
    public void unequip(EquipmentSlot slot)
    {
        switch (slot)
        {
        case EquipmentSlot.mainWpn:
        {
            itemData itemData = mainWeapon.GetComponent <itemData>();
//				int itemIndex = mainWeapon.GetComponent<itemData>().inventoryIndex;
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				charaMenuController.markUnequipped(itemIndex);
            mainWeapon.GetComponent <itemData>().isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            mainWeapon = null;
            break;
        }

        case EquipmentSlot.subWpn:
        {
            itemData itemData = subWeapon.GetComponent <itemData>();
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				inventoryController.partyInventory[subWeapon.GetComponent<itemData>().inventoryIndex].isEquipped = false;
            itemData.isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            subWeapon = null;
            break;
        }

        case EquipmentSlot.head:
        {
            itemData itemData = head.GetComponent <itemData>();
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				inventoryController.partyInventory[head.GetComponent<itemData>().inventoryIndex].isEquipped = false;
            itemData.isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            head = null;
            break;
        }

        case EquipmentSlot.chest:
        {
            itemData itemData = chest.GetComponent <itemData>();
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				inventoryController.partyInventory[chest.GetComponent<itemData>().inventoryIndex].isEquipped = false;
            itemData.isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            chest = null;
            break;
        }

        case EquipmentSlot.hands:
        {
            itemData itemData = hands.GetComponent <itemData>();
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				inventoryController.partyInventory[hands.GetComponent<itemData>().inventoryIndex].isEquipped = false;
            itemData.isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            hands = null;
            break;
        }

        case EquipmentSlot.legs:
        {
            itemData itemData = legs.GetComponent <itemData>();
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				inventoryController.partyInventory[legs.GetComponent<itemData>().inventoryIndex].isEquipped = false;
            itemData.isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            legs = null;
            break;
        }

        case EquipmentSlot.feet:
        {
            itemData itemData = feet.GetComponent <itemData>();
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				inventoryController.partyInventory[feet.GetComponent<itemData>().inventoryIndex].isEquipped = false;
            itemData.isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            feet = null;
            break;
        }

        case EquipmentSlot.accessory:
        {
            itemData itemData = accessory.GetComponent <itemData>();
            totalDefense -= itemData.defense;
            totalAttack  -= itemData.damage;
//				inventoryController.partyInventory[accessory.GetComponent<itemData>().inventoryIndex].isEquipped = false;
            itemData.isEquipped = false;
            masterList.getItem(itemData.itemID).GetComponent <itemData>().numEquipped--;
            accessory = null;
            break;
        }
        }

        charaMenuController.listEquip();
        charaMenuController.displayCurrentEquip();
    }
Ejemplo n.º 24
0
 public void selectCharacter(itemData item)
 {
 }
Ejemplo n.º 25
0
 public itemData RemoveItem(itemData _item)
 {
     return(RemoveItem(_item.m_itemName));
 }
Ejemplo n.º 26
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            if (currentmode == Mode.Delete)
            {
                currentmode = Mode.Edit;
                goto ChangeModeEnd;
            }
            if (currentmode == Mode.Edit)
            {
                currentmode = Mode.Select;

                goto ChangeModeEnd;
            }
            if (currentmode == Mode.Select)
            {
                currentmode    = Mode.Delete;
                candeleteagain = true;
                foreach (GameObject sprite in multisselectsprites)
                {
                    multisselectsprites.Remove(sprite);
                    Destroy(sprite);
                }
                foreach (GameObject sprite in selectedtiles)
                {
                    selectedtiles.Remove(sprite);
                }
                goto ChangeModeEnd;
            }
        }
ChangeModeEnd:
        switch (currentmode)
        {
        case Mode.Edit:
            modetext.text = "Mode: Draw/Edit";
            break;

        case Mode.Delete:
            modetext.text = "Mode: Delete";
            break;

        case Mode.Select:
            modetext.text = "Mode: Multi-Edit";
            break;
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            currentTileIndex--;
            if (currentTileIndex < 0)
            {
                currentTileIndex = tilepool.Count - 1;
            }
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            currentTileIndex++;
            if (currentTileIndex == tilepool.Count)
            {
                currentTileIndex = 0;
            }
        }
        if (currentmode == Mode.Select)
        {
            hasWarpComponent      = true;
            hasPropertyComponent  = true;
            hasTallGrassComponent = true;
            foreach (GameObject selectedtile in selectedtiles)
            {
                if (!selectedtile.GetComponent <itemData>())
                {
                    hasPropertyComponent = false;
                }
                if (!selectedtile.GetComponent <TileWarp>())
                {
                    hasWarpComponent = false;
                }
                if (!selectedtile.GetComponent <TallGrass>())
                {
                    hasTallGrassComponent = false;
                }
            }
        }
        else if (currenttile != null)
        {
            hasPropertyComponent  = currenttile.GetComponent <itemData>();
            hasWarpComponent      = currenttile.GetComponent <TileWarp>();
            hasTallGrassComponent = currenttile.GetComponent <TallGrass>();
        }

        editchangesprite.sprite    = Resources.Load <Sprite>("interiortiles/" + tilepool[currentTileIndex].sprite);
        previewCreateSprite.sprite = Resources.Load <Sprite>("interiortiles/" + tilepool[currentTileIndex].sprite);

        transform.Translate(new Vector2(-Input.mouseScrollDelta.x, Input.mouseScrollDelta.y));
        Vector3 mousepos = editorcamera.ScreenToViewportPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));

        mousepos = editorcamera.ViewportToWorldPoint(mousepos);
        Vector2      snappos = new Vector2(Mathf.Round(mousepos.x), Mathf.Round(mousepos.y));
        RaycastHit2D hit     = Physics2D.Raycast(snappos, Vector2.zero);

        if (hit.collider != null)
        {
            hoveredtile = hit.collider.gameObject;
        }
        if (!placingWarp)
        {
            tilecursor.transform.position = new Vector2(Mathf.Round(mousepos.x), Mathf.Round(mousepos.y));
        }
        else
        {
            warpmarker.transform.position = new Vector2(Mathf.Round(mousepos.x), Mathf.Round(mousepos.y));
        }
        if (Input.mousePosition.x < Screen.width * 0.775f)
        {
            if (Input.GetMouseButtonDown(0) && currentmode == Mode.Edit)
            {
                if (!placingWarp)
                {
                    if (hit.collider != null)
                    {
                        currenttile = hit.collider.gameObject;
                        if (currenttile.GetComponent <itemData>())
                        {
                            itemData itemdata = currenttile.GetComponent <itemData>();

                            onlyonce.isOn = itemdata.onlyonce;
                            hasText.isOn  = itemdata.hasText;
                            textId.text   = itemdata.TextID.ToString();
                            itemname.text = itemdata.itemName;
                        }
                        if (currenttile.GetComponent <TileWarp>())
                        {
                            TileWarp warp = currenttile.GetComponent <TileWarp>();
                            warpmarker.transform.position = warp.warppos;
                        }
                    }
                }
            }
            if (Input.GetMouseButton(0) && !placingWarp && currentmode == Mode.Select && hit.collider != null && (snappos != lastselectedpos || canselectagain))
            {
                if (!selectedtiles.Contains(hoveredtile))
                {
                    canselectagain = false;
                    selectedtiles.Add(hoveredtile);
                    GameObject go = Instantiate(selectmarker, snappos, Quaternion.identity);
                    multisselectsprites.Add(go);
                    lastselectedpos = snappos;
                }
                else
                {
                    canselectagain = false;
                    Destroy(multisselectsprites[selectedtiles.IndexOf(hoveredtile)]);
                    multisselectsprites.RemoveAt(selectedtiles.IndexOf(hoveredtile));
                    selectedtiles.Remove(hoveredtile);
                    lastselectedpos = snappos;
                }
            }
            if (Input.GetMouseButtonUp(0) && !placingWarp && currentmode == Mode.Select && lastselectedpos == snappos)
            {
                canselectagain = true;
            }
            if (Input.GetMouseButtonUp(0) && !placingWarp && currentmode == Mode.Delete && lastdeletedpos == snappos)
            {
                candeleteagain = true;
            }
            if (Input.GetMouseButton(0) && !placingWarp && currentmode == Mode.Delete && hit.collider != null && (snappos != lastdeletedpos || candeleteagain))
            {
                Destroy(hoveredtile);
                candeleteagain = false;
                lastdeletedpos = snappos;
            }
            if (Input.GetMouseButtonUp(0) && placingWarp)
            {
                placingWarp = false;
            }
            if (Input.GetMouseButton(0) && !placingWarp && currentmode == Mode.Edit && tilepool[currentTileIndex].tag == "TallGrass")
            {
                if (hoveredtile.tag == "TallGrass")
                {
                    goto SkipTallGrassRule;
                }
                GameObject gameObject = Instantiate(template, container.transform, true);
                gameObject.transform.position = snappos;
                gameObject.tag   = tilepool[currentTileIndex].tag;
                gameObject.layer = tilepool[currentTileIndex].layer;
                gameObject.GetComponent <SpriteRenderer>().sprite       = Resources.Load <Sprite>("interiortiles/" + tilepool[currentTileIndex].sprite);
                gameObject.GetComponent <SpriteRenderer>().sortingOrder = 1;
                if (gameObject.tag == "TallGrass")
                {
                    gameObject.AddComponent <TallGrass>();
                }
                if (tilepool[currentTileIndex].isAnimated)
                {
                    gameObject.AddComponent <AnimatedTile>();
                    gameObject.GetComponent <AnimatedTile>().tileanimsprites = Resources.LoadAll <Sprite>("interiortiles/" + tilepool[currentTileIndex].sprite);
                }
            }
SkipTallGrassRule:
            if (Input.GetMouseButton(0) && hit.collider == null && !placingWarp && currentmode == Mode.Edit)
            {
                GameObject gameObject = Instantiate(template, container.transform, true);
                gameObject.transform.position = snappos;
                gameObject.tag   = tilepool[currentTileIndex].tag;
                gameObject.layer = tilepool[currentTileIndex].layer;
                gameObject.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("interiortiles/" + tilepool[currentTileIndex].sprite);
                if (gameObject.tag == "TallGrass")
                {
                    gameObject.AddComponent <TallGrass>();
                }
                if (tilepool[currentTileIndex].isAnimated)
                {
                    gameObject.AddComponent <AnimatedTile>();

                    gameObject.GetComponent <AnimatedTile>().tileanimsprites = Resources.LoadAll <Sprite>("interiortiles/" + tilepool[currentTileIndex].sprite);
                }
            }
        }


        if (currenttile != null)
        {
            warpmarker.SetActive(currenttile.GetComponent <TileWarp>());
            editoriginalsprite.sprite = currenttile.GetComponent <SpriteRenderer>().sprite;
        }
        tallgrassoverlay.SetActive(!hasTallGrassComponent);
        propertyoverlay.SetActive(!hasPropertyComponent);
        warpoverlay.SetActive(!hasWarpComponent);
    }
Ejemplo n.º 27
0
 public int itemHeight(itemData item)
 {
     return(SwinGame.BitmapHeight(item.bmp));
 }