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


C++ PlayerEntity类代码示例

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


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

示例1: ZhiLiaoShu

int ShengNv::ZhiLiaoShu(int &step, Action* action)
{
	int dstID = action->dst_ids(0);
	int cardID = action->card_ids(0);
	PlayerEntity * dstPlayer = engine->getPlayerEntity(dstID);
	if(step != ZHI_LIAO_SHU)
	{
		SkillMsg skill_msg;
		Coder::skillNotice(id, dstID, ZHI_LIAO_SHU, skill_msg);
		engine->sendMessage(-1, MSG_SKILL, skill_msg);
		CardMsg show_card;
		Coder::showCardNotice(id, 1, cardID, show_card);
		engine->sendMessage(-1, MSG_CARD, show_card);
		engine->setStateMoveOneCardNotToHand(id, DECK_HAND, -1, DECK_DISCARD, cardID, id, ZHI_LIAO_SHU, true);
		//插入了新状态,请return GE_URGENT
		return GE_URGENT;
	}
	else
	{
		dstPlayer->addCrossNum(2);
		GameInfo update_info;
		Coder::crossNotice(dstID, dstPlayer->getCrossNum(), update_info);
		engine->sendMessage(-1, MSG_GAME, update_info);
		return GE_SUCCESS;
	}
}
开发者ID:GaelClichy,项目名称:CodfiyAsteriatedGrailServer,代码行数:26,代码来源:ShengNv.cpp

示例2: assert

void PlayerBullet::onLoad()
{
	PlayerEntity* player = GameGlobals::get()->player;
	assert(player);

	sf::Color color;

	bulletStance = player->getStance();

	switch(bulletStance)
	{
	case PlayerEntity::Stance::Agile:
		color = sf::Color(140, 255, 50);
		break;

	case PlayerEntity::Stance::Defensive:
		color = sf::Color(40, 120, 250);
		break;

	case PlayerEntity::Stance::Offensive:
		color = sf::Color(255, 80, 50);
		break;
	}

	getComponent<sz::Renderer>()->setColor(color);
}
开发者ID:Sonaza,项目名称:scyori,代码行数:26,代码来源:PlayerBullet.cpp

示例3: setCrystal

int ShengNv::ShengLiao(Action* action)
{
	SkillMsg skill_msg;
	list<int> dsts;
	int dstID;
	PlayerEntity * dstPlayer;
	for(int i=0; i < action->dst_ids_size(); i ++)
	{
		dsts.push_back(action->dst_ids(i));
	}
	Coder::skillNotice(id, dsts, SHENG_LIAO, skill_msg);
	engine->sendMessage(-1, MSG_SKILL, skill_msg);
	//更新能量
	GameInfo update_info;
	if(crystal>0){
		setCrystal(--crystal);
	}
	else{
		setGem(--gem);
	}
	Coder::energyNotice(id, gem, crystal, update_info);
	engine->sendMessage(-1, MSG_GAME, update_info);
	for(int i=0; i < action->dst_ids_size(); i ++)
	{
		dstID = action->dst_ids(i);
		dstPlayer = engine->getPlayerEntity(dstID);
		dstPlayer->addCrossNum(action->args(i));
		GameInfo update_info;
		Coder::crossNotice(dstID, dstPlayer->getCrossNum(), update_info);
		engine->sendMessage(-1, MSG_GAME, update_info);
	}
	used_ShengLiao = true;
	addAction(ACTION_ATTACK_MAGIC, SHENG_LIAO);
	return GE_SUCCESS;
}
开发者ID:GaelClichy,项目名称:CodfiyAsteriatedGrailServer,代码行数:35,代码来源:ShengNv.cpp

示例4: readCollidingEntity

void SausageEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
  if (!isDying && !isAgonising && collideWithEntity(entity))
  {
    if (entity->getType() == ENTITY_PLAYER || entity->getType() == ENTITY_BOLT )
    {
      PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);
      BoltEntity* boltEntity = dynamic_cast<BoltEntity*>(entity);

      if (playerEntity != NULL && !playerEntity->isDead()) dying();

      else if (boltEntity != NULL && !boltEntity->getDying() && boltEntity->getAge() > 0.05f) collideWithBolt(boltEntity);
    }
    else // collision with other enemy ?
    {
      if (entity->getType() >= ENTITY_ENEMY && entity->getType() <= ENTITY_ENEMY_MAX)
      {
        if (this != entity)
        {
          EnemyEntity* enemyEntity = static_cast<EnemyEntity*>(entity);
          if (enemyEntity->canCollide()) collideWithEnemy(enemyEntity);
        }
      }
    }
  }
}
开发者ID:Cirrus-Minor,项目名称:witchblast,代码行数:26,代码来源:SausageEntity.cpp

