/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package multididdy_model;
import java.io.File;
import java.util.ArrayList;
import multididdy_debug.Debug;
import multididdy_tools.ConfigReader;
/**
*
* @author chris
*/
class ResourceLoader {
ArrayList<Weapon> weapons;
ArrayList<Item> items;
ArrayList<Character> models;
ArrayList<Map> maps;
public ResourceLoader(String pathToWeapons, String pathToItems, String pathToCharacters, String pathToMaps) {
weapons = new ArrayList();
items= new ArrayList();
models= new ArrayList();
maps= new ArrayList();
loadWeapons(pathToWeapons);
loadItems(pathToItems);
}
private void loadWeapons(String pathToWeapons) {
File dir = new File(pathToWeapons);
String[] children = dir.list();
for (int i = 0; i < children.length; ++i) {
Debug.p(children[i], 5);
ConfigReader conf = new ConfigReader(pathToWeapons + "/" + children[i] + "/weapon.ini");
Weapon newW = new Weapon();
newW.directory = pathToWeapons + "/" + children[i];
//könnte man noch die bilder für die animationen reinladen
newW.name = conf.getString("name");
newW.type = WeaponTypes.valueOf(conf.getString("type"));
newW.power = conf.getInt("power");
newW.speed = conf.getInt("speed");
newW.range = conf.getInt("range");
newW.defaultAmmo = conf.getInt("defaultAmmo");
newW.costMana = conf.getInt("costMana");
newW.costStamina = conf.getInt("costStamina");
newW.explosion = conf.getBool("explosion");
newW.explosionRange = conf.getInt("explosionRange");
newW.animationFrames = conf.getValues("animationFrames");
newW.explosionFrames = conf.getValues("explosionFrames");
newW.shootingFrames = conf.getValues("shootingFrames");
weapons.add(newW);
}
}
private void loadItems(String pathToItems) {
File dir = new File(pathToItems);
String[] children = dir.list();
for (int i = 0; i < children.length; ++i) {
Debug.p(children[i], 5);
ConfigReader conf = new ConfigReader(pathToItems + "/" + children[i] + "/item.ini");
Item newI = new Item();
newI.directory = pathToItems + "/" + children[i];
//könnte man noch die bilder für die animationen reinladen
newI.name = conf.getString("name");
newI.type = ItemTypes.valueOf(conf.getString("type"));
newI.pAttribute = PlayerAttributes.valueOf(conf.getString("pAttribute"));
newI.wAttribute = WeaponAttribute.valueOf(conf.getString("wAttribute"));
newI.value = conf.getInt("value");
newI.spawnTime = conf.getInt("spawnTime");
items.add(newI);
}
}
}