예제 #1
0
    public AuricaSpell GetSpellMatchFromString(string componentString)
    {
        string[] componentSeperator            = new string[] { ", " };
        string[] splitComponents               = componentString.Split(componentSeperator, System.StringSplitOptions.None);
        List <AuricaSpellComponent> components = new List <AuricaSpellComponent>();

        foreach (string componentName in splitComponents)
        {
            foreach (AuricaSpellComponent c in allComponents)
            {
                if (c.c_name == componentName)
                {
                    components.Add(c);
                    break;
                }
            }
        }
        AuricaSpell spellMatch = null;
        int         bestMatchCorrectComponents = 0;

        foreach (AuricaSpell s in allSpells)
        {
            if (s.CheckComponents(components) && s.GetNumberOfMatchingComponents(components) > bestMatchCorrectComponents)
            {
                spellMatch = s;
                bestMatchCorrectComponents = s.GetNumberOfMatchingComponents(components);
            }
        }

        return(spellMatch);
    }
예제 #2
0
    public void CacheCurrentSpell(string key)
    {
        string componentString = "";

        foreach (AuricaSpellComponent c in currentComponents)
        {
            componentString += c.c_name + ", ";
        }
        componentString = componentString.Substring(0, componentString.Length - 2);
        Debug.Log("Caching spell: " + componentString);

        if (cachedSpells.ContainsKey(key))
        {
            cachedSpells[key] = new CachedSpell(componentString);
        }
        else
        {
            cachedSpells.Add(key, new CachedSpell(componentString));
        }
        PlayerPrefs.SetString("CachedSpell_" + key, componentString);
        Debug.Log("Spell cached under key: CachedSpell_" + key + " with string -> " + componentString);
        AuricaSpell match = Cast();

        try {
            BindingUIPanel.LocalInstance.SetBind(key, match);
        } catch {
            Debug.Log("No spell found for binding...");
            BindingUIPanel.LocalInstance.SetBind(key, null);
        }
    }
예제 #3
0
    public void PopulateFromSpell(AuricaSpell s)
    {
        spell            = s;
        title.text       = spell.c_name;
        description.text = spell.description;
        targetDistDisplay.SetDistribution(spell.targetDistribution);
        targetDistDisplayValues.SetDistribution(spell.targetDistribution);
        // Debug.Log("IDEAL AURA:    "+spell.IdealAuraCalculation().ToString());
        if (!isCasterAgnostic)
        {
            spellEfficacyText.text = string.Format("{0:N2}", AuricaCaster.LocalCaster.GetSpellStrength() * 100f) + "%";
            manaCostText.text      = string.Format("{0:N2}", AuricaCaster.LocalCaster.GetManaCost());
        }
        if (componentUIList != null)
        {
            componentUIList.ResetList();
            foreach (var component in spell.keyComponents)
            {
                componentUIList.AddComponent(component);
            }
        }

        if (gameObject.activeInHierarchy)
        {
            StartCoroutine(SetTargetDist(spell.targetDistribution));
        }
    }
예제 #4
0
 public void CheckComponents()
 {
     spell = AuricaCaster.LocalCaster.Cast();
     try {
         if (spell.c_name != null)
         {
             if (isHidden)
             {
                 ShowSpell();
             }
             PopulateFromSpell(spell);
         }
     } catch {
         // do nothing, no spell match
     }
 }
예제 #5
0
    public void CacheSpell(string key, string spell)
    {
        Debug.Log("Caching spell: " + spell);
        if (cachedSpells.ContainsKey(key))
        {
            cachedSpells[key] = new CachedSpell(spell);
        }
        else
        {
            cachedSpells.Add(key, new CachedSpell(spell));
        }
        PlayerPrefs.SetString("CachedSpell_" + key, spell);
        AuricaSpell match = CastSpellByName(spell);

        try {
            BindingUIPanel.LocalInstance.SetBind(key, match);
        } catch {
            Debug.Log("No spell found for binding...");
            BindingUIPanel.LocalInstance.SetBind(key, null);
        }
    }
