void UnitFactory::produceAndRegisterUnit(const std::string& unitClass, int owner, const MPoint& pos) { UnitModel* unit; UnitViewController* view; unit = produceUnit(unitClass, owner, pos); view = new UnitViewController(unit, 64.0f, 64.0f, unit->getVisualType()); unit->addObserver(view); ModelManager::instance()->addUnit(unit); ViewControllerManager::instance()->add(view); }
void UnitFactory::produceAndRegisterMapObject(const std::string& objectType, int owner, const MPoint& pos) { MapObject* object; MapObjectView* view; std::vector<UnitModel*> units; std::vector<int> actions; int image = 0; int layer = 0; if (objectType == "village") { image = 4; layer = MapLayer::BUILDING; object = new MapObject(MapObjectCategory::CITY, pos, owner, actions); } else if (objectType == "dungeon") { image = 5; layer = MapLayer::BUILDING; object = new MapObject(MapObjectCategory::DUNGEON, pos, owner, actions); } else if (objectType == "party") { layer = MapLayer::UNIT; if (owner == 1) { image = 1; } else { image = 6; } actions.push_back(ActionNS::AACTION_MOVE); actions.push_back(ActionNS::AACTION_FIGHT); actions.push_back(ActionNS::AACTION_SHOP); actions.push_back(ActionNS::AACTION_ENTERDUNGEON); actions.push_back(ActionNS::AACTION_INVENTORY); units.push_back(produceUnit("swordsman", owner, MPointMake(1,1))); units.push_back(produceUnit("channeler", owner, MPointMake(1,0))); object = new PartyModel(MapObjectCategory::PARTY, pos, owner, actions, units); } else { return; } view = new MapObjectView(object, 64.0f, 64.0f, image, layer); object->addObserver(view); ModelManager::instance()->addMapObject(object); ViewControllerManager::instance()->add(view); }
/** * Produce in factories */ void BotPlayer::outpostProduce() { outpostList_t outposts = getOutposts(_objective_disposition_player); for (outpostList_t::iterator i = outposts.begin(); i != outposts.end(); i++) { OutpostStatus outpostStatus = ObjectiveInterface::getOutpostStatus(*i); if (outpostStatus.unit_generation_on_off == false) { // XXX hack, _unit_type_humvee is expected to be last accesible produceUnit(*i, rand() % (_unit_type_humvee + 1)); } } }
/** * Produce in factories */ void BotPlayer::outpostProduce() { ObjectiveID num_objectives = ObjectiveInterface::getObjectiveCount(); Objective* obj; for ( int i = 0; i < num_objectives; ++i ) { obj = ObjectiveInterface::getObjective(i); if ( obj->occupying_player && obj->occupying_player == PlayerInterface::getLocalPlayer() && obj->unit_generation_on_flag == false ) { produceUnit( i, rand() % UnitProfileInterface::getNumUnitTypes() ); } } }
int producePeasant(int x1, int y1, int x2, int y2) { return produceUnit(x1, y1, x2, y2, PEASANT_PRODUCE_ID); }
int produceKnight(int x1, int y1, int x2, int y2) { return produceUnit(x1, y1, x2, y2, KNIGHT_PRODUCE_ID); }