示例5: ci

void BulletEntity::onPreSolveEvent(b2Contact * contact, const b2Manifold * oldManifold)
{
	ContactInfo ci(getBody(), contact);
	Entity * ent = (Entity*)ci.toucher->GetUserData();
	if (ent->getType() == EntityType::PlayerEntity)
	{
		PlayerEntity * ceEnt = (PlayerEntity*)ent;
		if (ceEnt == owner.getPlayerEntity().lock().get())
		{
			//Samego siebie nie krzywdzimy
			contact->SetEnabled(false);
			return;
		}
		else
		{
			//Innego gracza owszem
			if (ceEnt->getHealth() > 0.0)
			{
				ceEnt->takeDamage(damage);
				if (ceEnt->getHealth() == 0.0)
					owner.reportKill();
			}
		}
	}

	//Przy uderzeniu w cokolwiek innego niż gracz,
	//który nas wystrzelił, giniemy
	markForDeletion();
}
开发者ID:Tommalla,项目名称:zoldak,代码行数:29,代码来源:BulletEntity.cpp

示例6: ShenShengQiShi

int ShenGuan::ShenShengQiShi(int &step, int srcID)
{
	if(srcID != id){
		return GE_SUCCESS;
	}
	CommandRequest cmd_req;
	Coder::askForSkill(id, SHEN_SHENG_QI_SHI, cmd_req);
	int ret;
	//有限等待,由UserTask调用tryNotify唤醒
	if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req))
	{
		void* reply;
		if (GE_SUCCESS == (ret = engine->getReply(srcID, reply)))
		{
			Respond* respond = (Respond*) reply;
			//发动
			if(respond->args(0) == 1){
				network::SkillMsg skill;
				Coder::skillNotice(id, id, SHEN_SHENG_QI_SHI, skill);
				engine->sendMessage(-1, MSG_SKILL, skill);
				int dstID = id;
				PlayerEntity * dstPlayer = engine->getPlayerEntity(dstID);
				dstPlayer->addCrossNum(1);
				GameInfo update_info;
				Coder::crossNotice(dstID, dstPlayer->getCrossNum(), update_info);
				engine->sendMessage(-1, MSG_GAME, update_info);
			}
		}
		return ret;
	}
	else{
		//超时啥都不用做
		return GE_TIMEOUT;
	}
}
开发者ID:GaelClichy,项目名称:CodfiyAsteriatedGrailServer,代码行数:35,代码来源:ShenGuan.cpp

示例7: showTest

//测试用
void BackgroundEngine::showTest()
{
    PlayerEntity* player;
    char temp[500];
    QString tempStr;
    for(int i = 0;i < this->getPlayerNum();i++)
    {
        player = this->playerList.at(i);
        sprintf(temp,"player%d:\n",player->getID());
        tempStr.append(temp);

        for(int j = 0;j < player->getHandCardNum();j++)
        {

            tempStr.append(player->getHandCards().at(j)->getName());
            tempStr += QString::number(player->getHandCards().at(j)->getID());
            tempStr += " ";
        }
        tempStr += "\n";
    }

    sprintf(temp,"red team:%d\n",teamArea.getMorale(RED));
    tempStr.append(temp);
    sprintf(temp,"blue team:%d\n",teamArea.getMorale(BLUE));
    tempStr.append(temp);
    emit this->toInforDisplay(tempStr);
}
开发者ID:dreamStar,项目名称:Asteriated_Grail,代码行数:28,代码来源:BackGroundEngine.cpp

示例8: readCollidingEntity

void ItemEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
  if (itemType == ItemBossHeart && !game().getCurrentMap()->isCleared()) return;

  PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);

  if (collideWithEntity(entity))
  {
    if (playerEntity != NULL && !playerEntity->isDead())
    {
      if (isMerchandise)
      {
        playerEntity->setItemToBuy(this);
      }
      else if (canBePickedUp())
      {
        playerEntity->acquireItem(itemType);

        if (isMerchandise) playerEntity->pay(getPrice());

        dying();

        if (!items[itemType].generatesStance)
          new MagnetEntity(x, y, playerEntity, itemType);
      }
    }
  }
}
开发者ID:qw3ry,项目名称:witchblast,代码行数:28,代码来源:ItemEntity.cpp

示例9: readCollidingEntity

