Example #1
0
    IEnumerator PopulateWeaponFamilies(int w)                   //used to populate each weapon family
    {
        string weaponURL = generalURL + "/" + weaponTreeURL[w]; //get the correct URL for each weapon family

        WeaponFamily wf = new WeaponFamily(weaponName[w]);

        weapons.Add(wf);                                     //add family to compete list

        List <string> htmlWeaponClass = new List <string>(); //create a list of individual weapon classes base of HTML format

        using (WWW www = new WWW(weaponURL))
        {
            yield return(www);                                                                 //wait for page to load

            string   page      = www.text.ToString();                                          //turn page into readable text
            string[] substring = new String[] { "<tr>" };                                      //what to seperate weapons by
            string[] classes   = page.Split(substring, StringSplitOptions.RemoveEmptyEntries); //actually seperate out classes

            for (int i = 1; i < classes.Length; i++)                                           //starting at 1 as to skip over non-weapon info
            {
                if (classes[i].Contains(generalURL))
                {
                    htmlWeaponClass.Add(classes[i]);
                }
            }

            for (int j = 0; j < htmlWeaponClass.Count; j++)
            {
                CreateWeaponClass(htmlWeaponClass[j], w);
            }
        }
    }
Example #2
0
    void Branches(WeaponFamily wf)
    {
        wf.displayBranches = EditorGUILayout.Foldout(wf.displayBranches, "Show Branches");
        if (wf.displayBranches)
        {
            for (int j = 0; j < wf.branches.Count; j++)
            {
                EditorGUI.indentLevel++;
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(wf.weapons[wf.branches[j]].weaponName);

                wf.branches[j] = EditorGUILayout.IntField(wf.branches[j]);

                if (GUILayout.Button("+"))
                {
                    wf.branches.Insert(j, 0);
                }

                if (GUILayout.Button("-"))
                {
                    wf.branches.RemoveAt(j);
                }

                GUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }
        }
    }
Example #3
0
    void GetPrevious(Weapon weapon, WeaponFamily weaponFamily, string s)//gets the previous weapon index in the current family
    {
        int pageWeapons = 0;

        string[] lines = s.Split('\n');

        for (int t = 0; t < lines.Length; t++)
        {
            if (lines[t].Contains("https://mhworld.kiranico.com/weapon"))//count how many times this shows up
            {
                pageWeapons++;
                if (pageWeapons == weapon.tier)//when the numbers match its the previous weapon
                {
                    string[] itemName = lines[t].Split('>');

                    itemName = itemName[1].Split('<');
                    string previousWeaponname = itemName[0];

                    previousWeaponname = SpecialCharCheck(previousWeaponname);

                    for (int r = 0; r < weaponFamily.weapons.IndexOf(weapon); r++)
                    {
                        Weapon wea = weaponFamily.weapons[r];
                        if (wea.weaponName == previousWeaponname)
                        {
                            //print(wea.weaponName);
                            weapon.previous = r;
                        }
                    }
                }
            }
        }
    }
Example #4
0
 void CompileMats(Weapon w, WeaponFamily wf, ref List <string> s, ref List <int> n)
 {
     if (w.forge)
     {
         for (int i = 0; i < w.forgeItem.Count; i++)
         {
             if (s.Contains(w.forgeItem[i]))
             {
                 n[s.IndexOf(w.forgeItem[i])] += w.forgeNum[i];
             }
             else
             {
                 s.Add(w.forgeItem[i]);
                 n.Add(w.forgeNum[i]);
             }
         }
     }
     else
     {
         for (int i = 0; i < w.item.Count; i++)
         {
             if (s.Contains(w.item[i]))
             {
                 n[s.IndexOf(w.item[i])] += w.num[i];
             }
             else
             {
                 s.Add(w.item[i]);
                 n.Add(w.num[i]);
             }
         }
         CompileMats(wf.weapons[w.previous], wf, ref s, ref n);
     }
 }
Example #5
0
    void GetPreviousStart(Weapon weapon, WeaponFamily weaponFamily, string page)//split page in needed elements to get previous
    {
        string[] upgradePathText = new string[] { "upgrade" };
        string[] howToText       = new string[] { "How to" };
        string[] upgradePath     = page.Split(upgradePathText, StringSplitOptions.RemoveEmptyEntries);
        upgradePath = upgradePath[1].Split(howToText, StringSplitOptions.RemoveEmptyEntries);

        GetPrevious(weapon, weaponFamily, upgradePath[0]);
    }
