예제 #1
0
    /*
     * Read in a CSV Attack file generated from our Google Spreadsheet of attacks. Each
     * line will be an Attack, stored as a comma delimited value for each field in our Attack class.
     * Once complete, write the name of each attack in a lookup file of strings.
     */
    void ImportAttacks()
    {
        attackManager = (AttackManager)GameObject.Find(ObjectNames.MAANAGERS).GetComponent <AttackManager> ();
        if (attackManager == null)
        {
            Debug.LogError("Attack Manager could not be found");
            return;
        }
        TextAsset attackCsv = (TextAsset)Resources.Load(ATTACK_CSV, typeof(TextAsset));

        if (attackCsv == null)
        {
            Debug.LogError(string.Format("Attack file {0} failed to load correctly.", ATTACK_CSV));
            return;
        }
        attackManager.ClearAttacks();
        string[] lineArray = attackCsv.text.Split("\n" [0]);
        VerifyHeaderLine(lineArray [0]);
        for (int i = 1; i < lineArray.Length; i++)
        {
            Attack newAttack = SerializeAttackLine(lineArray [i]);
            attackManager.AddAttack(newAttack);
        }
        WriteAttacksToStringFile();
    }
예제 #2
0
 /*
  * Read in a CSV Attack file generated from our Google Spreadsheet of attacks. Each
  * line will be an Attack, stored as a comma delimited value for each field in our Attack class.
  * Once complete, write the name of each attack in a lookup file of strings.
  */
 void ImportAttacks()
 {
     attackManager = (AttackManager)GameObject.Find (ObjectNames.MAANAGERS).GetComponent <AttackManager> ();
     if (attackManager == null) {
         Debug.LogError ("Attack Manager could not be found");
         return;
     }
     TextAsset attackCsv = (TextAsset)Resources.Load (ATTACK_CSV, typeof(TextAsset));
     if (attackCsv == null) {
         Debug.LogError (string.Format ("Attack file {0} failed to load correctly.", ATTACK_CSV));
         return;
     }
     attackManager.ClearAttacks ();
     string[] lineArray = attackCsv.text.Split ("\n" [0]);
     VerifyHeaderLine (lineArray [0]);
     for (int i = 1; i < lineArray.Length; i++) {
         Attack newAttack = SerializeAttackLine (lineArray [i]);
         attackManager.AddAttack (newAttack);
     }
     WriteAttacksToStringFile ();
 }