当前位置: 首页>>代码示例>>C++>>正文


C++ Monsters类代码示例

本文整理汇总了C++中Monsters的典型用法代码示例。如果您正苦于以下问题:C++ Monsters类的具体用法?C++ Monsters怎么用?C++ Monsters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Monsters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cleanAllMonster

void MonsterBase::cleanAllMonster()
{
	Monsters * monsters = Monsters::getInstance();
	for(auto x = monsters->getMonsterVector().begin(); x != monsters->getMonsterVector().end(); x++)
	{
		(*x)->monsterDie();
	}
}
开发者ID:joyfish,项目名称:TowerTD,代码行数:8,代码来源:MonsterBase.cpp

示例2: init_game

static void init_game(int level)
{
    int i = 0;

    monsters.clear();

    for (i=0; i<level; i++) {
        Object m;
        m.x = rnd(1, 10);
        m.y = rnd(1, 10);
        m.life = 1;
        m.face = '@';
        m.score = 10;
        monsters.push_back(Monsters::value_type(m));
    }
}
开发者ID:pengyuwei,项目名称:hackathon2014,代码行数:16,代码来源:g.c

示例3: if

bool Monsters::deserializeSpell(xmlNodePtr node, spellBlock_t& sb, const std::string& description)
{
	sb.range = sb.minCombatValue = sb.maxCombatValue = 0;
	sb.combatSpell = sb.isMelee = false;
	sb.chance = 100;
	sb.speed = 2000;

	std::string name, scriptName;
	bool isScripted = false;
	if(readXMLString(node, "script", scriptName))
		isScripted = true;
	else if(!readXMLString(node, "name", name))
		return false;

	int32_t intValue;
	std::string strValue;
	if(readXMLInteger(node, "speed", intValue) || readXMLInteger(node, "interval", intValue))
		sb.speed = std::max(1, intValue);

	if(readXMLInteger(node, "chance", intValue))
	{
		if(intValue < 0 || intValue > 100)
			intValue = 100;

		sb.chance = intValue;
	}

	if(readXMLInteger(node, "range", intValue))
	{
		if(intValue < 0)
			intValue = 0;

		if(intValue > Map::maxViewportX * 2)
			intValue = Map::maxViewportX * 2;

		sb.range = intValue;
	}

	if(readXMLInteger(node, "min", intValue))
		sb.minCombatValue = intValue;

	if(readXMLInteger(node, "max", intValue))
		sb.maxCombatValue = intValue;

	//normalize values
	if(std::abs(sb.minCombatValue) > std::abs(sb.maxCombatValue))
		std::swap(sb.minCombatValue, sb.maxCombatValue);

	if((sb.spell = g_spells->getSpellByName(name)))
		return true;

	CombatSpell* combatSpell = NULL;
	bool needTarget = false, needDirection = false;
	if(isScripted)
	{
		if(readXMLString(node, "direction", strValue))
			needDirection = booleanString(strValue);

		if(readXMLString(node, "target", strValue))
			needTarget = booleanString(strValue);

		combatSpell = new CombatSpell(NULL, needTarget, needDirection);
		if(!combatSpell->loadScript(getFilePath(FILE_TYPE_OTHER, g_spells->getScriptBaseName() + "/scripts/" + scriptName), true))
		{
			delete combatSpell;
			return false;
		}

		if(!combatSpell->loadScriptCombat())
		{
			delete combatSpell;
			return false;

		}

		combatSpell->getCombat()->setPlayerCombatValues(FORMULA_VALUE, sb.minCombatValue, 0, sb.maxCombatValue, 0, 0, 0, 0, 0, 0, 0);
	}
	else
	{
		Combat* combat = new Combat;
		sb.combatSpell = true;
		if(readXMLInteger(node, "length", intValue))
		{
			int32_t length = intValue;
			if(length > 0)
			{
				int32_t spread = 3;
				//need direction spell
				if(readXMLInteger(node, "spread", intValue))
					spread = std::max(0, intValue);

				CombatArea* area = new CombatArea();
				area->setupArea(length, spread);

				combat->setArea(area);
				needDirection = true;
			}
		}

		if(readXMLInteger(node, "radius", intValue))
//.........这里部分代码省略.........
开发者ID:milbradt,项目名称:TFS,代码行数:101,代码来源:monsters.cpp

示例4: reloadInfo

void Commands::reloadInfo(Player* player, const std::string& cmd, const std::string& param)
{
	std::string tmpParam = asLowerCaseString(param);
	if (tmpParam == "action" || tmpParam == "actions") {
		g_actions->reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded actions.");
	} else if (tmpParam == "config" || tmpParam == "configuration") {
		g_config.reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded config.");
	} else if (tmpParam == "command" || tmpParam == "commands") {
		reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded commands.");
	} else if (tmpParam == "creaturescript" || tmpParam == "creaturescripts") {
		g_creatureEvents->reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded creature scripts.");
	} else if (tmpParam == "monster" || tmpParam == "monsters") {
		g_monsters.reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded monsters.");
	} else if (tmpParam == "move" || tmpParam == "movement" || tmpParam == "movements"
	           || tmpParam == "moveevents" || tmpParam == "moveevent") {
		g_moveEvents->reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded movements.");
	} else if (tmpParam == "npc" || tmpParam == "npcs") {
		g_npcs.reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded npcs.");
	} else if (tmpParam == "raid" || tmpParam == "raids") {
		Raids::getInstance()->reload();
		Raids::getInstance()->startup();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded raids.");
	} else if (tmpParam == "spell" || tmpParam == "spells") {
		g_spells->reload();
		g_monsters.reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded spells.");
	} else if (tmpParam == "talk" || tmpParam == "talkaction" || tmpParam == "talkactions") {
		g_talkActions->reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded talk actions.");
	} else if (tmpParam == "items") {
		Item::items.reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded items.");
	} else if (tmpParam == "weapon" || tmpParam == "weapons") {
		g_weapons->reload();
		g_weapons->loadDefaults();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded weapons.");
	} else if (tmpParam == "quest" || tmpParam == "quests") {
		Quests::getInstance()->reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded quests.");
	} else if (tmpParam == "mount" || tmpParam == "mounts") {
		Mounts::getInstance()->reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded mounts.");
	} else if (tmpParam == "globalevents" || tmpParam == "globalevent") {
		g_globalEvents->reload();
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reloaded globalevents.");
	} else {
		player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "Reload type not found.");
	}
}
开发者ID:KnightLogini,项目名称:forgottenserver,代码行数:56,代码来源:commands.cpp

示例5: createMonster

Monster* Monster::createMonster(const std::string& name)
{
	unsigned long id = g_monsters.getIdByName(name);
	if(!id){
		return NULL;
	}
	
	MonsterType* mtype = g_monsters.getMonsterType(id);
	if(!mtype)
		return NULL;
	
	Monster* new_monster = new Monster(mtype);
	return new_monster;
}
开发者ID:divinity76,项目名称:server,代码行数:14,代码来源:monster.cpp

示例6: addMonster

bool Spawn::addMonster(const std::string& _name, const Position& _pos, Direction _dir, uint32_t _interval)
{
	if(!g_game.getTile(_pos))
	{
		std::cout << "[Spawn::addMonster] NULL tile at spawn position (" << _pos << ")" << std::endl;
		return false;
	}

	MonsterType* mType = g_monsters.getMonsterType(_name);
	if(!mType)
	{
		std::cout << "[Spawn::addMonster] Cannot find \"" << _name << "\"" << std::endl;
		return false;
	}

	if(_interval < interval)
		interval = _interval;

	spawnBlock_t sb;
	sb.mType = mType;
	sb.pos = _pos;
	sb.direction = _dir;
	sb.interval = _interval;
	sb.lastSpawn = 0;

	uint32_t spawnId = (int32_t)spawnMap.size() + 1;
	spawnMap[spawnId] = sb;
	return true;
}
开发者ID:Fir3element,项目名称:035,代码行数:29,代码来源:spawn.cpp

示例7: monsters_round

static int monsters_round()
{
    int ret = 0;
    int yoffset = 0;
    int xoffset = 0;

    for (unsigned i=0; i<monsters.size(); i++) {
        ret++;
        Object *m = &monsters[i];
        mvwaddch(win_disp->win, m->y, m->x, ' ');
        yoffset = me.y - m->y;
        xoffset = me.x - m->x;
        if (abs(yoffset) > abs(xoffset)) {
            if (yoffset > 0) {
                m->y++;
            } else {
                m->y--;
            }
        } else {
            if (xoffset > 0) {
                m->x++;
            } else {
                m->x--;
            }
        }
        if (m->y == me.y && m->x == me.x) {
            me.life--;
        }
        mvwaddch(win_disp->win, m->y, m->x, m->face);
        wrefresh(win_disp->win);
        usleep(1000*200);
    }
    
    return ret;
}
开发者ID:pengyuwei,项目名称:hackathon2014,代码行数:35,代码来源:g.c

示例8: createMonster

Monster* Monster::createMonster(const std::string& name, std::string customName /* = ""*/)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;

	return createMonster(mType, customName);
}
开发者ID:milbradt,项目名称:TFS,代码行数:8,代码来源:monster.cpp

