Beispiel #1
0
void ChangePartManager::changePart(SPersonMainPartChangeContext & context)
{
	//人物的主节点时异步加载的,其它的是同步加载的。

	//验证是否有效
	if( context.part <= EEntityPart_Invalid && context.part >= EEntityPart_Max) 
		return;

	switch( context.part)
	{
	case EEntityPart_Armet:
		changeArmet( context);
		break;
	case EEntityPart_Suit_Armet:
		changeSuitArmet( context);
		break;
	case EEntityPart_Armor:
		changeArmor( context);
		break;
	case EEntityPart_Suit_Armor:
		changeSuitArmet(context);
		break;
	case EEntityPart_Weapon:
		changeWeapon(context);
		break;
	default:
		m_CurrentPart[context.part] = context;
		break;
	}

	return;
}
Beispiel #2
0
	void CWeaponsManager::addWeapon(int ammo, int weaponIndex){
		// Si el arma dada no la teniamos, indicamos que ahora la tenemos
		if(weaponIndex < WeaponType::eSIZE && !_weaponry[weaponIndex].first)
			_weaponry[weaponIndex].first = true;

		// Activamos el componente pero indicamos que
		// no es el arma equipada.
		if(_currentWeapon != weaponIndex){
			_weaponry[weaponIndex].second->stayBusy();
//_weaponry[weaponIndex].second->inUse( false );
		}
		/*
		else{
			//_weaponry[weaponIndex].second->stayAvailable();
			//_weaponry[weaponIndex].second->inUse( true );
		}
		*/
		
		// El arma estara en uso si es la actual, si no estara sin uso
		
		_weaponry[weaponIndex].second->addAmmo(weaponIndex, ammo, _weaponry[weaponIndex].first);

		/*
		// Enviamos un mensaje de actualizacion del hud
		std::shared_ptr<CMessageHudAmmo> *m=std::make_shared<CMessageHudAmmo>();
		m->setWeapon(weaponIndex);
		m->setAmmo(ammo);//No es necesario esto, ya que solo actualizare el hud como que puedo coger el arma pero no mostrara sus balas(en este caso concreto)
		_entity->emitMessage(m);
		*/
		//si llevabamos la melee, cambiamos de melee al arma que acabamos de coger
		if(_currentWeapon == WeaponType::eSOUL_REAPER){
			changeWeapon(weaponIndex);
		}
	}
Beispiel #3
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
Beispiel #4
0
	void CHudWeapons::process(const std::shared_ptr<CMessage>& message) {
		switch( message->getMessageType() ) {
			case Message::CHANGE_WEAPON_GRAPHICS: {
				std::shared_ptr<CMessageChangeWeaponGraphics> chgWpnMsg = static_pointer_cast<CMessageChangeWeaponGraphics>(message);
				changeWeapon( chgWpnMsg->getWeapon() );
				break;
			}
		}
	} // process
Beispiel #5
0
void Game::Tick(){

  DInput->Poll();
  if(DInput->KeyPressed(DIK_F12) || DInput->KeyPressed(DIK_F11) ){
    consoleOn = 1 - consoleOn;
  }
  if(consoleOn){
    con.Tick();
    DInput->Clear();
  }

  GetLock();
  UpdateDeltaTime();

  
  Networks::getScene();
  if(nextWeapon != -1){
    weaponTimer -= DeltaTime*1000;
    if(weaponTimer < 0){
      weapon = nextWeapon;
      testplayer.weapon = weapon;
      nextWeapon = -1;
      testplayer.playhighAnim(RAISE);
      //ALERT;
    }
  }


  if( DInput->KeyPressed( DIK_C) ){
    thirdperson = 1-thirdperson;

    if(thirdperson){
      testplayer.addDrawList();
    }else{
      testplayer.removeDrawList();
    }
  }
  if( DInput->KeyPressed( DIK_F1 ) ) changeWeapon(0);
  if( DInput->KeyPressed( DIK_F2 ) ) changeWeapon(1);

  if( DInput->KeyPressed(DIK_F7)){
    ActiveCamera->Position = D3DXVECTOR3(0, 3000, 0);
  }
  if( DInput->KeyPressed(DIK_F5)){
    fstream file;
    file.open(L"save.txt", ios::out);

    file << ActiveCamera->Position[0] << " " 
         << ActiveCamera->Position[1] << " " 
         << ActiveCamera->Position[2] << "\n" ;
    
    file << ActiveCamera->Pitch<< " " 
         << ActiveCamera->Yaw << "\n" ;

    file.close();

    debug << "D3DXVECTOR3(" << ActiveCamera->Position[0] << "," 
         << ActiveCamera->Position[1] << "," 
         << ActiveCamera->Position[2] << ")," ;
    
  }
  if( DInput->KeyPressed( DIK_O ) ){
    side = 1-side; 
    testplayer.side = side;
  }

  if( DInput->KeyPressed(DIK_F6)){
    fstream file;
    file.open(L"save.txt", ios::in);
    file >> ActiveCamera->Position[0]
         >> ActiveCamera->Position[1]
         >> ActiveCamera->Position[2];

    
    file >> ActiveCamera->Pitch
         >> ActiveCamera->Yaw;


    file.close();

  }