@Override public void init() { super.init(); }
public Unit(Unit unit) { this.id = unit.id; this.index = unit.index; this.unitType = unit.unitType; this.maxHp = unit.maxHp; this.hp = unit.hp; this.maxMp = unit.maxMp; this.mp = unit.mp; this.str = unit.str; this.mag = unit.mag; this.dex = unit.dex; this.spd = unit.spd; this.atk = unit.atk; this.hitRate = unit.hitRate; this.evasion = unit.evasion; this.critRate = unit.critRate; this.def = unit.def; this.mdef = unit.mdef; this.ct = unit.ct; this.status = new int[Game.NUMSTATUSES]; for (int i = 0; i < this.status.length; i++) { if (i >= unit.status .length) // TODO: can remove this check once I know more statuses won't be added { this.status[i] = 0; } else this.status[i] = unit.status[i]; } this.elementResistance = new int[Game.NUMELEMENTS]; for (int i = 0; i < this.elementResistance.length; i++) { this.elementResistance[i] = unit.elementResistance[i]; } this.statusResistance = new int[Game.NUMSTATUSES]; for (int i = 0; i < this.statusResistance.length; i++) { if (i >= unit.statusResistance .length) // TODO: can remove this check once I know more statuses won't be added { this.statusResistance[i] = 0; } else this.statusResistance[i] = unit.statusResistance[i]; } this.imageHeight = unit.imageHeight; this.imageWidth = unit.imageWidth; this.spriteHeight = unit.spriteHeight; this.actionHistory = new ArrayList<Integer>(); if (unit.actionHistory != null) { for (int i = 0; i < unit.actionHistory.size(); i++) { this.actionHistory.add(unit.actionHistory.get(i)); } } // Character specific if (unit.unitType == Unit.CHARACTER) { this.name = unit.name; this.className = unit.className; this.level = unit.level; this.exp = unit.exp; this.cubes = unit.cubes; this.equip = new Item[5]; for (int i = 0; i < equip.length; i++) this.equip[i] = Item.itemFromID(unit.equip[i].id); this.activeSkills = new ArrayList<ActiveSkill>(); for (int i = 0; i < unit.activeSkills.size(); i++) { this.activeSkills.add( ActiveSkill.activeSkillFromID( unit.activeSkills.get(i).id, unit.activeSkills.get(i).currentSP, unit.activeSkills.get(i).learned)); } this.passiveSkills = new ArrayList<PassiveSkill>(); for (int i = 0; i < unit.passiveSkills.size(); i++) { this.passiveSkills.add( PassiveSkill.passiveSkillFromID( unit.passiveSkills.get(i).id, unit.passiveSkills.get(i).currentSP, unit.passiveSkills.get(i).learned, unit.passiveSkills.get(i).equipped)); } } // Monster specific if (unit.unitType == Unit.MONSTER) { this.species = unit.species; this.expGain = unit.expGain; this.spGain = unit.spGain; this.moneyGain = unit.moneyGain; this.itemDrops = unit.itemDrops; this.itemRates = unit.itemRates; this.stealItems = unit.stealItems; this.stealItemRates = unit.stealItemRates; this.attackAnimation = unit.attackAnimation; this.preventFlee = unit.preventFlee; this.type = unit.type; } }