use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.
the class AI_Manager method resetGroups.
private void resetGroups() {
// }
if (groups == null)
groups = new ArrayList<>();
for (Object sub : game.getBattleMaster().getPlayerManager().getPlayers()) {
DC_Player player = (DC_Player) sub;
for (Unit unit : player.getControlledUnits_()) {
GroupAI group = unit.getAI().getGroup();
if (group == null)
group = new GroupAI(unit);
for (Unit unit1 : player.getControlledUnits_()) {
if (unit1.getAI().getGroup() != null)
continue;
if (unit1.equals(unit))
continue;
double max_distance = 2.5;
if (PositionMaster.getExactDistance(unit1.getCoordinates(), unit.getCoordinates()) >= max_distance)
continue;
if (!game.getVisionMaster().getSightMaster().getClearShotCondition().check(unit, unit1))
continue;
group.add(unit1);
}
if (!groups.contains(group))
groups.add(group);
}
}
if (!groups.isEmpty())
return;
else
return;
}
use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.
the class Spawner method spawn.
@Refactor
public void spawn() {
// initFacing(units, player, mode);
for (Object player1 : getBattleMaster().getPlayerManager().getPlayers()) {
DC_Player player = (DC_Player) player1;
if (player.isNeutral()) {
continue;
}
UnitData data = player.getUnitData();
if (data == null)
data = generateData("", player, null);
spawn(data, player, getSpawnMode(player, true));
}
spawnDone();
// initEmblem
}
use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.
the class Spawner method spawnCustomParty.
public void spawnCustomParty(boolean me, String partyData) {
DC_Player player = game.getPlayer(me);
if (BooleanMaster.isTrue(me)) {
Party party = PartyHelper.getParty();
if (party != null) {
DC_SoundMaster.playEffectSound(SOUNDS.READY, party.getLeader());
spawnPlayerParty(party, partyData);
return;
}
}
if (!partyData.contains(DC_ObjInitializer.COORDINATES_OBJ_SEPARATOR)) {
partyData = DC_ObjInitializer.convertVarStringToObjCoordinates(partyData);
}
UnitData data = generateData(partyData, player, null);
spawn(data, player, SPAWN_MODE.PARTY);
// List<MicroObj> list = DC_ObjInitializer.processUnitDataString(player, partyData, game);
// if (!ListMaster.isNotEmpty(list)) {
// return;
// }
}
use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.
the class CombatScriptExecutor method doSpawn.
private boolean doSpawn(Ref ref, String[] args) {
int i = 0;
DC_Player player = getPlayerManager().getPlayer(args[i]);
if (player == null)
player = getPlayerManager().getPlayer(false);
else
i++;
List<String> units = new ArrayList<>();
// if (args[i].contains(ScriptSyntax.SPAWN_ARG_UNITS_WAVE))
String unitString = args[i];
int level = StringMaster.getInteger(VariableManager.getVars(unitString));
unitString = VariableManager.removeVarPart(unitString);
ObjType wave = DataManager.getType(unitString, DC_TYPE.ENCOUNTERS);
if (wave != null) {
for (String sub : StringMaster.open(wave.getProperty(PROPS.PRESET_GROUP))) {
if (level > 0)
units.add(UnitLevelManager.getLeveledTypeName(level, sub));
else
units.add(sub);
}
}
// TODO adjust wave? difficulty => level
boolean group = false;
if (units.isEmpty()) {
units.addAll(StringMaster.openContainer(UnitGroupMaster.getUnitGroupData(unitString, level)));
}
if (units.isEmpty()) {
// DataManager.gettypes
units.addAll(StringMaster.openContainer(unitString));
} else
group = true;
if (units.isEmpty())
return false;
i++;
// CoordinatesFactory.createCoordinates(unitString);
// if (origin==null )
// origin = ref.getObj(unitString).getCoordinates();
List<Coordinates> coordinates = null;
if (group) {
for (String sub : units) {
coordinates.add(DC_ObjInitializer.getCoordinatesFromObjString(sub));
}
} else
coordinates = getCoordinatesListForUnits(unitString, player, units, ref);
String data = "";
data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.COORDINATES, StringMaster.joinList(coordinates, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.MEMBERS, StringMaster.joinStringList(units, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
UnitData unitData = new UnitData(data);
SPAWN_MODE mode = SPAWN_MODE.SCRIPT;
List<Unit> unitsList = getSpawner().spawn(unitData, player, mode);
getSpawner().getFacingAdjuster().adjustFacing(unitsList);
return true;
}
use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.
the class Loader method createObjects.
private static List<Obj> createObjects(List<String> objectNodes) {
DC_Game game = DC_Game.game;
List<Obj> objects = new ArrayList<>();
// TODO ID ORDER MUST BE PRESERVED! put in parameter?
for (String typesNode : objectNodes) {
Document node = XML_Converter.getDoc(typesNode);
DC_TYPE TYPE = DC_TYPE.getType(node.getNodeName());
for (Node subNode : XML_Converter.getNodeList(node)) {
String sub = XML_Converter.getStringFromXML(subNode);
game.setIdManager(new DC_IdManager(game));
Map<PROPERTY, String> props = getPropsFromNode(sub);
Map<PARAMETER, String> params = getParamsFromNode(sub);
ObjType type = DataManager.getType(subNode.getNodeName(), TYPE);
// preset ID?! init containers by id... including buffs; but first create them
Ref ref = new Ref(game);
Node refNode = XML_Converter.findNode(sub, Saver.OBJ_NODE);
if (refNode != null)
for (String substring : StringMaster.open(refNode.getTextContent())) {
ref.setValue(KEYS.valueOf(substring.split("=")[0].toUpperCase()), substring.split("=")[1]);
}
String ownerName = null;
DC_Player owner = game.getBattleMaster().getPlayerManager().getPlayer(// property?
ownerName);
if (owner == null) {
owner = DC_Player.NEUTRAL;
}
Coordinates c = new Coordinates(params.get(G_PARAMS.POS_X) + "-" + params.get(G_PARAMS.POS_Y));
Obj object = createObj(type, c.x, c.y, owner, game, ref);
object.getPropMap().putAll(props);
object.getParamMap().putAll(params);
object.setId(StringMaster.getInteger(props.get(G_PROPS.ID)));
objects.add(object);
init(object);
}
}
return objects;
}
Aggregations