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


C++ PlayerData::getPlayer方法代码示例

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


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

示例1: update

int EnemyMovementObject::update(int dt) {
	if(NpcMovementObject::update(dt) == -1) {
		return -1;
	}

	if(noAttackTimer > 0) {
		noAttackTimer -= dt;
		if(noAttackTimer < 0) {
			noAttackTimer = 0;
		}
	}



	if(noAttackTimer == 0) {
		Rectangle *thisRect = sprite->getRectWithoutRot();

		if(getObjectList() != NULL) {
			std::list<GameObject*> *spatialList = spatialHashmap->getNearby(this);
			for(std::list<GameObject*>::iterator it = spatialList->begin(); it != spatialList->end(); ++it) {
				GameObject *gameObject = *it;



				if(gameObject->gameObjectInstance->gameObject->type != GameObjectClass::INIMIGO &&
						gameObject->gameObjectInstance->gameObject->type != GameObjectClass::ITEM) {

					Rectangle *objectRect = gameObject->sprite->getRectWithoutRot();

					if(!gameObject->isInvincible() && gameObject->position->z == 0 &&  objectRect->intersectsWith(thisRect)) {
						int dmg = gameObject->addDamage(this, this->gameObjectInstance->gameObject->atacaEncostaPersonagemDano);
						if(dmg != 0) {
							gameObject->setInvincibility(1000);
						}


					}

					delete objectRect;

				}
			}

			delete spatialList;
		}

		delete thisRect;
	}




	if(attackTimer/1000.0f > (float)this->gameObjectInstance->gameObject->tempoAtaque) {
		if(this->gameObjectInstance->gameObject->atiraItemMagiaDirecaoPersonagem) {
			ObjectFunctions *objectFunctions = ObjectFunctions::getInstance();

			GameData *gameData = GameData::getInstance();
			PlayerData *playerData = PlayerData::getInstance();
			GameObjectClass *throwed;
			throwed = gameData->searchGameObjectById(this->gameObjectInstance->gameObject->atiraItemMagiaDirecaoPersonagemIdItem);

			if(playerData->getPlayer() != NULL) {
				objectFunctions->throwObject(this, throwed, 2, Vector2(*playerData->getPlayer()->position),  0);
			}

		}

		if(this->gameObjectInstance->gameObject->atiraItemMaginaDirecaoEstiver) {
			ObjectFunctions *objectFunctions = ObjectFunctions::getInstance();

			GameData *gameData = GameData::getInstance();
			GameObjectClass *throwed;
			throwed = gameData->searchGameObjectById(this->gameObjectInstance->gameObject->atiraItemMaginaDirecaoEstiverIdItem);

			objectFunctions->throwObject(this, throwed, 2, 0);
		}

		attackTimer = 0;
	}





	attackTimer += dt;

}
开发者ID:slumki,项目名称:gameka-runtime,代码行数:87,代码来源:EnemyMovementObject.cpp


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