示例9: createMonster

Monster* Monster::createMonster(const std::string& name)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if (!mType) {
		return nullptr;
	}
	return new Monster(mType);
}
开发者ID:WibbenZ,项目名称:forgottenserver,代码行数:8,代码来源:monster.cpp

示例10: createMonster

Monster* Monster::createMonster(const std::string& name)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;

	return createMonster(mType);
}
开发者ID:alexisjojo,项目名称:darkkonia,代码行数:8,代码来源:monster.cpp

示例11: createMonsterNick

Monster* Monster::createMonsterNick(const std::string& name, const std::string& nick)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;
		
	mType->name = nick;		
    mType->realName = name;
	return createMonster(mType);
}
开发者ID:CaosJunior,项目名称:DxP,代码行数:10,代码来源:monster.cpp

示例12: fire_fly

static int fire_fly()
{
    int hit = 0;
    int ret = 0;

    for (unsigned i=0; i<fires.size(); i++) {
        ret++;
        hit = 0;
        Object *f = &fires[i];
        mvwaddch(win_disp->win, f->y, f->x, ' '); // erase old face
        f->x += f->xstep;
        f->y += f->ystep;
        if (f->x < 0 || f->x >= win_disp->locate.w
                || f->y < 0 || f->y >= win_disp->locate.h) {
            fires.erase(fires.begin() + i);
            break;
        }
        // hit test
        for (unsigned j=0; j<monsters.size(); j++) {
            Object *m = &monsters[j];
            if (f->x == m->x && f->y == m->y) {
                m->life--;
                if (m->life <= 0) {
                    hit = 1;
                    monsters.erase(monsters.begin() + j);
                    me.score += m->score;
                    break;
                }
            }
        }
        if (hit) {
            continue;
        }
        mvwaddch(win_disp->win, f->y, f->x, f->face);
        draw_me();
        wrefresh(win_disp->win);

        usleep(1000*100);
    }

    return ret;
}
开发者ID:pengyuwei,项目名称:hackathon2014,代码行数:42,代码来源:g.c

