Refactored Unit package a lot...

This commit is contained in:
Ognjen Milan Robovic 2024-05-21 11:14:17 -04:00
parent 94073bdd59
commit 388b039671
9 changed files with 73 additions and 64 deletions

View File

Before

Width:  |  Height:  |  Size: 840 B

After

Width:  |  Height:  |  Size: 840 B

View File

Before

Width:  |  Height:  |  Size: 876 B

After

Width:  |  Height:  |  Size: 876 B

View File

Before

Width:  |  Height:  |  Size: 837 B

After

Width:  |  Height:  |  Size: 837 B

View File

Before

Width:  |  Height:  |  Size: 836 B

After

Width:  |  Height:  |  Size: 836 B

View File

Before

Width:  |  Height:  |  Size: 836 B

After

Width:  |  Height:  |  Size: 836 B

View File

Before

Width:  |  Height:  |  Size: 851 B

After

Width:  |  Height:  |  Size: 851 B

View File

@ -11,9 +11,11 @@ package body unit is
view_width : constant integer := 48;
view_height : constant integer := 64;
sprite : array (enumeration) of core.sprite;
icon : array (enumeration) of core.sprite;
view : array (enumeration) of core.sprite;
base : array (faction.fairy .. faction.imp) of core.sprite;
--~sprite : array (enumeration) of core.sprite;
--~icon : array (enumeration) of core.sprite;
--~view : array (enumeration) of core.sprite;
------------------------------------------------------------------------------------------
@ -21,49 +23,42 @@ package body unit is
begin
core.echo (core.comment, "Configuring unit components...");
--
for index in enumeration loop
declare folder : constant string := core.lowercase (faction.enumeration'image (trait (index).kind));
file : constant string := core.lowercase (enumeration'image (index));
begin
sprite (index) := core.import_sprite (core.folder & "/game/unit/" & folder & "/" & file & ".png", 4, 6);
--~icon (index) := core.import_sprite (core.folder & "/icon/unit/" & folder & "/" & file & ".png", 1, 1);
--~view (index) := core.import_sprite (core.folder & "/view/unit/" & folder & "/" & file & ".png", 1, 1);
end;
for index in faction.fairy .. faction.imp loop
base (index) := core.import_sprite (core.folder & "/game/unit/" & core.lowercase (faction.enumeration'image (index)) & "/base.png", 4, 6);
end loop;
end configure;
------------------------------------------------------------------------------------------
procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is
begin
core.draw (sprite (index), x, y, state => state);
end draw;
--~procedure draw (index : in enumeration; state : in core.animation; x, y : in integer) is
--~begin
--~core.draw (sprite (index), x, y, state => state);
--~end draw;
------------------------------------------------------------------------------------------
procedure draw_icon (index : in enumeration; x, y : in integer) is
begin
ui.draw_overicon (icon (index), trait (index).text, x, y);
end draw_icon;
--~procedure draw_icon (index : in enumeration; x, y : in integer) is
--~begin
--~ui.draw_overicon (icon (index), trait (index).text, x, y);
--~end draw_icon;
------------------------------------------------------------------------------------------
procedure draw_view (index : in enumeration; x, y : in integer) is
offset : constant integer := 4;
begin
core.draw (view (index), x + offset, y + offset);
ui.draw_icon_menu (x, y, view_width + 2 * offset, view_height + 2 * offset);
end draw_view;
--~procedure draw_view (index : in enumeration; x, y : in integer) is
--~offset : constant integer := 4;
--~begin
--~core.draw (view (index), x + offset, y + offset);
--~ui.draw_icon_menu (x, y, view_width + 2 * offset, view_height + 2 * offset);
--~end draw_view;
------------------------------------------------------------------------------------------
procedure draw_full (index : in natural; x, y : in integer) is
limit : constant value_limit := value_limit (index);
procedure draw_full (index : in enumeration; state : in core.animation; x, y : in integer) is
begin
draw (values (limit).kind, values (limit).state, x, y);
core.draw (base (trait (index).kind), x, y, state => state);
--
for equipment_index in equipment.slot loop
equipment.draw (values (limit).equipments (equipment_index), values (limit).state, x, y);
for slot in equipment.slot loop
equipment.draw (trait (index).equipments (slot), state, x, y);
end loop;
end draw_full;

View File

@ -9,61 +9,74 @@ package unit is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type enumeration is (
dwarf_base, fairy_base, gnoll_base, goblin_base, imp_base, kobold_base
dwarf_berserker, dwarf_elite_berserker, dwarf_guard, dwarf_elite_guard
);
------------------------------------------------------------------------------------------
type information is record
name : core.short_string;
kind : faction.enumeration;
attributes : attribute.points;
evoke : effect.value;
text : core.long_string;
end record;
type value is record
name : core.short_string := "-- ";
kind : enumeration := imp_base;
state : core.animation := core.idle;
kind : faction.enumeration := faction.neutral;
attributes : attribute.points := (others => 0);
daily_fee : natural := 0;
equipments : equipment.equip_array := (others => equipment.none);
end record;
type value_limit is range 0 .. 90;
type value_array is array (value_limit) of value;
--~bone_chestplate, bronze_chestplate, chainmail_chestplate, crystal_chestplate, golden_chestplate, iron_chestplate,
--~leather_chestplate, mithril_chestplate, steel_chestplate, bone_greaves, bronze_greaves, chainmail_greaves,
--~crystal_greaves, golden_greaves, iron_greaves, leather_greaves, mithril_greaves, steel_greaves,
--~black_tunic, blue_tunic, cyan_tunic, green_tunic, grey_tunic, lime_tunic,
--~orange_tunic, pink_tunic, purple_tunic, red_tunic, white_tunic, yellow_tunic,
--~bone_gauntlets, bronze_gauntlets, chainmail_gauntlets, crystal_gauntlets, golden_gauntlets, iron_gauntlets,
--~leather_gauntlets, mithril_gauntlets, steel_gauntlets, bone_helmet, bronze_helmet, chainmail_helmet,
--~crystal_helmet, golden_helmet, iron_helmet, leather_helmet, mithril_helmet, steel_helmet,
--~bone_axe, bone_battleaxe, bone_bow, bone_mace, bone_spear, bone_sword,
--~bronze_axe, bronze_greatsword, bronze_mace, bronze_spear, bronze_sword, club,
--~crystal_bow, crystal_greatsword, crystal_mace, crystal_spear, crystal_sword, golden_axe,
--~golden_battleaxe, golden_bow, golden_greatsword, golden_sword, iron_axe, iron_bow,
--~iron_mace, iron_spear, iron_sword, jade_axe, jade_battleaxe, jade_greatsword,
--~jade_mace, jade_spear, jade_sword, maul, mithril_axe, mithril_battleaxe,
--~mithril_bow, mithril_mace, mithril_spear, sledge_hammer, spiked_club, spiked_staff,
--~staff, steel_battleaxe, steel_bow, steel_greatsword, steel_mace, steel_sword,
--~wooden_bow, wooden_greatsword, wooden_sword, golden_necklace, bronze_shield, crystal_shield,
--~golden_shield, iron_shield, mithril_shield, steel_shield, wooden_shield, wooden_armour,
--~fur_armour, fur_greaves, fur_gauntlets, red_hood, white_hood, wooden_helmet,
--~human_helmet, human_armour, elven_helmet, elven_armour, orcish_helmet, orcish_armour,
--~black_robe, cyan_robe, lime_dress, magenta_dress, orange_robe, pink_dress,
--~red_robe, sexy_dress, white_robe, lime_robe, orange_hood, fur_helmet,
--~black_hood, cyan_hood, lime_hood
--~full_body, head, chest, hands, feet, neck,
--~main_hand, off_hand
------------------------------------------------------------------------------------------
count : constant natural := enumeration'pos (enumeration'last) + 1;
trait : constant array (enumeration) of information := (
("Dwarf ", faction.dwarf, (others => 1), effect.none, " "),
("Fairy ", faction.fairy, (others => 1), effect.none, " "),
("Gnoll ", faction.gnoll, (others => 1), effect.none, " "),
("Goblin ", faction.goblin, (others => 1), effect.none, " "),
("Imp ", faction.imp, (others => 1), effect.none, " "),
("Kobold ", faction.kobold, (others => 1), effect.none, " ")
);
default_value : value;
values : value_array := (
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), (equipment.main_hand => equipment.mithril_axe, others => equipment.none)),
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), (equipment.main_hand => equipment.mithril_battleaxe, others => equipment.none)),
("Dwarf Berserker ", dwarf_base, core.idle, (3, 2, 1, 3, 2, 2), (equipment.main_hand => equipment.mithril_mace, others => equipment.none)),
--
others => default_value
("Dwarf Berserker ", faction.dwarf, (3, 2, 1, 3, 2, 2), 1, (
equipment.blue_tunic, equipment.leather_helmet, equipment.leather_chestplate, equipment.none,
equipment.leather_greaves, equipment.none, equipment.iron_axe, equipment.none)),
("Dwarf Elite Berserker ", faction.dwarf, (3, 2, 1, 3, 2, 2), 3, (
equipment.cyan_tunic, equipment.mithril_helmet, equipment.mithril_chestplate, equipment.leather_gauntlets,
equipment.leather_greaves, equipment.none, equipment.mithril_axe, equipment.none)),
("Dwarf Guard ", faction.dwarf, (3, 2, 1, 3, 2, 2), 4, (
equipment.cyan_tunic, equipment.steel_helmet, equipment.steel_chestplate, equipment.leather_gauntlets,
equipment.leather_greaves, equipment.none, equipment.steel_battleaxe, equipment.steel_shield)),
("Dwarf Elite Guard ", faction.dwarf, (3, 2, 1, 3, 2, 2), 6, (
equipment.cyan_tunic, equipment.steel_helmet, equipment.mithril_chestplate, equipment.steel_gauntlets,
equipment.steel_greaves, equipment.none, equipment.mithril_axe, equipment.steel_shield))
);
------------------------------------------------------------------------------------------
procedure configure;
procedure draw (index : in enumeration; state : in core.animation; x, y : in integer);
procedure draw_icon (index : in enumeration; x, y : in integer);
procedure draw_view (index : in enumeration; x, y : in integer);
procedure draw_full (index : in natural; x, y : in integer);
--~procedure draw (index : in enumeration; state : in core.animation; x, y : in integer);
--~procedure draw_icon (index : in enumeration; x, y : in integer);
--~procedure draw_view (index : in enumeration; x, y : in integer);
procedure draw_full (index : in enumeration; state : in core.animation; x, y : in integer);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -309,7 +309,8 @@ package body world is
--
for index in 1 .. unit_limit loop
if map.views (map.units (index).x, map.units (index).y) then
unit.draw_full (map.units (index).index,
unit.draw_full (unit.enumeration'val (map.units (index).index),
core.animation'val (map.units (index).state),
offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom,
offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom);
end if;