void SnakeEntity::readCollidingEntity(CollidingSpriteEntity* entity)
{
  if (!isDying && !isAgonising && collideWithEntity(entity))
  {
    if (entity->getType() == ENTITY_PLAYER || entity->getType() == ENTITY_BOLT )
    {
      PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(entity);
      BoltEntity* boltEntity = dynamic_cast<BoltEntity*>(entity);

      if (playerEntity != NULL && !playerEntity->isDead())
      {
        int meleeLevel = 0;
        if (snakeType == SnakeTypeBlood)
        {
          if (rand() % 3 == 0)
          {
            meleeType = ShotTypePoison;
            meleeDamages = 4;
            meleeLevel = 1;
          }
          else
          {
            meleeType = ShotTypeStandard;
            meleeDamages = 8;
          }
        }
        if (playerEntity->hurt(getHurtParams(meleeDamages, meleeType, meleeLevel, false, SourceTypeMelee, enemyType, false)))
        {
          float xs = (x + playerEntity->getX()) / 2;
          float ys = (y + playerEntity->getY()) / 2;
          SpriteEntity* star = new SpriteEntity(ImageManager::getInstance().getImage(IMAGE_HURT_IMPACT), xs, ys);
          star->setFading(true);
          star->setZ(y+ 100);
          star->setLifetime(0.7f);
          star->setType(ENTITY_EFFECT);
          star->setSpin(400.0f);
        }
        inflictsRecoilTo(playerEntity);
      }

      else if (boltEntity != NULL && !boltEntity->getDying() && boltEntity->getAge() > 0.05f)
      {
        collideWithBolt(boltEntity);
      }
    }
    else // collision with other enemy ?
    {
      if (entity->getType() >= ENTITY_ENEMY && entity->getType() <= ENTITY_ENEMY_MAX_COUNT)
      {
        if (this != entity)
        {
          EnemyEntity* enemyEntity = static_cast<EnemyEntity*>(entity);
          if (enemyEntity->canCollide()) collideWithEnemy(enemyEntity);
        }
      }
    }
  }
}
开发者ID:LibreGames,项目名称:witchblast,代码行数:58,代码来源:SnakeEntity.cpp

示例10: BodyIterator

void BodyIterator (const NewtonBody* body, void* userData)
{
    //Undvik att hantera kollision med sig själv
    if(NewtonBodyGetUserData(body)!=userData)
    {
        PlayerEntity* player = (PlayerEntity*)userData;
        player->UpdateCollision((NewtonBody*)body);
    }
}
开发者ID:scanberg,项目名称:engine,代码行数:9,代码来源:Entity.cpp

示例11: NewtonUpdate

void PlayerEntity::NewtonUpdate (float dt)
{
	// get the entity associated with this rigid body
	PlayerEntity* ent = PlayerEntity::player;

	ent->UpdatePhysics(SceneHandler::world,dt);

    ent->prevPosition = ent->curPosition;
    ent->curPosition = ent->matrix[3];
}
开发者ID:scanberg,项目名称:engine,代码行数:10,代码来源:Entity.cpp

示例12: inflictsRecoilTo

void RockMissileEntity::inflictsRecoilTo(BaseCreatureEntity* targetEntity)
{
  PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(targetEntity);

  if (playerEntity != NULL && !playerEntity->isDead())
  {
    Vector2D recoilVector = Vector2D(0, 0).vectorTo(getVelocity(), 600.0f );
    targetEntity->giveRecoil(true, recoilVector, 0.5f);
  }
}
开发者ID:LibreGames,项目名称:witchblast,代码行数:10,代码来源:RockMissileEntity.cpp

示例13: NianDan