示例13: createMonster

Monster* Monster::createMonster(const std::string& name)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if(!mType)
		return NULL;
		
           mType->name = name; 
           mType->realName = name;
           
    
			//-- sistema de shiny respawn
			
			mType->codenome = ""; 
 		    mType->exists = false;
			
			std::string findText[] = {"Shiny", "Elite", "Elder", "shiny", "elite", "elder"};
            for(int i = 0; i < 6; i++){
            	if(mType->name.find(findText[i]) != std::string::npos){
            		mType->codenome = findText[i]; 
            		mType->exists = true;
            		break;
            	}
            }	
    		
			
			if (mType->exists) {
                mType->realName = mType->name;
                std::string newName = mType->name;	
                std::string from = mType->codenome + " ";	
                std::string to = "";	
                size_t start_pos = 0;
                while((start_pos = newName.find(from, start_pos)) != std::string::npos) {
                    newName.replace(start_pos, from.length(), to);
                    start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
                }
                mType->name = newName;
            } 
            
		
	return createMonster(mType);
}
开发者ID:CaosJunior,项目名称:DxP,代码行数:41,代码来源:monster.cpp

示例14: addMonster

bool Spawn::addMonster(const std::string& name, const Position& pos, Direction dir, uint32_t interval)
{
	MonsterType* mType = g_monsters.getMonsterType(name);
	if (!mType) {
		std::cout << "[Spawn::addMonster] Can not find " << name << std::endl;
		return false;
	}

	this->interval = std::min(this->interval, interval);

	spawnBlock_t sb;
	sb.mType = mType;
	sb.pos = pos;
	sb.direction = dir;
	sb.interval = interval;
	sb.lastSpawn = 0;

	uint32_t spawnId = spawnMap.size() + 1;
	spawnMap[spawnId] = sb;
	return true;
}
开发者ID:Alissonfgp,项目名称:forgottenserver,代码行数:21,代码来源:spawn.cpp

示例15: draw

static void draw()
{
    unsigned i = 0;

    if (NULL == win_disp) {
        return;
    }
    wclear(win_disp->win);
    char msg[16] = {0};
    sprintf(msg, "L%d R%d Score:%d", level, round, me.score);
    mvwaddstr(win_disp->win, 0, 1, msg);

    mvwaddch(win_disp->win, me.y, me.x, me.face);
    for (i=0; i<monsters.size(); i++) {
        Object *m = &monsters[i];
        mvwaddch(win_disp->win, m->y, m->x, m->face);
    }
    for (i=0; i<fires.size(); i++) {
        Object *f = &fires[i];
        mvwaddch(win_disp->win, f->y, f->x, f->face);
    }
    
    wrefresh(win_disp->win);
}
开发者ID:pengyuwei,项目名称:hackathon2014,代码行数:24,代码来源:g.c


注:本文中的Monsters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。