Ejemplo n.º 1
0
void Game_Battler::ChangeHp(int hp) {
	if (!IsDead()) {
		SetHp(GetHp() + hp);

		// Death
		if (GetHp() <= 0) {
			AddState(RPG::State::kDeathID);
		}
	}
}
Ejemplo n.º 2
0
bool Player::HpDraw(coord_def offset_)
{
	d3dx_vprintf(offset_, 1.0f, D3DCOLOR_XRGB(150,150,255), "%2d", level);
	offset_.x+=30.0f;
	tex_system_heart.Draw(offset_.x, offset_.y, 1.0f, 0.0f);
	offset_.x+=30.0f;
	d3dx_vprintf(offset_, 1.0f, D3DCOLOR_XRGB(255,100,100), "%3d/%3d", GetHp()>0?GetHp():0, GetMaxHp());
	
	return true;
}
Ejemplo n.º 3
0
void Unit::update(float eTime) {
    Thing::update(eTime);

    //Status가 살아있고, HP가 0보다 작을 때, 죽은 상태로 전환한다.
    if( GetHp() <= 0 && IsAlive() ) {
        SetDead();
    }

    //유한 상태 기계
    m_pFSM->Update(eTime);

    //체력, 마나 리젠
    m_fHp += m_fHpRegen * eTime;
    m_fMp += m_fMpRegen * eTime;
    MathMgr->Clamp(m_fHp,0,m_fMaxHp);
    MathMgr->Clamp(m_fMp, 0, m_fMaxMp);

    //방향 설정한다.
    //dir : 0~360
    m_iPrevDir = m_iDir;
    float Angle = static_cast<float>( (acos(m_vHeading.dot(Vec2(1,0)))) *
                                      180.0f / MathMgr->Pi *
                                      m_vHeading.sign(Vec2(1, 0))) + 180;

    m_iDir = (int)(Angle / 22.5);
    MathMgr->Clamp(m_iDir, 0, 15);

    //유닛이 맵 전체에서 나가지 못하게 한다.
    //MathMgr->Clamp(_position.x,30,GAME_SCREEN_WIDTH-30);
    //MathMgr->Clamp(_position.y, 30, GAME_SCREEN_HEIGHT - 30);

}
Ejemplo n.º 4
0
DWORD  CBuild::SetValue(const char* strName, DWORD dwValue)
{
	if(strcmp(strName,"HP") == 0)
	{
        SetHp(dwValue);
		//GetGame()->GetCGuiEx()->GetCObjectPageEx()->UpdataObjInfo();
	}
    else if(strcmp(strName,"MAXHP") == 0)
	{
        SetMaxHp(dwValue);
		if(dwValue<GetHp())
		{
           SetHp(dwValue);
		}

		//GetGame()->GetCGuiEx()->GetCObjectPageEx()->UpdataObjInfo();
	}
    else if(strcmp(strName,"SWITCH") == 0)
	{
		//SetSwitch((bool)dwValue);
	}
    else if(strcmp(strName,"REFRESH") == 0)
	{
		SetHp(dwValue);
		//GetGame()->GetCGuiEx()->GetCObjectPageEx()->UpdataObjInfo();
	}
	return 1;
}
Ejemplo n.º 5
0
void Game_Actor::SetLevel(int _level) {
	GetData().level = min(max(_level, 1), GetMaxLevel());
	// Ensure current HP/SP remain clamped if new Max HP/SP is less.
	SetHp(GetHp());
	SetSp(GetSp());

}
Ejemplo n.º 6
0
void Game_Enemy::ChangeHp(int hp) {
	SetHp(GetHp() + hp);

	if (this->hp == 0) {
		// Death
		SetGauge(0);
		SetDefending(false);
		SetCharged(false);
		RemoveAllStates();
		AddState(1);
	} else {
		// Back to life
		RemoveState(1);
	}
}
Ejemplo n.º 7
0
void PlayerHpBar::SetFeedback()
{
	auto character = m_player->GetComponent<CharacterComponent>()->GetCharacter();
	int hp = character->GetHp();
	if (hp == m_lastHp) return;
	if (hp < 0) m_object->GetParent()->GetComponent<MainGame>()->AnnounceFinish(m_object->GetName());
	m_lastHp = hp;
	int maxHp = character->GetMaxHp();
	float perc = (float)hp / maxHp;

	auto sprite = m_greenBar->GetComponent<SpriteComponent>()->GetSprite();
	auto rect = sprite->getTextureRect();
	rect.width = (int)(m_barSize.x * perc);
	sprite->setTextureRect(rect);
}
Ejemplo n.º 8
0
bool Game_Enemy::IsActionValid(const RPG::EnemyAction& action) {
	if (action.kind == action.Kind_skill) {
		if (!IsSkillUsable(action.skill_id)) {
			return false;
		}
	}

	switch (action.condition_type) {
	case RPG::EnemyAction::ConditionType_always:
		return true;
	case RPG::EnemyAction::ConditionType_switch:
		return Game_Switches[action.switch_id];
	case RPG::EnemyAction::ConditionType_turn:
		{
			int turns = Game_Battle::GetTurn();
			return Game_Battle::CheckTurns(turns, action.condition_param2, action.condition_param1);
		}
	case RPG::EnemyAction::ConditionType_actors:
		{
			std::vector<Game_Battler*> battlers;
			GetParty().GetActiveBattlers(battlers);
			int count = (int)battlers.size();
			return count >= action.condition_param1 && count <= action.condition_param2;
		}
	case RPG::EnemyAction::ConditionType_hp:
		{
			int hp_percent = GetHp() * 100 / GetMaxHp();
			return hp_percent >= action.condition_param1 && hp_percent <= action.condition_param2;
		}
	case RPG::EnemyAction::ConditionType_sp:
		{
			int sp_percent = GetSp() * 100 / GetMaxSp();
			return sp_percent >= action.condition_param1 && sp_percent <= action.condition_param2;
		}
	case RPG::EnemyAction::ConditionType_party_lvl:
		{
			int party_lvl = Main_Data::game_party->GetAverageLevel();
			return party_lvl >= action.condition_param1 && party_lvl <= action.condition_param2;
		}
	case RPG::EnemyAction::ConditionType_party_fatigue:
		{
			int party_exh = Main_Data::game_party->GetFatigue();
			return party_exh >= action.condition_param1 && party_exh <= action.condition_param2;
		}
	default:
		return true;
	}
}
Ejemplo n.º 9
0
void cPlayer::Send_PlayerInfo()
{
	MyPlayerInfoAq* pInfo = (MyPlayerInfoAq*)PrepareSendPacket( sizeof( MyPlayerInfoAq ) );
	if( NULL == pInfo )
		return;
	pInfo->s_sType = MyPlayerInfo_Aq;
	pInfo->s_byDur = GetDur();
	pInfo->s_byLevel = GetLevel();
	pInfo->s_byStr = GetStr();
	pInfo->s_dwExp = GetExp();
	pInfo->s_dwHp = GetHp();
	pInfo->s_dwPKey = GetPKey();
	pInfo->s_dwPos = GetPos();
	strncpy( pInfo->s_szId , GetId() , MAX_ID_LENGTH );
	strncpy( pInfo->s_szName , GetName() , MAX_NAME_LENGTH );
	strncpy( pInfo->s_szNickName , GetNickName() , MAX_NICKNAME_LENGTH );
	SendPost( sizeof( MyPlayerInfoAq ) );
}
Ejemplo n.º 10
0
bool Player::Reload(Game_Manager * gm_)
{//³ªÁß¿¡ bulletÀÇ °¹¼ö¿¡ ÀÇÇؼ­ ¸®·ÎµùÇÏ°Ô ÇÏÀÚ
	if(current_weapon && current_weapon == main_weapon)
	{
		float need_bullet = 1.0f-((float)main_weapon->GetBullet()/(int)main_weapon->GetMaxBullet());
		if(need_bullet && bullet > 0.0f)
		{
			main_weapon->PlayReloadSE(gm_);
			need_bullet = min(need_bullet,bullet);
			bullet -= need_bullet;
			SetDelay(main_weapon->Reload(need_bullet));
		}
		else if(blood_reload && GetHp()>blood_reload)
		{
			main_weapon->PlayReloadSE(gm_);
			UpDownHp(-(int)(blood_reload*need_bullet+0.99f));
			SetDelay(main_weapon->Reload(need_bullet));
		}
	}
	return true;
}
Ejemplo n.º 11
0
void CCharacter::Attacked(CCharacter* chr, int damage, bool reflection) {
	char buffer[1024];
/*	
	AttackResult result = ATTACK_COUNT;
	switch (result)
	{
	case ATTACK_HIT:
			printf_s("-- %s는 공격에 (%d)의 피해를 입었다.\n", GetName().c_str(), damage);
			break;
	case ATTACK_MISS:                // 회피시에는 데미지가 없다.
			printf_s("-- %s는 공격을 피했다.\n", GetName().c_str());
			damage = 0;
			break;
	case ATTACK_GUARD:
			printf_s("-- 는 공격을 막았다. (%d)의 피해만 입었다.\n", GetName().c_str(), damage / 2);
			damage = damage / 2;
			break;        
	default:
			break;
	}
*/
	sprintf_s(buffer, "%s님이[%s]한테 %d데미지를 입혔습니다.",chr->GetName().c_str(), m_name.c_str(), damage );	
	CLog::Add(buffer);
	
	if(reflection)
		chr->Attacked(this, 3, false);

	MinusHp(chr, damage);
	
	if(chr->m_type != PC) {
		char buffer2[1024];
		sprintf_s(buffer2, "%s hp %5d / %5d", GetName().c_str(), GetHp(), GetMHp() );	
		CLog::AddMonsterLog(buffer2);
	}



}
Ejemplo n.º 12
0
bool Game_Battler::IsDead() const {
	return !IsHidden() && GetHp() == 0 && !IsImmortal();
}
Ejemplo n.º 13
0
void Game_Battler::Kill() {
	ChangeHp(-GetHp());
}
Ejemplo n.º 14
0
bool Game_Battler::HasFullHp() const {
	return GetMaxHp() == GetHp();
}
Ejemplo n.º 15
0
void Game_Battler::ChangeHp(int hp) {
	SetHp(GetHp() + hp);
}