예제 #1
0
//------------------------------------------------------------------------------
void Player::setWeapon( const Weapon& iW )
{
	int i = getWeaponIndex( iW.getType() );
	if( i != -1 )
  { mWeaponBag[i] = iW; }
  else
  { mWeaponBag.push_back(iW); }
  mWeapon = iW;
}
예제 #2
0
//------------------------------------------------------------------------------
void Player::addWeaponToBag( const Weapon& iW)
{
	int i = getWeaponIndex( iW.getType() );
	if( i != -1 )
  {
//  	mWeaponBag[i].setNumberOfAmmo = mWeaponBag[i].getNumberOfAmmo() + 
//    	iW.getNumberOfAmmo();
  }
  else{ mWeaponBag.push_back( iW ); }
}
예제 #3
0
void Hero::addItem(Weapon weaponIn)
{
    if (weaponIn.getName().compare("none") != 0)
    {
        inventory.push_back(weaponIn);
        if (weaponIn.getType() == WEAPON)
        {
            weapon = weaponIn;
        }
    }
}
예제 #4
0
/**
 * When the button is left Pressed
 */
void WeaponBackpackItem::leftPressed(void)
{
	ASSERT(mOwner);
	ASSERT(mUserDef);

	// if the actual weapon of the player is this weapon, we do nothing
	if(mOwner->getActualWeapon() == mUserDef){
		// the same weapon, do nothing
		return;
	}
	// else set the actual weapon
	Weapon *w = static_cast<Weapon *>(mUserDef);
	mOwner->setWeapon(w->getType());
}
예제 #5
0
bool AttackState::onMessage(Character* agent, const Telegram& msg)
{
    switch (msg.msg) {
        case Msg_AttackedByWeapon:{//被玩家的武器攻击到
            log("Character::Msg_AttackedByWeapon");
            Weapon *weapon = (Weapon*)GameEntityManager::getInstance()->getEntityFromID(msg.sender);
            agent->takeDamage(weapon->getDamage());
            if (agent->getLife() <= 0) {
                agent->die();
                return false;
            }
            switch (weapon->getType()) {
                case WeaponTypeKnife:{
                    Knife *knife = (Knife*)weapon;
                    
                    KnifeAttackDirection direction = *(KnifeAttackDirection*)msg.extraInfo;
                    if (knife->isXuliStateDamage()) {
                        if (direction == KnifeAttackDirectionUp) {
                            agent->flowup();
                        }else if (direction == KnifeAttackDirectionDown) {
                            agent->falldown();
                        }else if (direction == KnifeAttackDirectionRight) {
                            agent->rollback();
                        }else{
                            agent->stiff();
                        }
                    }else{
                        agent->stiff();
                    }
                    
                }
                    break;
                    case WeaponTypePistol:
                    agent->stiff();
                    break;
                default:
                    break;
            }
        }
            break;
        default:
            break;
    }
    return false;
}
예제 #6
0
// 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);
}
예제 #7
0
파일: HumanA.cpp 프로젝트: lguard/cpp-p
void	HumanA::setWeapon(Weapon type)
{
	this->weapon.setType(type.getType());
}
예제 #8
0
Uint16 Erik::hit(Uint16 dir, Weapon& weap) {
    if (weap.getType()==W_WATER) {
        cancelEvent();
        return health;
    } else return Player::hit(dir,weap);
}