Example #6
0
    void GetPrevious(Weapon w, WeaponFamily wf, ref List <Weapon> tree)
    {
        tree.Add(w);

        if (w.previous >= 0)
        {
            GetPrevious(wf.weapons[w.previous], wf, ref tree);
        }
    }
Example #7
0
    void CreateWeaponClass(string wclass, int familyIndex)//create the weapons
    {
        WeaponFamily wf = weapons[familyIndex];

        string[] lines    = wclass.Split('\n');//split the page into lines
        string   itemURL  = string.Empty;
        string   itemName = string.Empty;
        int      rarity   = 0;
        int      tier     = 0;
        bool     c        = false;

        for (int i = 0; i < lines.Length; i++)
        {
            if (lines[i].Contains("&#9495;"))//indicates a break symbol, if a line contains one it is further in the tier
            {
                tier++;
            }

            if (lines[i].Contains("a href"))//the line with the weapon URL and name in it
            {
                string[] weaponUrlName = lines[i].Split('>');
                itemURL  = GetWeaponURL(weaponUrlName);  //refer to function
                itemName = GetWeaponName(weaponUrlName); //refer to function
            }

            if (lines[i].Contains("RARE"))//line with rarity in it
            {
                rarity = int.Parse(new string(lines[i].Where(Char.IsDigit).ToArray()));
            }

            if (lines[i].Contains("creatable"))//if this shows up the weapon is creatable with out the previous entry in the tree
            {
                c = true;
            }
        }

        Weapon w = new Weapon(itemName, itemURL, tier, rarity, c);

        wf.weapons.Add(w);

        int wIndex       = wf.weapons.IndexOf(w);
        int previousTier = 0;

        if (wIndex > 0)
        {
            previousTier = wf.weapons[wIndex - 1].tier;
        }

        if (tier <= previousTier)
        {
            wf.branches.Add(wIndex);
        }
    }
Example #8
0
 IEnumerator StartGetWeaponDetails()         //used to get any missing and needed weapon data
 {
     for (int j = 0; j < weapons.Count; j++) //iterate through each weapon type
     {
         WeaponFamily wf = weapons[j];
         print("<color=red>Starting " + wf.familyName + "</color>");
         for (int k = 0; k < wf.weapons.Count; k++)//iteration through each weapon
         {
             Weapon w = wf.weapons[k];
             print("<color=blue>Starting " + w.weaponName + "</color>");
             yield return(StartCoroutine(GetWeaponDetails(w, wf)));
         }
     }
 }
Example #9
0
    IEnumerator GetWeaponDetails(Weapon weapon, WeaponFamily weaponFamily)//gets the missing weapon details
    {
        using (WWW w = new WWW(weapon.weaponURL))
        {
            yield return(w);

            string page = w.text.ToString();

            if (weapon.tier >= 1)//no need to look for previous is there isn't one
            {
                GetPreviousStart(weapon, weaponFamily, page);
            }

            GetMaterialsStart(weapon, page);//Used to get the different materials needed for the
        }
        print("<color=green>Got details for</color> <color=blue>" + weapon.weaponName + " </color>");
    }
