예제 #1
0
 //Sorry for the massive constructor but all the vals are readonly so...
 public EnemyStats(string name, string chat, string sprite, int hp, int shield, int stag, float atk, float def, float speed, float acc, int evade, float[] vsElem, EnemySpellList sp, string ai_type, string[] ai_params)
     : base(name, chat, hp, shield, stag, atk, def, speed, acc, evade, vsElem)
 {
     sprite_path    = sprite;
     this.ai_type   = ai_type;
     this.ai_params = ai_params;
     spells         = sp;
 }
예제 #2
0
 public override SpellData getNextSpell(EnemySpellList spells, Enemy[] allies, int position, ICaster[] player_arr, out int target)
 {
     target = 1;
     if (state == AI_State.NORMAL)
     {
         return(getSpellRandom(spells.getSpells()));
     }
     else if (state == AI_State.CHARGE_MAX)
     {
         return(spells.getSpells("TOO_LONG")[0]);
     }
     else if (state == AI_State.ATTACK_SPECIAL)
     {
         return(spells.getSpells()[0]);
     }
     else
     {
         throw new AiStateException("invalid AI state in Doppelganger AI");
     }
 }
예제 #3
0
 public override SpellData getNextSpell(EnemySpellList spells, Enemy[] allies, int position, ICaster[] player_arr, out int target)
 {
     target = 1;
     if (state == AI_State.NORMAL)
     {
         return(nrmlAtk.getNextSpell(spells, allies, position, player_arr, out target));
     }
     else if (state == AI_State.HEALTH_LOW)
     {
         return(getSpellSequential(spells.getSpells("HEALTH_LOW"), ref currentSpell));
     }
     else if (state == AI_State.HEALTH_CRITICAL)
     {
         if (spells.hasGroup("HEALTH_CRITICAL"))
         {
             return(getSpellSequential(spells.getSpells("HEALTH_CRITICAL"), ref currentSpell));
         }
         return(getSpellSequential(spells.getSpells("HEALTH_LOW"), ref currentSpell));
     }
     else
     {
         throw new SpellGroupException("Invalid group");
     }
 }
예제 #4
0
    //Builds database from text file specified by text_file
    public void build()
    {
        text_file = Resources.Load <TextAsset>(file_name);
        string[] lines = text_file.text.Split(line_delim);
        string[] cols;
        //Declare fields
        string name, sprite_path, chat_id, ai_type;
        int    max_hp, max_shield, max_stagger, evade;//declare stat variables
        float  speed, acc, atk, def;

        float[] vsElem;
        //For each line in input file
        for (int i = 1; lines[i].Trim().CompareTo("END") != 0; i++)
        {
            //FIELDS//

            cols = lines[i].Split(col_delim);
            int ind = 0;//Allows new stats to be added without changing the constants
            name        = cols[ind].Trim();
            sprite_path = cols[++ind].Trim();
            chat_id     = cols[++ind].Trim().ToLower();
            int.TryParse(cols[++ind].Trim(), out max_hp);
            int.TryParse(cols[++ind].Trim(), out max_shield);
            int.TryParse(cols[++ind].Trim(), out max_stagger);
            float.TryParse(cols[++ind].Trim(), out atk);
            float.TryParse(cols[++ind].Trim(), out def);
            float.TryParse(cols[++ind].Trim(), out speed);
            float.TryParse(cols[++ind].Trim(), out acc);
            int.TryParse(cols[++ind].Trim(), out evade);
            ai_type = cols[++ind].Trim();
            string[] ai_params = null;
            if (cols[++ind].Trim() != "none")
            {
                ai_params = cols[ind].Trim('"').Split(',');
            }

            //ELEMENTS//

            vsElem = new float[Elements.count];
            //Read in elemental weakness/resistances
            for (int j = ++ind; j < ind + Elements.count; j++)
            {
                float.TryParse(cols[j].Trim(), out vsElem[j - ind]);
            }

            //SPELLS//

            //Read in Spell List
            Dictionary <string, SpellData[]> spellGroups = new Dictionary <string, SpellData[]>();
            List <SpellData> spells = null;
            string           key    = "";
            for (int j = ind + Elements.count; ; j++)
            {
                if (cols[j].Trim().CompareTo("END") == 0)
                {
                    if (spells != null)
                    {
                        spellGroups.Add(key, spells.ToArray());
                    }
                    break;
                }
                if (cols[j].Trim().Contains("GROUP"))
                {
                    if (spells != null)
                    {
                        spellGroups.Add(key, spells.ToArray());
                    }
                    key    = cols[j].Trim().Substring(6);
                    spells = new List <SpellData>();
                    j++;
                }
                string root = cols[j].Trim();
                j++;
                string elem = cols[j].Trim();
                if (elem.CompareTo("null") == 0)
                {
                    elem = null;
                }
                j++;
                string style = cols[j].Trim();
                if (style.CompareTo("null") == 0)
                {
                    style = null;
                }
                SpellData s = new SpellData(root, elem, style);
                spells.Add(s);
            }
            EnemySpellList spellList = new EnemySpellList(spellGroups);
            EnemyStats     stats     = new EnemyStats(name, chat_id, sprite_path, max_hp, max_shield, max_stagger, atk, def, speed, acc, evade, vsElem, spellList, ai_type, ai_params);
            database.Add(stats.name, stats);
        }
        Debug.Log("Enemy Database Loaded");
        is_loaded = true;
    }
예제 #5
0
 //Returns the next spell for the enemy to cast and sets the target in out int target
 public abstract SpellData getNextSpell(EnemySpellList spells, Enemy[] allies, int position, ICaster[] player_arr, out int target);
예제 #6
0
 public override SpellData getNextSpell(EnemySpellList spells, Enemy[] allies, int position, ICaster[] player_arr, out int target)
 {
     return(baseAI.getNextSpell(spells, allies, position, player_arr, out target));
 }
예제 #7
0
 public override SpellData getNextSpell(EnemySpellList spells, Enemy[] allies, int position, ICaster[] player_arr, out int target)
 {
     target = 1;
     return(getSpellSequential(spells.getSpells("DEFAULT"), ref currentSpell));
 }