• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Weapon类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: useEquipment

bool Fruit::useEquipment(Equipment *equipment, Entity *target)
{
    if (((equipment->getType() >= EQUIPMENT_TEA_SPOON) && (equipment->getType() <= EQUIPMENT_SALT_SNIPER)) || ((equipment->getType() == EQUIPMENT_JUICE_NEEDLE)))
    {
        Weapon *weapon = (Weapon*)equipment;
        return weapon->use(target);
    }
    else if (equipment->getType() == EQUIPMENT_PEELER)
    {
        Peeler *peeler = (Peeler*)equipment;
        return peeler->use(target);
    }
    else if (equipment->getType() == EQUIPMENT_RELOADER)
    {
        Loader *loader = (Loader*)equipment;
        return loader->use(target);
    }
    
    return false;
}
开发者ID:aurelien-defossez,项目名称:cod-open-world,代码行数:20,代码来源:Fruit.cpp


示例2: Ignore

void
NetPlayer::SetShip(Ship* s)
{
	if (ship != s) {
		if (ship) {
			ship->EnableRepair(true);
			Ignore(ship);
		}

		ship = s;

		if (ship) {
			Observe(ship);
			ship->SetNetworkControl(this);
			ship->SetObjID(objid);

			iff = ship->GetIFF();

			// Turn off auto-repair.  All repair data should
			// come in over the network from the remote player:

			ship->EnableRepair(false);

			// Set all ship weapons back to manual fire control.
			// All trigger events should come over the network,
			// not from weapon auto aiming ai:

			ListIter<WeaponGroup> iter = ship->Weapons();
			while (++iter) {
				WeaponGroup* group = iter.value();

				ListIter<Weapon> w_iter = group->GetWeapons();
				while (++w_iter) {
					Weapon* weapon = w_iter.value();

					weapon->SetFiringOrders(Weapon::MANUAL);
				}
			}
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:41,代码来源:NetPlayer.cpp


示例3: while

void CharacterCore::addSpell(SpellID id, int slotNr) {
	Weapon* wep = dynamic_cast<Weapon*>(m_equippedItems.at(ItemType::Equipment_weapon));
	if (wep == nullptr) return;
	if (!wep->isSpellAllowed(slotNr, id)) return;
	// check if this spell is already in another slot, if yes, remove that
	for (auto& it : m_data.equippedWeaponSlots) {
		if (it.first == id) {
			it.first = SpellID::VOID;
			it.second.clear();
		}
	}

	while (m_data.equippedWeaponSlots.size() - 1 < slotNr) {
		m_data.equippedWeaponSlots.push_back(std::pair<SpellID, std::vector<SpellModifier>>({SpellID::VOID, std::vector<SpellModifier>()}));
	}

	m_data.equippedWeaponSlots.at(slotNr).first = id;
	m_data.equippedWeaponSlots.at(slotNr).second.clear();

	reloadWeaponSlots();
}
开发者ID:StanislavGrinkov,项目名称:Cendric2,代码行数:21,代码来源:CharacterCore.cpp


示例4: main

int	main()
{
	{
		Weapon	club = Weapon("crude spiked club");
		HumanA	bob("Bob", club);

		bob.attack();
		club.setType("some other type of club");
		bob.attack();
	}
	{
		Weapon	club = Weapon("crude spiked club");
		HumanB	jim("Jim");

		jim.setWeapon(club);
		jim.attack();
		club.setType("some other type of club");
		jim.attack();
	}
	return 0;
}
开发者ID:z0mbie42,项目名称:42,代码行数:21,代码来源:main.cpp


示例5: fire

void Ship::fire(int weaponIndex)
{
	if (weaponIndex >= 0 && weaponIndex < (int)weapons_.size())
	{
		transform_->getMatrix(weaponTransformation_, false);

		//keeping weapon's local direction
		Weapon* weapon = weapons_[weaponIndex].first;
		weapon->currentDirection = weapon->direction;
		weapon->currentDirection.rotateVector(weaponTransformation_);

		//keeping weapon's local position
		Vector3 weaponPos = weapons_[weaponIndex].second;
		weaponPos.rotateVector(weaponTransformation_);
		weapon->position = transform_->getPosition() + weaponPos;

		weapon->fire();
	}
	else
		Logger::PrintWarning("Ship::fire - invalid argument\n");
}
开发者ID:haksist,项目名称:Chmo-engine,代码行数:21,代码来源:Ship.cpp


示例6: reloadWeaponSlots

void CharacterCore::addModifier(const SpellModifier& modifier, int slotNr)
{
	Weapon* wep = dynamic_cast<Weapon*>(m_equippedItems.at(ItemType::Equipment_weapon));
	if (wep == nullptr) return;
	if (wep->addModifier(slotNr, modifier, true))
	{
		std::pair<SpellID, std::vector<SpellModifier>>& slot = m_data.equippedWeaponSlots.at(slotNr);
		// check if this type already exists. if yes, remove it.
		for (auto& it = slot.second.begin(); it != slot.second.end(); /* don't increment here */)
		{
			if (it->type == modifier.type)
			{
				it = slot.second.erase(it);
			}
			else ++it;
		}
		
		slot.second.push_back(modifier);
	}
	reloadWeaponSlots();
}
开发者ID:G-GFFD,项目名称:Cendric2,代码行数:21,代码来源:CharacterCore.cpp


示例7: if

void SideScroller::Update(float elapsed) {
	if (state == STATE_TITLE)
	{
		return;
	}
	else if (state == STATE_GAME)
	{
		if (enemySpawnTimer > 0.8f && enemies.size() < 50) {
			Enemy* tempEnemy = new PewRunner(tex);
			tempEnemy->y = player->y + 4.0f;
			tempEnemy->x = player->x + 10.0f;
			tempEnemy->setScale(2.5f);
			if (genRandomNumber(0.0f, 1.0f) > 0.93f) {
				//Grant him knighthood
				tempEnemy->hp += 30;
				Weapon* weapon = new Weapon(tex);
				weapon->changeWeapon(SWORD);
				tempEnemy->equip(weapon);
				entities.push_back(weapon);
			}

			tempEnemy->setWalkLeft(0.8f);

			enemies.push_back(tempEnemy);
			entities.push_back(tempEnemy);
			
			enemySpawnTimer = genRandomNumber(0.0f, 0.75f);
		}

		for (size_t i = 0; i < entities.size(); i++) {
			entities[i]->Update(elapsed);
		}

		for (size_t i = 0; i < projectiles.size(); i++) {
			projectiles[i]->Update(elapsed);
		}

		enemySpawnTimer += elapsed;
	}
}
开发者ID:WilsonLiCode,项目名称:GamePro,代码行数:40,代码来源:SideScroller.cpp


示例8: do_zap

//do_zap: Perform a zap with a wand
bool do_zap()
{
    Coord delta;
    if (!get_dir(&delta))
        return false;

    Item *item = get_item("zap with", STICK);
    if (!item)
        return false;

    Stick* stick = dynamic_cast<Stick*>(item);
    Weapon* weapon = dynamic_cast<Weapon*>(item);
    if (!(stick || (weapon && weapon->is_vorpalized() && weapon->charges()))) {
        //mdk: zapping with non-stick doesn't count as turn
        msg("you can't zap with that!");
        return false;
    }

    // Handle the special case of a vorpalized weapon
    if (weapon) {
        game->screen().play_sound("zap");
        if (weapon->zap_vorpalized_weapon(delta)) {
            weapon->use_charge();
        }
        return true;
    }

    // Zap the appropriate stick
    if (stick->charges() == 0) {
        msg("nothing happens");
    }
    else{
        game->screen().play_sound("zap");
        if (stick->Zap(delta)) {
            stick->use_charge();
        }
    }

    return true;
}
开发者ID:mikeyk730,项目名称:Game-Rogue,代码行数:41,代码来源:sticks.cpp


示例9: Run

void Obstacle::Run(Weapon &weapon1,Player &player1,Weapon &weapon2,Player &player2)
{
    double b1x=weapon1.GetBullet()->x();
    double b1y=weapon1.GetBullet()->y();
    int p1x=player1.getX();
    int p1y=player1.getY();
    double b2x=weapon2.GetBullet()->x();
    double b2y=weapon2.GetBullet()->y();
    int p2x=player2.getX();
    int p2y=player2.getY();
    Draw(p1x,p1y,p2x,p2y);
    Move();
    CheckCollision(b1x,b1y,b2x,b2y);
    if (hstate1==1) {
        player1.health-=0.2;
        hstate1=0;
    }
    if (hstate2==1) {
        player2.health-=0.2;
        hstate2=0;
    }
    if (state1==1)
    {
        countdown+=0.9;
        if (countdown>1.2)
        {
            state1=0;
            countdown=0;
        }
    }
    if (state2==1)
    {
        countdown+=0.9;
        if (countdown>1.2)
        {
            state2=0;
            countdown=0;
        }
    }
}
开发者ID:javierchauvin,项目名称:EC,代码行数:40,代码来源:Obstacle.cpp


示例10: tryAddEffectsFromWeapon

void StatusEffectsHandler::tryAddEffectsFromWeapon(const Weapon& wpn, const bool IS_MELEE) {
  const ItemDefinition& wpnDef = wpn.getDef();
  StatusEffect* wpnEffect = IS_MELEE ? wpnDef.meleeStatusEffect : wpnDef.rangedStatusEffect;

  if(wpnEffect != NULL) {
    //Make a new copy of the weapon effect
    StatusEffect* cpy = wpnEffect->copy();

    //Attempt to add the effect to the actor.
    //If attempt fails (saving throw succeeds, immune, etc), the copy is destroyed.
    tryAddEffect(cpy);
  }
}
开发者ID:Justice-,项目名称:ia,代码行数:13,代码来源:StatusEffects.cpp


示例11: assert

void DebriefMenu::handleGameEvent(GameEvent evt) {
    if (evt.type_ == GameEvent::GE_SEARCH) {
        // A research has ended, so check which type
        Research *pRes = static_cast<Research *> (evt.pCtxt_);
         // Is it equipment or mods research?
         if (pRes->getType() == Research::EQUIPS) {
             // Get researched weapon type
             Weapon::WeaponType wt= pRes->getSearchWeapon();
             assert(wt);

             // Get weapon
             Weapon *pWeap = g_App.weapons().getWeapon(wt);
             assert(pWeap);

             // Draw name of it
             getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pWeap->getName());
         } else {
             // Must be mods research so draw it
             getStatic(txtSearchId_)->setTextFormated("#DEBRIEF_SEARCH", pRes->getName().c_str());
         }
    }
}
开发者ID:spippolatore,项目名称:freesynd,代码行数:22,代码来源:debriefmenu.cpp


示例12: while

bool
StarshipAI::AssessTargetPointDefense()
{
	if (Game::GameTime() - point_defense_time < 3500)
	return tgt_point_defense;

	tgt_point_defense = false;

	if (!target || target->Type() != SimObject::SIM_SHIP || GetAILevel() < 2)
	return tgt_point_defense;

	Ship* tgt_ship = (Ship*) target;

	if (!tgt_ship->IsStarship())
	return tgt_point_defense;

	Weapon*  subtgt = 0;
	Point    svec   = ship->Location() - tgt_ship->Location();

	point_defense_time = Game::GameTime();

	// first pass: turrets
	ListIter<WeaponGroup> g_iter = tgt_ship->Weapons();
	while (++g_iter && !tgt_point_defense) {
		WeaponGroup* g = g_iter.value();

		if (g->CanTarget(1)) {
			ListIter<Weapon> w_iter = g->GetWeapons();
			while (++w_iter && !tgt_point_defense) {
				Weapon* w = w_iter.value();

				if (w->Availability() > 35 && w->GetAimVector() * svec > 0)
				tgt_point_defense = true;
			}
		}
	}

	return tgt_point_defense;
}
开发者ID:lightgemini78,项目名称:Starshatter-Rearmed,代码行数:39,代码来源:StarshipAI.cpp


示例13: while

int
WeaponGroup::Status() const
{
    int status   = System::NOMINAL;
    int critical = true;

    ListIter<Weapon> iter = (List<Weapon>&) weapons; // cast-away const
    while (++iter) {
        Weapon* w = iter.value();

        if (w->Status() < System::NOMINAL)
            status = System::DEGRADED;

        if (w->Status() > System::CRITICAL)
            critical = false;
    }

    if (critical)
        return System::CRITICAL;

    return status;
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:22,代码来源:WeaponGroup.cpp


示例14: ASSERT

// Enter the state
void PlayerReloadingState::enter(PlayerUnit *ref)
{
	ASSERT(ref->getActualWeapon());

	Weapon *w = ref->getActualWeapon();

	// depending of the weapon, we will get the animation
	switch(w->getType()){
	case Weapon::W_SHORT:
		ref->changeAnimation(PlayerUnit::ANIM_RELOAD_SHORT);
		break;

	case Weapon::W_LONG:
		ref->changeAnimation(PlayerUnit::ANIM_RELOAD_LONG);
		break;

	default:
		ASSERT(false);
	}

	ASSERT(w->getAmmunition() > 0);
}
开发者ID:agudpp,项目名称:CordobaZombie,代码行数:23,代码来源:PlayerReloadingState.cpp


示例15: usesMeleeWeapons

void BasicMonster::useBestWeapon()
{
	bool melee = usesMeleeWeapons();
	bool ranged = usesRangedWeapons();
	int bestScore = -1;
	symbol bestWeapon = '\0';

	for (auto it = inventory.begin(); it != inventory.end(); it++)
	{
		if (it->second->getType() != ITEM_WEAPON) continue;
		Weapon* weapon = static_cast<Weapon*>(it->second);
		if (weapon->getRange() <= 1 && !melee) continue;
		if (weapon->getRange() > 1 && !ranged) continue;
		int score = scoreWeapon(weapon);
		if (score > bestScore)
		{
			bestScore = score;
			bestWeapon = it->first;
		}
	}

	mainWeapon = bestWeapon;
}
开发者ID:Zwergesel,项目名称:deadmeat,代码行数:23,代码来源:basicmonster.cpp


示例16: prevWeapon

void Ship::prevWeapon()
{
  weapon->stopShooting();
  int current = 0;
  for(int i = 0; i < weapons.size(); ++i)
  {
    if(weapons.at(i) == weapon)
    {
      current = i;
      break;
    }
  }

  for(int i = weapons.size() - 1; i > 0 ; --i)
  {
    Weapon* w = weapons.at((current + i) % weapons.size());
    if(w->getLevel() > 0)
    {
      weapon = w;
      break;
    }
  }
}
开发者ID:bzar,项目名称:spacerocks,代码行数:23,代码来源:ship.cpp


示例17: findComponents

//---------------------------------------------------------------------------
void Avatar::fireWeaponGroup(int /*groupId*/)
{
	// for now, fire everything
	ComponentList list;
	findComponents(EquipmentSlotComponent::getClassDef(), list);
	for (ComponentList::iterator it = list.begin(); it != list.end(); ++it)
	{
		EquipmentSlotComponent* pSlot = static_cast<EquipmentSlotComponent*>(*it);
		if (pSlot)
		{
			size_t numEquipment = pSlot->getNumEquipment();
			for (size_t i=0; i<numEquipment; ++i)
			{
				Mountable* pMountable = pSlot->getEquipment(i);
				if (pMountable && pMountable->isOfType(Weapon::getClassDef()))
				{
					Weapon* pWeapon = static_cast<Weapon*>(pMountable);
					pWeapon->fire();
				}
			}
		}
	}
}
开发者ID:nbtdev,项目名称:teardrop,代码行数:24,代码来源:Avatar.cpp


示例18: ExtractUuid

Entity *Message::ExtractEntity() {
  if (message_type_ == kEntityDataMessage ||
      message_type_ == kViewUpdateMessage) {
    boost::uuids::uuid source = ExtractUuid();
    std::string name = ExtractString();
    int health_value = ExtractInt();
    int health_bound = ExtractInt();
    BoundedAttribute health(health_value, health_bound);

    Entity *entity = new Entity(name, health);
    entity->AssignId(source);

    std::string weapon_name = ExtractString();
    int value = ExtractInt();
    int min_damage = ExtractInt();
    int max_damage = ExtractInt();
    Weapon *weapon = new Weapon(weapon_name, value, min_damage, max_damage);
    weapon->Equip(*entity);

    return entity;
  }

  return NULL;
}
开发者ID:ZadrraS,项目名称:Imp-Dungeon,代码行数:24,代码来源:message.cpp


示例19: getWeapon

GameObj* GOBox::shoot()
{
	if (getIsWeapon())
	{
		Weapon* w = getWeapon();

		if (getIsRangedWeapon()){
			
			if (((RangedWeapon *)w)->readyToShoot())
			{
				double rbDepth = getDepth() / 2 + ((RangedWeapon *)w)->getPDepth()/1.5 + 0.6f;
				btTransform* rbTrans = &getRigidBody()->getWorldTransform();
				btVector3 boxRot = rbTrans->getBasis()[2];
				boxRot.normalize();
				btVector3 correctedDisplacement = boxRot * -rbDepth; // /2
				double x = rbTrans->getOrigin().getX();// + 0.5 - w->getPWidth();
				double y = rbTrans->getOrigin().getY();
				double z = rbTrans->getOrigin().getZ() + correctedDisplacement.getZ();

				GameObj* proj = new Projectile(x, y, z, rbTrans->getRotation().getX(), rbTrans->getRotation().getY(), rbTrans->getRotation().getZ(), rbTrans->getRotation().getW(),
					((RangedWeapon *)w)->getPMass(), ((RangedWeapon *)w)->getPWidth(), ((RangedWeapon *)w)->getPHeight(), ((RangedWeapon *)w)->getPDepth());
				proj->setDamage(w->getDamage());
				//std::cout << "shoot: " << ((RangedWeapon *)w)->getPBlockType() << std::endl;
				proj->setBlockType(((RangedWeapon *)w)->getPBlockType());
				((RangedWeapon *)w)->setLastShot();
				((Projectile*)proj)->initForce = ((RangedWeapon *)w)->getPInitForce();


				return proj;
			}

		}

	}
	return nullptr;
}
开发者ID:RuiqingQiu,项目名称:CSE125,代码行数:36,代码来源:GOBox.cpp


示例20: Item

/// <summary>
/// Builder of the Weapons class use to copy
/// </summary>
/// <param> weaponToCopy: The weapon's to copy, what did you expected? </param>
Weapon::Weapon(const Weapon& weaponToCopy) : Item(*(weaponToCopy.m_name), *weaponToCopy.m_type, weaponToCopy.m_itemImagePath.at(0), weaponToCopy.m_price)
												, m_weaponsDamage(weaponToCopy.m_weaponsDamage), m_weaponsKnockback(weaponToCopy.m_weaponsKnockback)
{
	m_weaponType = new std::string(*weaponToCopy.m_weaponType);

	m_itemImagePath.push_back(weaponToCopy.m_itemImagePath.at(1));
	m_itemImagePath.push_back(weaponToCopy.m_itemImagePath.at(2));

	m_weaponsImage = new sf::Texture(*(weaponToCopy.m_weaponsImage));

	m_weaponsSprite = new sf::Sprite(*m_weaponsImage);
	m_weaponsSprite->setPosition(weaponToCopy.getWeaponSprite().getPosition());

	m_weaponsBox = new sf::FloatRect(m_weaponsSprite->getGlobalBounds());

	m_weaponsAnimationTime = new sf::Time(*(weaponToCopy.m_weaponsAnimationTime));
	m_weaponsKnockbackTime = new sf::Time(*(weaponToCopy.m_weaponsKnockbackTime));
	m_weaponCoolDownTime = new sf::Time(*(weaponToCopy.m_weaponCoolDownTime));
}
开发者ID:ChristophePigeon,项目名称:Mathematicia,代码行数:23,代码来源:Weapon.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WeaponsResource类代码示例发布时间:2022-05-31
下一篇:
C++ WeakReference类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap