本文整理汇总了C++中Monster类的典型用法代码示例。如果您正苦于以下问题:C++ Monster类的具体用法?C++ Monster怎么用?C++ Monster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Monster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Assert
bool DynamicZoneSlayerMirrorOfAbyss::addMono()
{
Assert(m_pZone != NULL);
// 이성의 봉인을 생성한다.
Monster* pMonster = new Monster(792);
Assert(pMonster != NULL);
pMonster->setName("이성의 봉인");
pMonster->setClanType(33);
try
{
m_pZone->addCreature(pMonster, 15, 15, 2);
m_pZone->getMonsterManager()->addEnemy(NULL, pMonster);
m_MonoObjectID = pMonster->getObjectID();
}
catch (EmptyTileNotExistException& )
{
SAFE_DELETE(pMonster);
}
return true;
}
示例2: getShapePalette
Creature *Session::addCreatureFromScript( char *creatureType, int cx, int cy, int *fx, int *fy, int r ) {
Monster *monster = Monster::getMonsterByName( creatureType );
if ( !monster ) {
cerr << "*** Error: no monster named " << creatureType << endl;
return NULL;
}
GLShape *shape = getShapePalette()->
getCreatureShape( monster->getModelName(),
monster->getSkinName(),
monster->getScale(),
monster );
Creature *replacement = newCreature( monster, shape );
// register with squirrel
registerWithSquirrel( replacement );
bool b = true;
if( r > 0 ) {
b = replacement->findPlaceBoundedRadial( cx, cy, r );
} else if ( fx && fy ) {
b = replacement->findPlace( cx, cy, fx, fy );
} else {
//int ffx, ffy;
//replacement->findPlace( cx, cy, &ffx, &ffy );
replacement->moveTo( cx, cy, 0 );
getMap()->setCreature( cx, cy, 0, replacement );
}
replacement->cancelTarget();
return replacement;
}
示例3: OTSYS_TIME
void Spawn::checkSpawn()
{
#ifdef __DEBUG_SPAWN__
std::clog << "[Notice] Spawn::checkSpawn " << this << std::endl;
#endif
Monster* monster;
uint32_t spawnId;
checkSpawnEvent = 0;
for(SpawnedMap::iterator it = spawnedMap.begin(); it != spawnedMap.end();)
{
spawnId = it->first;
monster = it->second;
if(monster->isRemoved())
{
if(spawnId)
spawnMap[spawnId].lastSpawn = OTSYS_TIME();
monster->unRef();
spawnedMap.erase(it++);
}
else
{
/*if(spawnId && !isInSpawnZone(monster->getPosition()) && monster->getIdleStatus())
g_game.internalTeleport(monster, monster->getMasterPosition(), true);
*/++it;
}
}
uint32_t spawnCount = 0;
for(SpawnMap::iterator it = spawnMap.begin(); it != spawnMap.end(); ++it)
{
spawnId = it->first;
spawnBlock_t& sb = it->second;
if(spawnedMap.count(spawnId))
continue;
if(OTSYS_TIME() < sb.lastSpawn + sb.interval)
continue;
if(findPlayer(sb.pos))
{
sb.lastSpawn = OTSYS_TIME();
continue;
}
spawnMonster(spawnId, sb.mType, sb.pos, sb.direction);
++spawnCount;
if(spawnCount >= (uint32_t)g_config.getNumber(ConfigManager::RATE_SPAWN))
break;
}
if(spawnedMap.size() < spawnMap.size())
checkSpawnEvent = Scheduler::getInstance().addEvent(createSchedulerTask(getInterval(), boost::bind(&Spawn::checkSpawn, this)));
#ifdef __DEBUG_SPAWN__
else
std::clog << "[Notice] Spawn::checkSpawn stopped " << this << std::endl;
#endif
}
示例4: update
void GameLayer::update(float dt)
{
// check if animationing
if (m_isAnimationing) {
// init with false
m_isAnimationing = false;
for (int i = 0; i < m_height * m_width; i++) {
Monster *mon = m_matrix[i];
if (mon && mon->getNumberOfRunningActions() > 0) {
m_isAnimationing = true;
break;
}
}
}
// if Monter is moving, ignore use touch event
m_isTouchEnable = !m_isAnimationing;
if (!m_isAnimationing) {
if (m_isNeedFillVacancies) {
//爆炸效果结束后才掉落新怪物,增强打击感
fillVacancies();
m_isNeedFillVacancies = false;
}
else {
checkAndRemoveChain();
}
}
}
示例5: if
void PlayerController::handlePlayerRotateCommand(const ann::util::Dictionary& dict) {
std::string direction = dict["direction"].asString();
int angleDiff = 0;
Game& game = Game::getInstance();
MonsterDriver* monsterDriver = game.getMonsterDriver();
Monster* player = game.getPlayer();
if (direction == Constants::kRotateDirectionHalfLeft) {
monsterDriver->rotateHalfLeft(player);
angleDiff = Constants::kMonsterRotateStep;
} else if (direction == Constants::kRotateDirectionHalfRight) {
monsterDriver->rotateHalfRight(player);
angleDiff = -Constants::kMonsterRotateStep;
} else {
LOGE("Uknown rotation direction %s", direction.c_str());
}
ann::util::Dictionary responce;
responce["id"] = player->getId();
responce["angleDiff"] = angleDiff;
ann::util::NotificationCenter::getInstance().postNotification(Constants::kMonsterRotateNotification, responce);
ann::util::NotificationCenter::getInstance().postNotification(Constants::kAllRoundActionsDoneNotification);
}
示例6: addMonster
void HelloWorld::addMonster()
{
// CCSprite* monster = CCSprite::create("monster.png");
Monster* monster = NULL;
if (rand() % 2 == 0)
{
monster = WeakAndFastMonster::create();
}
else
{
monster = StrongAndSlowMonster::create();
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
int minY = monster->getContentSize().height / 2;
int maxY = winSize.height - monster->getContentSize().height / 2;
int rangeY = maxY - minY;
int actualY = (rand() % rangeY) + minY;
monster->setPosition(ccp(winSize.width + monster->getContentSize().width / 2, actualY));
this->addChild(monster);
int minDuration = monster->getMinMoveDuration();
int maxDuration = monster->getMaxMoveDuration();
int rangeDuration = maxDuration - minDuration;
int actualDuration = (rand() % rangeDuration) + minDuration;
CCMoveTo* actionMove = CCMoveTo::create(actualDuration, ccp(-monster->getContentSize().width / 2, actualY));
CCCallFuncN* actionMoveDone = CCCallFuncN::create(this, callfuncN_selector(HelloWorld::spriteMoveFinished));
monster->runAction(CCSequence::create(actionMove, actionMoveDone, NULL));
monster->setTag(1);
_monsters->addObject(monster);
}
示例7: Dungeon
Game::Game(int dungeon_height, int dungeon_width, int number_of_monsters){
// initialize dungeon
dungeon = new Dungeon(dungeon_width, dungeon_height);
// initialize default weapon
Weapon* kurzschwert = new Weapon("Kurzschwert", 2.0);
Attributes kurzschwert_mods;
kurzschwert_mods.strength = 3;
kurzschwert_mods.agility = -1;
kurzschwert->setModificators(kurzschwert_mods);
// initialize hero
gregor_bob = new Hero("Gregor-Bob");
Attributes hero_attribs;
hero_attribs.strength = 6;
hero_attribs.agility = 7;
gregor_bob->setMaxWeight(10.0);
gregor_bob->addItem(kurzschwert);
gregor_bob->setModificators(hero_attribs);
// initialize monsters and distribute over dungeon
for(int i = 0; i < number_of_monsters; i++){
Monster* monster = new Monster("generic_monster");
monster_x = rand() % dungeon_width;
monster_y = rand() % dungeon_height;
Attributes monster_attribs;
monster_attribs.strength = 10;
monster_attribs.agility = 5;
monster->setAttributes(monster_attribs);
monster->setCurrentLocation(monster_x, monster_y);
dungeon->getRoom(monster_x, monster_y)->addCreature(monster);
}
}
示例8: pushCreatures
void Monster::pushCreatures(Tile* tile)
{
CreatureVector* creatures = tile->getCreatures();
if(!creatures)
return;
bool effect = false;
Monster* monster = NULL;
for(uint32_t i = 0; i < creatures->size();)
{
if((monster = creatures->at(i)->getMonster()) && monster->isPushable())
{
if(pushCreature(monster))
continue;
monster->setDropLoot(LOOT_DROP_NONE);
monster->changeHealth(-monster->getHealth());
if(!effect)
effect = true;
}
++i;
}
if(effect)
g_game.addMagicEffect(tile->getPosition(), MAGIC_EFFECT_BLOCKHIT);
}
示例9: TEST
TEST (Monster, ReferenceAddressesShouldBeTheSameOnFluenting)
{
Monster monster ("X", 1);
EXPECT_EQ (&monster, &(monster.WithStat (Statistics ())));
EXPECT_EQ (&monster, &(monster.Weaponed (Weapon())));
}
示例10: get_monster_in_direction
bool Polymorph::Zap(Coord dir)
{
Monster* monster = get_monster_in_direction(dir, true);
if (!monster)
return true;
//cancel the holding effect as the monster is changing
if (game->hero().is_held_by(monster)) {
game->hero().clear_hold();
}
//restore the level tile, as the new monster may be invisible
Coord p = monster->position();
if (game->hero().can_see_monster(monster))
game->screen().add_tile(p, game->level().get_tile(p));
//create a random monster
Monster* new_monster = Monster::CreateMonster(rnd(26) + 'A', &p, game->get_level());
new_monster->set_tile_beneath(monster->tile_beneath());
new_monster->m_pack = monster->m_pack;
if (new_monster->m_type != monster->m_type)
discover(false);
if (game->hero().can_see_monster(new_monster))
game->screen().add_tile(p, new_monster->m_type);
//the monster chases the player
new_monster->start_run(&game->hero());
//destroy the original
game->level().monsters.remove(monster);
delete monster;
return true;
}
示例11: spawnMonster
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, bool startup /*= false*/)
{
Monster* monster = Monster::createMonster(mType);
if (!monster) {
return false;
}
if (startup) {
//No need to send out events to the surrounding since there is no one out there to listen!
if (!g_game.internalPlaceCreature(monster, pos, true)) {
delete monster;
return false;
}
} else {
if (!g_game.placeCreature(monster, pos, false, true)) {
delete monster;
return false;
}
}
monster->setDirection(dir);
monster->setSpawn(this);
monster->setMasterPos(pos, radius);
monster->useThing2();
spawnedMap.insert(spawned_pair(spawnId, monster));
spawnMap[spawnId].lastSpawn = OTSYS_TIME();
return true;
}
示例12: main
int main()
{
player.Pos_x = 2; player.Pos_y = 2; player.Frame_Cnt = 0;
UnBreakable_Wall().UnBreakable_Wall_Init();
for (int i = 0; i < 10; i++) monster.Monster_Init();
Breakable_Wall().Breakable_Wall_Init();
State();
while (Move_Dir = _getch())
{
player.Frame_Cnt++;
//20초마다 몬스터 추가
if (player.Frame_Cnt % 20 == 0) monster.Monster_Init();
//사용자
player.Player_Move(&player, Move_Dir);
//몬스터
monster.Monster_Move();
monster.Monster_Attack();
//폭탄
bomb.Bomb_Cnt();
//종료 확인
if (End_Flag)return 0;
//출력
Output();
}
return 0;
}
示例13: GetMyPlayer
/************************************************************************
* 处理鼠标右击事件
************************************************************************/
void Controller::HandleRightClick(Point& destPoint)
{
Player* myPlayer = GetMyPlayer();//GetPlayerManager()->GetPlayer(m_strMyPlayerID);
// 把所有的怪物的被选中状态置为未选择状态
Game()->GetMonsterManager()->UnSelectAllMonster();
// 判断鼠标右击区域是否存在一个怪物,如果存在就返回该怪物的指针,否则返回空
Monster* pMonster = Game()->GetMonsterManager()->GetMonster(destPoint);
if (pMonster != 0)
{
m_pCurrentSelectedMonster = pMonster;
// 设置该怪物为被选中状态
pMonster->SetSelected(true);
// 在怪物血条栏上显示怪物的血量
MonsterLogic::GetInstance()->HandleMonsterBloodChange(pMonster,0);
}
else
{
// 清空怪物血条栏上怪物的血量
Game()->GetSceneManager()->SetMonsterBloodProgress(0);
}
// 获取玩家当前的朝向
int dir = Game()->GetPathManager()->GetDirection(myPlayer->getPosition(),destPoint);
// 设置玩家的目的地点(玩家要移动到鼠标右键点击的区域)
myPlayer->SetDestPoint(destPoint);
// 玩家跑动
myPlayer->Action(CodeMsg::code_player_run,dir);
GetNetworkModule()->SendPlayerState(myPlayer);
}
示例14: getRandomLocation
void TerrainGenerator::addMissionObjectives( Map *map, ShapePalette *shapePal ) {
cerr << "...TerrainGenerator::addMissionObjectives" << endl;
if ( mission && !mission->isCompleted() && depth > 0 ) {
int startIndex, endIndex;
int items = mission->getItemCount();
cerr << "\t...adding items" << endl;
if( items > 0 ) {
startIndex = depth - 1;
endIndex = depth < maxDepth - 1 ? startIndex + 1 : items;
cerr << "\t...range=" << startIndex << " to " << endIndex << endl;
//cerr << "*** Added mission items: from " << startIndex << " to " << endIndex << endl;
// mission objects are on a pedestal
// and they are blocking so creatures can't get them
for ( int i = startIndex; i < endIndex; i++ ) {
RpgItem *rpgItem = mission->getItem( i );
Item *item = scourge->getSession()->newItem( rpgItem, mission->getLevel() );
//mission->addItemInstance( item, rpgItem );
item->setMissionObjectInfo( mission->getMissionId(), i );
item->setBlocking( true ); // don't let monsters pick this up
Item *pedestal = scourge->getSession()->newItem( RpgItem::getItemByName( "Pedestal" ) );
int x, y;
getRandomLocation( map, pedestal->getShape(), &x, &y );
addItem( map, NULL, pedestal, NULL, x, y );
addItem( map, NULL, item, NULL,
x + ( pedestal->getShape()->getWidth() / 2 ) - ( item->getShape()->getWidth() / 2 ),
y - ( pedestal->getShape()->getDepth() / 2 ) + ( item->getShape()->getDepth() / 2 ),
pedestal->getShape()->getHeight() );
cerr << "\t...Added mission item: " << item->getItemName() << " at: " << x << "," << y << endl;
}
}
cerr << "\t...adding creatures" << endl;
int creatures = mission->getCreatureCount();
if( creatures > 0 ) {
startIndex = depth - 1;
endIndex = depth < maxDepth - 1 ? startIndex + 1 : creatures;
cerr << "\t...range=" << startIndex << " to " << endIndex << endl;
//cerr << "*** Added mission creatures: from " << startIndex << " to " << endIndex << endl;
// add mission creatures
for ( int i = startIndex; i < endIndex; i++ ) {
int x, y;
Monster *monster = mission->getCreature( i );
GLShape *shape = scourge->getSession()->getShapePalette()->
getCreatureShape( monster->getModelName(),
monster->getSkinName(),
monster->getScale(),
monster );
Creature *creature = scourge->getSession()->newCreature( monster, shape );
creature->setMissionObjectInfo( mission->getMissionId(), i );
//mission->addCreatureInstanceMap( creature, monster );
getRandomLocation( map, creature->getShape(), &x, &y );
addItem( map, creature, NULL, NULL, x, y );
creature->moveTo( x, y, 0 );
cerr << "\t...Added mission monster: " << creature->getMonster()->getType() << endl;
}
}
}
cerr << "\t...done" << endl;
}
示例15: pushCreatures
void Monster::pushCreatures(Tile* tile)
{
//We can not use iterators here since we can push a creature to another tile
//which will invalidate the iterator.
if(CreatureVector* creatures = tile->getCreatures())
{
uint32_t removeCount = 0;
for(uint32_t i = 0; i < creatures->size();)
{
Monster* monster = creatures->at(i)->getMonster();
if(monster && monster->isPushable())
{
if(pushCreature(monster))
continue;
else
{
monster->changeHealth(-monster->getHealth());
monster->setDropLoot(false);
removeCount++;
}
}
++i;
}
if(removeCount > 0)
g_game.addMagicEffect(tile->getPosition(), NM_ME_BLOCKHIT);
}
}