Example #10
0
    void FamilyDisplay(int i, WeaponFamily wf)
    {
        wf.display = EditorGUILayout.Foldout(wf.display, wf.familyName); //fold out for family
        if (wf.display)                                                  //if foldout is open
        {
            EditorGUI.indentLevel++;
            Branches(wf);//call on branches display

            wf.displayWeapons = EditorGUILayout.Foldout(wf.displayWeapons, "Show Weapons");
            if (wf.displayWeapons)
            {
                EditorGUI.indentLevel++;
                for (int k = 0; k < wf.weapons.Count; k++)//for each weapon in the family
                {
                    Weapon w = wf.weapons[k];

                    w.display = EditorGUILayout.Foldout(w.display, w.weaponName);
                    if (w.display)
                    {
                        EditorGUI.indentLevel++;
                        if (w.forge)
                        {
                            MaterialsDisplay(ref w.forgeItem, ref w.forgeNum, "Crafting Items", ref w.displayForge);
                            GUILayout.Space(5);
                        }

                        if (w.item.Count > 0)
                        {
                            MaterialsDisplay(ref w.item, ref w.num, "Upgrade Items", ref w.displayUpgrade);
                            GUILayout.Space(5);
                        }
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUI.indentLevel--;
        }
    }
Example #11
0
    public void BuildWeaponTree(Weapon w, WeaponFamily wf)
    {
        treeText.text = "";
        matText.text  = "";
        List <Weapon> tree  = new List <Weapon>();
        List <string> items = new List <string>();
        List <int>    num   = new List <int>();

        GetPrevious(w, wf, ref tree);
        CompileMats(w, wf, ref items, ref num);

        for (int i = tree.Count - 1; i >= 0; i--)
        {
            //print(tree[i].weaponName);
            treeText.text += tree[i].weaponName + '\n';

            if (i != 0)
            {
                treeText.text += downArrow.ToString() + '\n';
            }
        }

        for (int i = items.Count - 1; i >= 0; i--)
        {
            int rem = i % 2;

            matText.text += items[i] + " x " + num[i];

            if (rem == 0)
            {
                matText.text += "     ";
            }
            else
            {
                matText.text += '\n';
            }
        }
    }
Example #12
0
    public override void OnInspectorGUI()
    {
        ITEM = (Items)target;

        showColor = EditorGUILayout.Foldout(showColor, "Rarity Colors");

        if (showColor)
        {
            EditorGUI.indentLevel++;
            for (int c = 0; c < ITEM.rarityColors.Length; c++)
            {
                GUILayout.BeginHorizontal();
                ITEM.rarityColors[c] = EditorGUILayout.ColorField("Rarity " + (c + 1), ITEM.rarityColors[c]);

                if (GUILayout.Button("-"))
                {
                    ArrayUtility.RemoveAt(ref ITEM.rarityColors, c);
                }
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add Color"))
            {
                ArrayUtility.Add(ref ITEM.rarityColors, Color.white);
            }
            EditorGUI.indentLevel--;
        }



        GUILayout.Space(10);
        for (int i = 0; i < ITEM.weapons.Count; i++)
        {
            WeaponFamily wf = ITEM.weapons[i];//create reference to specific family
            FamilyDisplay(i, wf);
        }
    }
Example #13
0
    public void BuildFamilyTree(int familyIndex)
    {
        CheckContentRectSize();

        displayFamily = items.weapons[familyIndex];

        int WeaponListCount = displayFamily.weapons.Count;

        contentHolder.sizeDelta = new Vector2(offset * 9, (displayFamily.branches.Count - 1) * offset);

        int treeCount = 1;

        for (int i = 0; i < WeaponListCount; i++)
        {
            Weapon w = displayFamily.weapons[i];
            if (i != 0)
            {
                if (treeCount < displayFamily.branches.Count)
                {
                    if (i == displayFamily.branches[treeCount])
                    {
                        treeCount++;
                        startPos.y -= offset;

                        if (w.tier == 0)
                        {
                            startPos.x = offset / 2;
                        }
                        else
                        {
                            startPos.x = displayFamily.weapons[w.previous].spot.x + offset;
                        }
                    }
                }
            }

            GameObject o = Instantiate(weaponButtonPrefab, contentHolder);
            o.name = w.weaponName;

            RectTransform rt = o.GetComponent <RectTransform>();
            rt.sizeDelta     = new Vector2(buttonSize, buttonSize);
            rt.localPosition = startPos;

            Button b = o.GetComponent <Button>();

            if (i > displayFamily.weaponImage.Length - 1)
            {
                b.image.sprite = missingImage;
            }
            else
            {
                b.image.sprite = displayFamily.weaponImage[i];
            }

            w.spot = startPos;
            b.onClick.AddListener(delegate { BuildWeaponTree(w, displayFamily); });

            Text t = o.transform.GetChild(0).GetComponent <Text>();
            t.text  = w.rarity.ToString();
            t.color = items.rarityColors[w.rarity - 1];
            buttons.Add(o);
            startPos.x += offset;
        }

        populatedBefore = true;
    }