Exemplo n.º 1
0
void pd::player::take_damage(float val, damage_type type)
{
    switch (type) {
    case pd::entity::kinetic_damage:
        if (stance() == pd::entity::kinetic_stance) {
            m_energy = std::min(1.0f, m_energy + val / 150.0f);
            return;
        }
        break;
    case pd::entity::electromagnetic_damage:
        if (stance() == pd::entity::electromagnetic_stance) {
            m_energy = std::min(1.0f, m_energy + val / 300.0f);
            return;
        }
        break;
    case pd::entity::thermal_damage:
        if (stance() == pd::entity::thermal_stance) {
            m_energy = std::min(1.0f, m_energy + val / 100.0f);
            return;
        }
        break;
    }

    /* na, just damage like a human being */
    pd::entity::take_damage(val, type);
}
Exemplo n.º 2
0
pd::player::player(pd::game_session *session, float x, float y)
    : pd::entity(session, x, y, 60.0f, 90.0f, -20.0f, 20.0f, 0.0f, true),
      m_thermal_idle_anim(pd::get_resource<pd::texture>("textures/character_thermal_idle.png"), 17, 0.05f),
      m_flamethrower_anim(pd::get_resource<pd::texture>("textures/flamer.png"), 5, 0.1f)
{
    stance(thermal_stance);

    m_energy = 1.0f;
    health(200.0f);
    m_shooting = false;
    m_stoped = true;
}
Exemplo n.º 3
0
void pd::player::weapon_damage_test(float dt)
{
    if (!m_shooting)
        return;

    if (stance() == thermal_stance) {
        std::vector<pd::entity *> entities;
        visible_entities(200.0f, entities);
        for (std::vector<pd::entity *>::iterator iter = entities.begin();
             iter != entities.end(); ++iter)
            (*iter)->take_damage(500.0f * dt, pd::entity::thermal_damage);
    }
}
Exemplo n.º 4
0
	HudMainPanel::HudMainPanel(const FRect &rect) :HudLayer(rect) {
		float2 bottom_left(spacing, rect.height() - spacing);

		FRect char_rect(s_hud_char_icon_size);
		char_rect += bottom_left - float2(0, char_rect.height());

		FRect weapon_rect(s_hud_weapon_size);
		weapon_rect += float2(char_rect.max.x + spacing, bottom_left.y - weapon_rect.height());

		m_hud_char_icon = make_shared<HudCharIcon>(char_rect);
		m_hud_weapon = make_shared<HudWeapon>(weapon_rect);

		{
			FRect stance_rect(s_hud_stance_size);
			stance_rect += float2(weapon_rect.max.x + spacing, bottom_left.y - s_hud_stance_size.y);

			for(int n = 0; n < arraySize(s_stance_buttons); n++) {
				PHudButton stance(new HudRadioButton(stance_rect, (int)s_stance_buttons[n].stance_id, 1));
				stance->setIcon(s_stance_buttons[n].icon_id);
				m_hud_stances.push_back(std::move(stance));

				stance_rect += float2(0.0f, -s_hud_stance_size.y - spacing);
			}
		}

		{
			FRect button_rect = align(FRect(s_hud_button_size), char_rect, align_top, spacing);
			button_rect += float2(char_rect.min.x - button_rect.min.x, 0.0f);

			for(int n = 0; n < arraySize(s_buttons); n++) {
				PHudButton button(new HudToggleButton(button_rect, s_buttons[n].layer_id));
				button->setLabel(s_buttons[n].name);
				m_hud_buttons.emplace_back(std::move(button));
				button_rect += float2(button_rect.width() + spacing, 0.0f);
			}
		}

		attach(m_hud_weapon);
		attach(m_hud_char_icon);
		for(int n = 0; n < (int)m_hud_buttons.size(); n++)
			attach(m_hud_buttons[n]);
		for(int n = 0; n < (int)m_hud_stances.size(); n++)
			attach(m_hud_stances[n]);
	}