예제 #6
0
    public AuricaSpell GetSpellMatch(List <AuricaSpellComponent> components, ManaDistribution distribution)
    {
        int         bestMatchCorrectComponents = 0;
        AuricaSpell spellMatch = null;

        foreach (AuricaSpell s in allSpells)
        {
            // Debug.Log("Check Spell: " + s.c_name + "   IsMatch: " + s.CheckComponents(components) + "     Error:  " + s.GetError(distribution)+"  Num matching components: "+s.GetNumberOfMatchingComponents(components));
            if (s.CheckComponents(components) && s.GetNumberOfMatchingComponents(components) > bestMatchCorrectComponents)
            {
                spellMatch = s;
                bestMatchCorrectComponents = s.GetNumberOfMatchingComponents(components);
                spellStrength = (spellMatch.errorThreshold - s.GetError(distribution)) / spellMatch.errorThreshold + 0.3f;
                if (spellStrength < 0.25f)
                {
                    spellStrength = 0.25f;
                }
            }
        }

        return(spellMatch);
    }
예제 #7
0
    public void AddComponent(AuricaSpellComponent component)
    {
        if (currentIndex >= maxComponents)
        {
            HideAllComponents();
        }
        ComponentPanels[currentIndex].gameObject.SetActive(true);
        ComponentPanels[currentIndex].SetComponent(component, allGlyphs);
        currentIndex += 1;

        spell = AuricaCaster.LocalCaster.Cast();
        if (spell != null && spell.c_name != null)
        {
            spellText.gameObject.SetActive(true);
            spellText.text = spell.c_name.ToUpper();

            foreach (SideBarComponent item in ComponentPanels)
            {
                item.ActivateComponent(spell);
            }
        }
    }
예제 #8
0
    public void Startup()
    {
        dict.Add("q", bindQ);
        dict.Add("e", bindE);
        dict.Add("r", bindR);
        dict.Add("1", bind1);
        dict.Add("2", bind2);
        dict.Add("3", bind3);

        if (PlayerPrefs.HasKey("CachedSpell_e"))
        {
            SetBind("e", AuricaCaster.LocalCaster.GetSpellMatchFromString(PlayerPrefs.GetString("CachedSpell_e")));
        }
        if (PlayerPrefs.HasKey("CachedSpell_q"))
        {
            SetBind("q", AuricaCaster.LocalCaster.GetSpellMatchFromString(PlayerPrefs.GetString("CachedSpell_q")));
        }
        if (PlayerPrefs.HasKey("CachedSpell_1"))
        {
            SetBind("1", AuricaCaster.LocalCaster.GetSpellMatchFromString(PlayerPrefs.GetString("CachedSpell_1")));
        }
        if (PlayerPrefs.HasKey("CachedSpell_2"))
        {
            SetBind("2", AuricaCaster.LocalCaster.GetSpellMatchFromString(PlayerPrefs.GetString("CachedSpell_2")));
        }
        if (PlayerPrefs.HasKey("CachedSpell_3"))
        {
            SetBind("3", AuricaCaster.LocalCaster.GetSpellMatchFromString(PlayerPrefs.GetString("CachedSpell_3")));
        }
        if (PlayerPrefs.HasKey("CachedSpell_r"))
        {
            string componentString = PlayerPrefs.GetString("CachedSpell_r");
            // Debug.Log("Try to find spell name for: "+componentString);
            AuricaSpell spell = AuricaCaster.LocalCaster.GetSpellMatchFromString(componentString);
            // Debug.Log("Found spell name: "+spell.c_name);
            SetBind("r", spell);
        }
    }
예제 #9
0
 public void SetSpell(AuricaSpell s)
 {
     spell = s;
     SetTitle(s.c_name);
 }
예제 #10
0
 public void SetBind(string key, AuricaSpell spell)
 {
     Debug.Log("Set graphics for key: " + key + " with spell: " + spell.c_name);
     dict[key].SetButtonGraphics(spell);
 }