private int LookupCost(ElementMod e)
        {
            switch (e)
            {
            case ElementMod.Weak:
                if (weakApplied)
                {
                    return(-1);
                }
                else
                {
                    weakApplied = true;
                    return(-2);
                }

            case ElementMod.None:
                return(0);

            case ElementMod.Resist:
                return(2);

            case ElementMod.Immune:
                return(3);

            case ElementMod.Absorb:
                return(4);

            default:
                return(0);
            }
        }
Пример #2
0
    //Casts spell from NPC (enemy or ally)
    public List <CastData> cast(SpellData spell, ICaster[] targets, int selected, ICaster[] allies, int position, out List <Transform> noTargetPositions)
    {
        noTargetPositions = new List <Transform>();
        ICaster caster = allies[position];
        Spell   s      = spells[spell.root];
        Spell   c      = createSpellFromType(s.type);

        s.copyInto(c);
        int wordCount = 1;

        string[]   animData = { null, s.animationID, null };
        string[]   sfxData  = { null, s.sfxID, null };
        ElementMod e        = null;
        StyleMod   st       = null;

        if (spell.element != null)
        {
            e           = elements[spell.element];
            sfxData[2]  = e.sfxID;
            animData[2] = e.animationID;
            ++wordCount;
        }
        if (spell.style != null)
        {
            st          = styles[spell.style];
            sfxData[0]  = st.sfxID;
            animData[0] = st.animationID;
            ++wordCount;
        }
        c.Modify(e, st);
        List <ICaster>  toCastAt = c.target(targets, selected, allies, position);
        List <CastData> data     = new List <CastData>();

        foreach (ICaster target in toCastAt)
        {
            if (target == null)
            {
                continue;
            }
            if (target.Is_dead)
            {
                noTargetPositions.Add(target.Transform);
                continue;
            }
            CastData castData = c.cast(target, caster);
            animData.CopyTo(castData.animData, 0);
            sfxData.CopyTo(castData.sfxData, 0);
            castData.wordCount = wordCount;
            if (castData.repel == true)
            {
                castData.setLocationData(caster, target);
            }
            else
            {
                castData.setLocationData(target, caster);
            }
            data.Add(castData);
        }
        return(data);
    }
        private void selectedIndexChanged(object sender, EventArgs e)
        {
            fireMod      = LookupMod(fireBox.SelectedIndex);
            iceMod       = LookupMod(iceBox.SelectedIndex);
            lightningMod = LookupMod(lightningBox.SelectedIndex);
            waterMod     = LookupMod(waterBox.SelectedIndex);
            holyMod      = LookupMod(holyBox.SelectedIndex);
            shadowMod    = LookupMod(shadowBox.SelectedIndex);
            slots        = 0;
            weakApplied  = false;
            slots       += LookupCost(fireMod);
            slots       += LookupCost(iceMod);
            slots       += LookupCost(lightningMod);
            slots       += LookupCost(waterMod);
            slots       += LookupCost(holyMod);
            slots       += LookupCost(shadowMod);

            slotCost.Text = slots.ToString();
        }
