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


C++ ThreatMapEntry::elementAt方法代码示例

本文整理汇总了C++中ThreatMapEntry::elementAt方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreatMapEntry::elementAt方法的具体用法?C++ ThreatMapEntry::elementAt怎么用?C++ ThreatMapEntry::elementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ThreatMapEntry的用法示例。


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

示例1: getHighestDamagePlayer

CreatureObject* ThreatMap::getHighestDamagePlayer() {
	Locker locker(&lockMutex);

	uint32 maxDamage = 0;
	VectorMap<uint64,uint32> damageMap;
	CreatureObject* player = NULL;

	for (int i = 0; i < size(); ++i) {
		ThreatMapEntry* entry = &elementAt(i).getValue();

		uint32 totalDamage = 0;

		for (int j = 0; j < entry->size(); ++j) {
			uint32 damage = entry->elementAt(j).getValue();

			totalDamage += damage;
		}

		CreatureObject* creature = elementAt(i).getKey();

		if (creature->isPlayerCreature()) {
			if(!damageMap.contains(creature->getObjectID())){
				damageMap.put(creature->getObjectID(),totalDamage);
			} else {
				damageMap.get(creature->getObjectID()) += totalDamage;
			}

			if (damageMap.get(creature->getObjectID()) > maxDamage) {
				maxDamage = damageMap.get(creature->getObjectID());
				player = cast<CreatureObject*>(creature);
			}
		} else if (creature->isPet()) {
			CreatureObject* owner = creature->getLinkedCreature().get();

			if (owner != NULL && owner->isPlayerCreature()) {
				if(!damageMap.contains(owner->getObjectID())){
					damageMap.put(owner->getObjectID(),totalDamage);
				} else {
					damageMap.get(owner->getObjectID()) += totalDamage;
				}

				if (damageMap.get(owner->getObjectID()) > maxDamage) {
					maxDamage = damageMap.get(owner->getObjectID());
					player = cast<CreatureObject*>(owner);
				}
			}
		}
	}

	return player;
}
开发者ID:dogg-jr,项目名称:GR-Core,代码行数:51,代码来源:ThreatMap.cpp

示例2: getTotalDamage

uint32 ThreatMap::getTotalDamage() {
	Locker locker(&lockMutex);

	uint32 totalDamage = 0;

	for (int i = 0; i < size(); ++i) {
		ThreatMapEntry* entry = &elementAt(i).getValue();

		for (int j = 0; j < entry->size(); ++j) {
			uint32 damage = entry->elementAt(j).getValue();

			totalDamage += damage;
		}
	}

	return totalDamage;
}
开发者ID:dogg-jr,项目名称:GR-Core,代码行数:17,代码来源:ThreatMap.cpp

示例3: getHighestDamageGroupLeader

CreatureObject* ThreatMap::getHighestDamageGroupLeader(){

	Locker locker(&lockMutex);

	VectorMap<uint64,uint32> groupDamageMap;
	int64 highestGroupDmg = 0;

	//Logger::Logger tlog("Threat");

	ManagedReference<CreatureObject*> leaderCreature = NULL;

	for (int i = 0; i < size(); ++i) {
		ThreatMapEntry* entry = &elementAt(i).getValue();

		uint32 totalDamage = 0;

		for (int j = 0; j < entry->size(); ++j) {
			uint32 damage = entry->elementAt(j).getValue();

			totalDamage += damage;
		}

		CreatureObject* creature = elementAt(i).getKey();
		//tlog.info("Group id is " + String::valueOf(creature->getGroupID()),true);
		if(creature->isGrouped()){

			CreatureObject* thisleader = cast<CreatureObject*>(creature->getGroup()->getLeader());
			//tlog.info("leader is " + thisleader->getFirstName(),true);

			if(thisleader == NULL || !thisleader->isPlayerCreature())
				break;

			if(!groupDamageMap.contains(creature->getGroupID())){
				//tlog.info("first dmg for group " + String::valueOf(creature->getGroupID()) + " dmg: " + String::valueOf(totalDamage), true);
				groupDamageMap.put(creature->getGroupID(),totalDamage);

			} else {
				groupDamageMap.get(creature->getGroupID()) += totalDamage;
				//tlog.info("adding to group " + String::valueOf(creature->getGroupID()) + "  dmg total: " + String::valueOf(groupDamageMap.get(creature->getGroupID())) + " this player dmg: " + String::valueOf(totalDamage),true);

			}

			if(groupDamageMap.get(creature->getGroupID()) > highestGroupDmg){
				highestGroupDmg = groupDamageMap.get(creature->getGroupID());
				leaderCreature = thisleader;
			}
		} else if (creature->isPet()) {
			CreatureObject* owner = creature->getLinkedCreature().get();

			if (owner != NULL && owner->isPlayerCreature()) {
				if (owner->isGrouped()) {
					CreatureObject* thisleader = cast<CreatureObject*>(owner->getGroup()->getLeader());

					if(thisleader == NULL || !thisleader->isPlayerCreature())
						break;

					if(!groupDamageMap.contains(owner->getGroupID())){
						groupDamageMap.put(owner->getGroupID(),totalDamage);
					} else {
						groupDamageMap.get(owner->getGroupID()) += totalDamage;
					}

					if(groupDamageMap.get(owner->getGroupID()) > highestGroupDmg){
						highestGroupDmg = groupDamageMap.get(owner->getGroupID());
						leaderCreature = thisleader;
					}
				} else {
					if(!groupDamageMap.contains(owner->getObjectID())){
						groupDamageMap.put(owner->getObjectID(),totalDamage);
					} else {
						groupDamageMap.get(owner->getObjectID()) += totalDamage;
					}

					if(totalDamage > highestGroupDmg) {
						highestGroupDmg = totalDamage;
						leaderCreature = owner;
					}
				}
			}
		} else {
			//tlog.info("adding single creature damage " + String::valueOf(totalDamage),true);
			groupDamageMap.put(creature->getObjectID(),totalDamage);
			if(totalDamage > highestGroupDmg) {
				highestGroupDmg = totalDamage;
				leaderCreature = creature;
			}

		}
	}
	//tlog.info("highest group is " + leaderCreature->getFirstName() + " damage of " + String::valueOf(highestGroupDmg),true);
	return leaderCreature;
}
开发者ID:dogg-jr,项目名称:GR-Core,代码行数:92,代码来源:ThreatMap.cpp


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