예제 #1
0
void AFPSGCharacter::manageWeapon(AFPSGWeapon* in_weapon)
{
	bool weaponFound = isInInventory(in_weapon);

	//This weapon was found in the inventory, only add its ammunition
	if (weaponFound)
	{
		//GEngine->AddOnScreenDebugMessage(-1, 6.0f, FColor::Red, "weaponFound");

		AFPSGWeapon* weapon = findWeapon(in_weapon);

		if (weapon != NULL)
		{
			//GEngine->AddOnScreenDebugMessage(-1, 6.0f, FColor::Red, "Add ammunition");
			weapon->setCurrentAmmunition(weapon->getCurrentAmmunition() + in_weapon->getCurrentAmmunition());
		}
	}
	else //Otherwise, add the weapon
	{
		//GEngine->AddOnScreenDebugMessage(-1, 6.0f, FColor::Red, "weapon NOT found");

		//Spawn the weapon
		AFPSGWeapon* spawnedWeapon = spawnWeapon(in_weapon, FVector::ZeroVector, FRotator::ZeroRotator);

		//Disable the weapons collision component, attach to character and set to invisible, then add it to the inventory
		if (spawnedWeapon != NULL)
		{
			spawnedWeapon->getBoxCollisionComponent()->UnregisterComponent();
			spawnedWeapon->AttachRootComponentTo(GetMesh(), inventoryWeaponSocket, EAttachLocation::SnapToTarget);
			spawnedWeapon->SetActorHiddenInGame(true);
			addWeapon(spawnedWeapon);
		}
	}
}
예제 #2
0
파일: Player.cpp 프로젝트: oke-ya/cheeze
void Player::reset()
{
    PlayerBase::reset();
//    LocalNotification::getInstance()->setEnabled(true);
    auto& playData = getPlayData();
    ValueMap map;
    ValueVector vec;
    const std::vector<const char*> mapKeys = {CHARACTERS, WEAPONS};
    for(auto k: mapKeys){ playData[k] = map; }
    const std::vector<const char*> vecKeys = {};
    for(auto k: vecKeys){ playData[k] = vec; }
    const std::vector<const char*> intKeys = {RANK, TOTAL_BATTLE};
    for(auto k: intKeys){ playData[k] = 0; }
    for (auto& item : INITIAL_ITEMS) {
        auto itemId = item.first;
        auto count = item.second;
        addItem(itemId, count);
    }
    for (auto& map : INITIAL_CHARACTERS) {
        auto characterId = map.first;
        auto weaponId = map.second;
        addCharacter(characterId, weaponId);
        addWeapon(weaponId);
    }
    
    createGift("Opening1", ItemId::CHARGE, 5, "[はろくえ]ダウンロードありがとうプレゼント!!");
    createGift("Opening2", ItemId::SOUL, 1000, "[はろくえ]ダウンロードありがとうプレゼント!!");
    
    setVolume(100);
    setVolumeSE(100);
    setAudioId(-1);
    
    save();
}
예제 #3
0
///////////////////
// Receive the list
void CWpnRest::readList(CBytestream *psByteS)
{
    std::string szName;
    int nState;
    wpnrest_t *psWpn = NULL;

    // Initialize all the weapons to a default of 'enabled'
    reset();

    int nCount = psByteS->readInt(2);

    // Go through the list reading weapons
    for( int i=0; i<nCount; i++ ) {
        szName = psByteS->readString();
        nState = psByteS->readByte();

        // Try and find the weapon
        psWpn = findWeapon(szName);
        if( psWpn )
            psWpn->nState = nState;
        else {
            // If the weapon doesn't exist, thats ok
            // just add it to the list
            addWeapon(szName,nState);
        }
    }
}
예제 #4
0
///////////////////
// Load the weapons restrictions list
void CWpnRest::loadList(const std::string& szFilename, const std::string& moddir)
{
    // Shutdown the list first
    Shutdown();

    std::string fn = szFilename;
    if(!strCaseStartsWith(fn, "cfg/")) {
        if(fn.size() > 4 && !stringcaseequal(fn.substr(fn.size()-4), ".wps"))
            fn += ".wps";
        if(moddir != "" && IsFileAvailable("cfg/presets/" + moddir + "/" + fn))
            fn = "cfg/presets/" + moddir + "/" + fn;
        else
            fn = "cfg/presets/" + fn;
    }

    FILE *fp = OpenGameFile(fn, "rt");
    if( !fp )
        return;

    std::string line;

    while( !feof(fp) && !ferror(fp) ) {
        line = ReadUntil(fp, '\n');
        std::vector<std::string> exploded = explode(line,",");
        if (exploded.size() >= 2)
            addWeapon(exploded[0],from_string<int>(exploded[1]));
    }

    fclose(fp);

    // Sort the list
    sortList();
}
예제 #5
0
파일: MechPart.cpp 프로젝트: Forkast/BTech
void MechPart::setBase(const MechPartBase *base)
{
	clearData();
	this->base = base;
	armorValue = base->getMaxArmorValue();
	internalValue = base->getMaxInternalValue();
	for (const WeaponBase *weapon : base->getWeapons())
		addWeapon(new Weapon(weapon));
}
예제 #6
0
	void CWeaponsManager::process(const std::shared_ptr<CMessage>& message) {
		switch( message->getMessageType() ) {
			case Message::CHANGE_WEAPON: {
				std::shared_ptr<CMessageChangeWeapon> changeWeaponMsg = std::static_pointer_cast<CMessageChangeWeapon>(message);
				int iWeapon = changeWeaponMsg->getWeapon();

				//Si iWeapon no es scroll de rueda de ratón hacia adelante o hacia atrás, 
				//asignamos directamente el arma con el índice recibido
				if ((iWeapon != 100) && (iWeapon != -100)){
					changeWeapon(iWeapon);
				}
				else{
					//Obtenemos el índice del arma nueva al que se va a cambiar por el scroll
					iWeapon = selectScrollWeapon(iWeapon);
					if (iWeapon != -1)
						changeWeapon(iWeapon); //Si hemos obtenido arma, se la asignamos
				}
				break;
			}
			case Message::ADD_AMMO: {
				
				std::shared_ptr<CMessageAddAmmo> addAmmoMsg = std::static_pointer_cast<CMessageAddAmmo>(message);
				unsigned int weaponIndex = addAmmoMsg->getAddWeapon();
				_weaponry[weaponIndex].second->addAmmo(weaponIndex, addAmmoMsg->getAddAmmo(), _weaponry[weaponIndex].first);
				break;
			}
			case Message::ADD_WEAPON: {
				std::shared_ptr<CMessageAddWeapon> addWeaponMsg = std::static_pointer_cast<CMessageAddWeapon>(message);
				addWeapon( addWeaponMsg->getAddAmmo(), addWeaponMsg->getAddWeapon() );
				break;
			}
			case Message::REDUCED_COOLDOWN: {
				std::shared_ptr<CMessageReducedCooldown> cooldownMsg = std::static_pointer_cast<CMessageReducedCooldown>(message);
				reduceCooldowns( cooldownMsg->getPercentCooldown() );
				_cooldownTimer = cooldownMsg->getDuration();
				break;
			}
			case Message::DAMAGE_AMPLIFIER: {
				std::shared_ptr<CMessageDamageAmplifier> damageAmplifierMsg = std::static_pointer_cast<CMessageDamageAmplifier>(message);
				amplifyDamage( damageAmplifierMsg->getPercentDamage() );
				_dmgAmpTimer = damageAmplifierMsg->getDuration();
				break;
			}
		}

	} // process
예제 #7
0
Enemy::Enemy(int c_texture_id)
: MoveableObject()
, is_talking(false)
, is_invincible(false)
, is_attacking(false)
, time_invincible(sf::seconds(0.f))
, fade(0.8, 0.1)
, life(2)
, stop_time(sf::Time::Zero)
, die_explosion_effect(nullptr)
, current_weapon(nullptr)
{
	Entity::texture_id = c_texture_id;
	setSpeed(50, 0.75f);
	addWeapon(WeaponType::ObjectInHand, sf::Vector2f(12.5f, 25.f), 0.f, 0.5f, 1);
	key = "Enemy";

}
예제 #8
0
///////////////////
// Update the weapons list from a gamescript file
void CWpnRest::updateList(const std::vector<std::string> & weaponList)
{
    // Go through the weapons in the gamescript
    // If any weapon is not in our list, add it to the list
    int count = weaponList.size();
    int i;


    for(i=0; i<count; i++) {

        wpnrest_t *w = findWeapon( weaponList[i] );
        if( !w ) {
            // No match, add it to the list
            addWeapon( weaponList[i], wpr_enabled );
        }
    }

    // Sort the list
    sortList();
}