Пример #4
0
 //Apllies prefix and suffix to spell. both arguments can be null (if no prefix or suffix)
 public void Modify(ElementMod e, StyleMod s)
 {
     //Dont modify if unmodifyable
     if (modFlag == ModFlags.NO_MODIFICATION)
     {
         return;
     }
     //Add rest of stuff
     if (e != null && modFlag != ModFlags.NO_ELEMENT)//Add element modifier
     {
         element = e.element;
         name    = e.name + "-" + name;
     }
     if (s != null && modFlag != ModFlags.NO_STYLE)//Add style modifier
     {
         //Modify targeting data if allowed and necessary
         if (s.isTarget == true)
         {
             if (modFlag == ModFlags.NO_TARGETING)
             {
                 return;
             }
             s.targets.modify(targetData);
         }
         //Apply power mod
         power  = Mathf.CeilToInt(power * s.powerModM);
         power += s.powerMod;
         //Apply acc mod
         hitPercentage  = Mathf.CeilToInt(hitPercentage * s.accModM);
         hitPercentage += s.accMod;
         //Appl crit mod
         critPercentage  = Mathf.CeilToInt(critPercentage * s.critModM);
         critPercentage += s.critMod;
         //Apply status % mod
         elementEffectMod  = Mathf.CeilToInt(elementEffectMod * s.statusEffectChanceModM);
         elementEffectMod += s.statusEffectChanceMod;
         name             += ("-" + s.name);
     }
 }
        private int LookupIndex(ElementMod mod)
        {
            switch (mod)
            {
            case ElementMod.Weak:
                return(0);

            case ElementMod.None:
                return(1);

            case ElementMod.Resist:
                return(2);

            case ElementMod.Immune:
                return(3);

            case ElementMod.Absorb:
                return(4);

            default:
                return(1);
            }
        }
        private void selectedIndexChanged(object sender, EventArgs e)
        {
            fireMod = LookupMod(fireBox.SelectedIndex);
            iceMod = LookupMod(iceBox.SelectedIndex);
            lightningMod = LookupMod(lightningBox.SelectedIndex);
            waterMod = LookupMod(waterBox.SelectedIndex);
            holyMod = LookupMod(holyBox.SelectedIndex);
            shadowMod = LookupMod(shadowBox.SelectedIndex);
            slots = 0;
            weakApplied = false;
            slots += LookupCost(fireMod);
            slots += LookupCost(iceMod);
            slots += LookupCost(lightningMod);
            slots += LookupCost(waterMod);
            slots += LookupCost(holyMod);
            slots += LookupCost(shadowMod);

            slotCost.Text = slots.ToString();
        }
 private int LookupIndex(ElementMod mod)
 {
     switch (mod)
     {
         case ElementMod.Weak:
             return 0;
         case ElementMod.None:
             return 1;
         case ElementMod.Resist:
             return 2;
         case ElementMod.Immune:
             return 3;
         case ElementMod.Absorb:
             return 4;
         default:
             return 1;
     }
 }
        private int LookupCost(ElementMod e)
        {
            switch (e)
            {
                case ElementMod.Weak:
                    if (weakApplied)
                    {
                        return -1;
                    }
                    else
                    {
                        weakApplied = true;
                        return -2;
                    }

                case ElementMod.None:
                    return 0;

                case ElementMod.Resist:
                    return 2;

                case ElementMod.Immune:
                    return 3;

                case ElementMod.Absorb:
                    return 4;

                default:
                    return 0;
            }
        }
Пример #9
0
    // parses Dictionary file which should be a tab-delimited txt file (from excel)
    public void buildDicts()
    {
        text_file = Resources.Load <TextAsset>(file_name);
        string[] lines = text_file.text.Split(line_delim);
        string[] cols;
        int      i = 1;

        //read in root keywords
        while (true)
        {
            cols = lines[i].Split(col_delim);
            int    ind = 0;
            string key = cols[ind].Trim();
            if (key.CompareTo("END") == 0) //At end of root keywords
            {
                i += 2;                    //Skip example line
                break;
            }
            string type = cols[++ind].Trim();
            Spell  s    = createSpellFromType(type);
            s.name        = key;
            s.type        = type;
            s.description = cols[++ind].Trim().Replace("\"", string.Empty);
            s.animationID = cols[++ind].Trim();
            s.sfxID       = cols[++ind].Trim();
            int.TryParse(cols[++ind].Trim(), out s.power);
            float.TryParse(cols[++ind].Trim(), out s.cooldown);
            int.TryParse(cols[++ind].Trim(), out s.hitPercentage);
            int.TryParse(cols[++ind].Trim(), out s.critPercentage);
            int.TryParse(cols[++ind].Trim(), out s.elementEffectMod);
            string pattern = cols[++ind].Trim();
            if (pattern.Contains("A"))
            {
                s.targetData            = new TargetData(true);
                s.targetData.selfCenter = false;
                s.targetData.targeted   = false;
            }
            else
            {
                s.targetData = new TargetData(false);
                if (pattern.Contains("L"))
                {
                    s.targetData.enemyL = true;
                }
                if (pattern.Contains("M"))
                {
                    s.targetData.enemyM = true;
                }
                if (pattern.Contains("R"))
                {
                    s.targetData.enemyR = true;
                }
                if (pattern.Contains("l"))
                {
                    s.targetData.allyL = true;
                }
                if (pattern.Contains("m"))
                {
                    s.targetData.allyM = true;
                }
                if (pattern.Contains("r"))
                {
                    s.targetData.allyR = true;
                }
                if (pattern.Contains("S"))
                {
                    s.targetData.selfCenter = true;
                }
                if (pattern.Contains("T"))
                {
                    s.targetData.targeted = true;
                }
            }
            string buff = cols[++ind].Trim();
            if (!buff.Contains("N"))
            {
                s.buff = new BuffData();
                int level;
                if (type == "buff")
                {
                    level = s.power;
                }
                else
                {
                    level = 1;
                }
                if (buff.Contains("A"))
                {
                    s.buff.attackMod = -1 * level;
                }
                else if (buff.Contains("a"))
                {
                    s.buff.attackMod = level;
                }
                if (buff.Contains("D"))
                {
                    s.buff.defenseMod = -1 * level;
                }
                else if (buff.Contains("d"))
                {
                    s.buff.defenseMod = level;
                }
                if (buff.Contains("S"))
                {
                    s.buff.speedMod = -1 * level;
                }
                else if (buff.Contains("s"))
                {
                    s.buff.speedMod = level;
                }
                if (buff.Contains("H"))
                {
                    s.buff.accuracyMod = -1 * level;
                }
                else if (buff.Contains("h"))
                {
                    s.buff.accuracyMod = level;
                }
                if (buff.Contains("E"))
                {
                    s.buff.evasionMod = -1 * level;
                }
                else if (buff.Contains("e"))
                {
                    s.buff.evasionMod = level;
                }
                if (buff.Contains("U"))
                {
                    s.buff.vsElemMod[Elements.@null] = -1 * level;
                }
                else if (buff.Contains("u"))
                {
                    s.buff.vsElemMod[Elements.@null] = level;
                }
                if (buff.Contains("F"))
                {
                    s.buff.vsElemMod[Elements.fire] = -1 * level;
                }
                else if (buff.Contains("f"))
                {
                    s.buff.vsElemMod[Elements.fire] = level;
                }
                if (buff.Contains("I"))
                {
                    s.buff.vsElemMod[Elements.ice] = -1 * level;
                }
                else if (buff.Contains("i"))
                {
                    s.buff.vsElemMod[Elements.ice] = level;
                }
                if (buff.Contains("B"))
                {
                    s.buff.vsElemMod[Elements.volt] = -1 * level;
                }
                else if (buff.Contains("b"))
                {
                    s.buff.vsElemMod[Elements.volt] = level;
                }
            }
            int.TryParse(cols[++ind].Trim(), out s.buffPercentage);
            switch (cols[++ind].Trim().ToLower())
            {
            case "no_mods":
                s.modFlag = Spell.ModFlags.NO_MODIFICATION;
                break;

            case "no_elements":
                s.modFlag = Spell.ModFlags.NO_ELEMENT;
                break;

            case "no_styles":
                s.modFlag = Spell.ModFlags.NO_STYLE;
                break;

            case "no_targeting":
                s.modFlag = Spell.ModFlags.NO_TARGETING;
                break;

            default:
                s.modFlag = Spell.ModFlags.NORMAL;
                break;
            }
            spells.Add(key, s);
            i++;
        }
        //read in element keywords
        while (true)
        {
            cols = lines[i].Split(col_delim);
            int    ind = 0;
            string key = cols[ind].Trim();
            if (key.CompareTo("END") == 0)
            {
                i += 2;//Skip example line
                break;
            }
            ElementMod e = new ElementMod();
            e.name        = key;
            e.element     = Elements.fromString(cols[++ind].Trim());
            e.description = cols[++ind].Trim().Replace("\"", string.Empty);
            e.animationID = cols[++ind].Trim();
            e.sfxID       = cols[++ind].Trim();
            float.TryParse(cols[++ind].Trim(), out e.cooldownMod);
            float.TryParse(cols[++ind].Trim(), out e.cooldownModM);
            elements.Add(key, e);
            i++;
        }
        //Read in casting style keywords
        while (true)
        {
            cols = lines[i].Split(col_delim);
            int    ind = 0;
            string key = cols[ind].Trim();
            if (key.CompareTo("END") == 0)
            {
                return;
            }
            StyleMod s = new StyleMod();
            s.name = key;
            int.TryParse(cols[++ind].Trim(), out s.powerMod);
            s.description = cols[++ind].Trim().Replace("\"", string.Empty);
            s.animationID = cols[++ind].Trim();
            s.sfxID       = cols[++ind].Trim();
            float.TryParse(cols[++ind].Trim(), out s.powerModM);
            float.TryParse(cols[++ind].Trim(), out s.cooldownMod);
            float.TryParse(cols[++ind].Trim(), out s.cooldownModM);
            int.TryParse(cols[++ind].Trim(), out s.accMod);
            float.TryParse(cols[++ind].Trim(), out s.accModM);
            int.TryParse(cols[++ind].Trim(), out s.critMod);
            float.TryParse(cols[++ind].Trim(), out s.critModM);
            int.TryParse(cols[++ind].Trim(), out s.statusEffectChanceMod);
            float.TryParse(cols[++ind].Trim(), out s.statusEffectChanceModM);
            string[] pattern = cols[++ind].Trim().Split(',');
            if (pattern[0].Contains("N"))
            {
                s.isTarget = false;
            }
            else
            {
                s.targets = TargetMod.createFromString(pattern[0].Trim('"'), pattern);
            }
            styles.Add(key, s);
            i++;
        }
    }