本文整理汇总了C++中MapObject::addObserver方法的典型用法代码示例。如果您正苦于以下问题:C++ MapObject::addObserver方法的具体用法?C++ MapObject::addObserver怎么用?C++ MapObject::addObserver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapObject
的用法示例。
在下文中一共展示了MapObject::addObserver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: produceAndRegisterMapObject
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);
}