Exemplo n.º 1
0
void Chest::ExamineUnit(ui::Gui &table, const Point &start, const Point &range) const
{
    Point nameplate = start.Moved(Point(1, 0));
    // name
    table.SetTextColor(Color(1, 1, 1));
    table.Write(nameplate, "Chest");
    table.Write(nameplate.Moved(Point(0, 2)), "Press E");
    table.Write(nameplate.Moved(Point(0, 3)), "to loot");
}
Exemplo n.º 2
0
void Actor::ExamineUnit(ui::Gui &table, const Point &start, const Point &range) const
{
	Point nameplate = start.Moved(Point(1, 0));
	Point hp = start.Moved(Point(1, 2));
	Point mp = start.Moved(Point(1, 4));
	Point effect_position = start.Moved(Point(1, 6));

	// name

	Name name = GetName();
	if (name.length() > 0)
	{
		table.SetTextColor(Color(1, 1, 1));
		table.Write(nameplate, name);
	}

	// bars
	int bar_length = range.X - 2;
	int current_health = GetCurrentHealth();
	int max_health = GetMaximumHealth();
	int current_energy = GetCurrentEnergy();
	int max_energy = GetMaximumEnergy();

	max_health = (max_health == 0) ? 1 : max_health;
	max_energy = (max_energy == 0) ? 1 : max_energy;

	int green = bar_length * current_health / max_health;
	green = (green == 0 && current_health > 0) ? 1 : green;
	green = (green < 0) ? 0 : green;

	int blue = bar_length * current_energy / max_energy;
	blue = (blue == 0 && current_energy > 0) ? 1 : blue;
	blue = (blue < 0) ? 0 : blue;

	table.Rectangle(hp, Point(green, 1), 0x085200);
	table.Rectangle(hp.Moved(Point(green, 0)), Point(bar_length - green, 1), 0x642800);
	table.Rectangle(mp, Point(blue, 1), 0x6b839c);
	table.Rectangle(mp.Moved(Point(blue, 0)), Point(bar_length - blue, 1), 0xf0bf9f);

	table.SetTextColor(0x1f0c00);
	table.WriteInteger(hp.Moved(Point(bar_length - 1, 0)), current_health);
	table.WriteInteger(mp.Moved(Point(bar_length - 1, 0)), current_energy);
	table.Write(hp.Moved(Point(1, 0)), "HP");
	table.Write(mp.Moved(Point(1, 0)), "EP");

	// effects

	table.SetTextColor(Color(1, 1, 1));
	for (auto i = _effects.cbegin(); i != _effects.cend(); ++i)
	{
		table.Write(effect_position, i->GetName());
		effect_position.Y += 2;
	}
}