int GeDou::NianDan(int step, int playerID)
{
	int ret;
	if(playerID != id || token[0] == tokenMax[0]){
		return GE_SUCCESS;
	}
	//满足发动条件,询问客户端是否发动
	CommandRequest cmd_req;
	Coder::askForSkill(id, NIAN_DAN, cmd_req);
	//有限等待,由UserTask调用tryNotify唤醒
	if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req))
	{
		void* reply;
		if (GE_SUCCESS == (ret = engine->getReply(id, reply)))
		{
			Respond* respond = (Respond*) reply;
			//发动
			if(respond->args(0)==1)
			{	
				int dstID = respond->dst_ids(0);
				PlayerEntity * dstPlayer = engine->getPlayerEntity(dstID);
				network::SkillMsg skill;
				Coder::skillNotice(id, dstID, NIAN_DAN, skill);
				engine->sendMessage(-1, MSG_SKILL, skill);
				setToken(0, token[0]+1);
				GameInfo game_info;
				Coder::tokenNotice(id, 0, token[0], game_info);
				engine->sendMessage(-1, MSG_GAME, game_info);
				if(dstPlayer->getCrossNum()==0)
				{
					HARM selfHarm;
					selfHarm.srcID = id;
					selfHarm.point = token[0];
					selfHarm.type = HARM_MAGIC;
					selfHarm.cause = NIAN_DAN;
					engine->setStateTimeline3(id, selfHarm);
				}
				HARM harm;
				harm.srcID = id;
				harm.point = 1;
				harm.type = HARM_MAGIC;
				harm.cause = NIAN_DAN;
				engine->setStateTimeline3(dstID, harm);
				return GE_URGENT;
			}
			//没发动技能
			return GE_SUCCESS;
		}
		return ret;
	}
	else{
		//超时啥都不用做
		return GE_TIMEOUT;
	}
}
开发者ID:GaelClichy,项目名称:CodfiyAsteriatedGrailServer,代码行数:55,代码来源:GeDou.cpp

示例14: inflictsRecoilTo

void CyclopsEntity::inflictsRecoilTo(BaseCreatureEntity* targetEntity)
{
  PlayerEntity* playerEntity = dynamic_cast<PlayerEntity*>(targetEntity);

  if (playerEntity != NULL && !playerEntity->isDead())
  {
    //Vector2D recoilVector = Vector2D(targetEntity->getX(), targetEntity->getY()).vectorTo(Vector2D(x, y), 450.0f);
    Vector2D recoilVector = Vector2D(x, y).vectorTo(Vector2D(targetEntity->getX(), targetEntity->getY()), 450.0f);
    targetEntity->giveRecoil(true, recoilVector, 0.5f);
  }
}
开发者ID:qw3ry,项目名称:witchblast,代码行数:11,代码来源:CyclopsEntity.cpp

示例15: ShuiZhiShenLi

int ShenGuan::ShuiZhiShenLi(int &step, Action* action)
{
	int cardID = action->card_ids(0);
	int dstID = action->dst_ids(0);
	PlayerEntity *dstPlayer = engine->getPlayerEntity(dstID);
	if(step == SHUI_ZHI_SHEN_LI)
	{
		SkillMsg skill_msg;
		Coder::skillNotice(id, dstID, SHUI_ZHI_SHEN_LI, skill_msg);
		engine->sendMessage(-1, MSG_SKILL, skill_msg);
		CardMsg show_card;
		Coder::showCardNotice(id, 1, cardID, show_card);
		engine->sendMessage(-1, MSG_CARD, show_card);
		engine->setStateMoveOneCardNotToHand(id, DECK_HAND, -1, DECK_DISCARD, cardID, id, SHUI_ZHI_SHEN_LI, true);
		step = SHUI_ZHI_SHEN_LI_GIVE;
		return GE_URGENT;
	}
	if(step == SHUI_ZHI_SHEN_LI_GIVE)
	{
		if(this->getHandCardNum() == 0)
		{
			addCrossNum(1);
			dstPlayer->addCrossNum(1);
			GameInfo update_info;
			Coder::crossNotice(id, getCrossNum(), update_info);
			Coder::crossNotice(dstID, dstPlayer->getCrossNum(), update_info);
			engine->sendMessage(-1, MSG_GAME, update_info);
			step = STEP_DONE;
			return GE_SUCCESS;
		}
		else
		{
			HARM shuishen;
			shuishen.cause = SHUI_ZHI_SHEN_LI;
			shuishen.point = 1;
			shuishen.srcID = id;
			shuishen.type = HARM_NONE;
			engine->pushGameState(new StateRequestHand(id, shuishen, dstID, DECK_HAND));
			step = SHUI_ZHI_SHEN_LI_CROSS;
			return GE_URGENT;
		}
	}
	if(step == SHUI_ZHI_SHEN_LI_CROSS)
	{
		addCrossNum(1);
		dstPlayer->addCrossNum(1);
		GameInfo update_info;
		Coder::crossNotice(id, getCrossNum(), update_info);
		Coder::crossNotice(dstID, dstPlayer->getCrossNum(), update_info);
		engine->sendMessage(-1, MSG_GAME, update_info);
		step = STEP_DONE;
		return GE_SUCCESS;
	}
}
开发者ID:GaelClichy,项目名称:CodfiyAsteriatedGrailServer,代码行数:54,代码来源:ShenGuan.cpp


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