More experimental unit stuff...
This commit is contained in:
parent
8a5bfd412d
commit
6fe24956a5
BIN
game/unit/elf/none.png
Normal file
BIN
game/unit/elf/none.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 B |
BIN
game/unit/human/none.png
Normal file
BIN
game/unit/human/none.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 B |
BIN
game/unit/neutral/none.png
Normal file
BIN
game/unit/neutral/none.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 B |
BIN
game/unit/orc/none.png
Normal file
BIN
game/unit/orc/none.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 B |
@ -2,7 +2,7 @@
|
||||
--
|
||||
-- GNU General Public Licence (version 3 or later)
|
||||
|
||||
with core, attribute, skill, resource, material, faction, equipment;
|
||||
with core, attribute, skill, resource, material, faction, equipment, unit;
|
||||
|
||||
package chad is
|
||||
|
||||
@ -16,7 +16,6 @@ package chad is
|
||||
|
||||
item_limit : constant natural := 24;
|
||||
skill_limit : constant natural := 8;
|
||||
--~unit_limit : constant natural := 8;
|
||||
|
||||
type item_array is array (0 .. item_limit - 1) of equipment.enumeration;
|
||||
|
||||
@ -45,8 +44,7 @@ package chad is
|
||||
equipments : equipment.equip_array := equipment.default;
|
||||
item_count : natural := 0;
|
||||
items : item_array := (others => equipment.none);
|
||||
--~unit_index : array (1 .. unit_limit) of unit.enumeration := (others => unit.none);
|
||||
--~unit_count : array (1 .. unit_limit) of natural := (others => 0);
|
||||
units : unit.points := (others => (others => <>));
|
||||
end record;
|
||||
|
||||
type informations is array (natural range <>) of information;
|
||||
|
@ -117,6 +117,11 @@ procedure main is
|
||||
equipment.feet => equipment.iron_greaves,
|
||||
equipment.main_hand => equipment.iron_sword,
|
||||
others => equipment.none),
|
||||
--
|
||||
units => ((unit.dwarf_villager, 12, 120),
|
||||
(unit.dwarf_knight, 3, 30),
|
||||
others => <>),
|
||||
--
|
||||
others => <>
|
||||
);
|
||||
|
||||
@ -235,6 +240,17 @@ procedure main is
|
||||
y => at_y + index_y * core.icon);
|
||||
end loop;
|
||||
end loop;
|
||||
--
|
||||
at_y := at_y + 3 * core.icon;
|
||||
--
|
||||
ui.draw_separator (at_x, at_y, width - 2 * offset);
|
||||
--
|
||||
at_y := at_y + core.base;
|
||||
--
|
||||
for index in 0 .. unit.limit - 1 loop
|
||||
world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8);
|
||||
ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon);
|
||||
end loop;
|
||||
end player_information;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
@ -327,7 +343,7 @@ begin
|
||||
|
||||
core.echo (core.comment, "Configuring" & unit.count'image & " unit components...");
|
||||
--
|
||||
for index in faction.fairy .. faction.imp loop
|
||||
for index in faction.enumeration loop
|
||||
unit.base (index) := core.import_sprite (core.folder & "/game/unit/" & core.lowercase (faction.enumeration'image (index)) & "/base.png", 4, 6);
|
||||
end loop;
|
||||
|
||||
|
@ -17,9 +17,13 @@ package unit is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
limit : constant natural := 8;
|
||||
count : constant natural := enumeration'pos (enumeration'last) + 1;
|
||||
|
||||
type definition is record
|
||||
name : access string := new string'("--");
|
||||
kind : faction.enumeration := faction.neutral;
|
||||
limit : natural := 0;
|
||||
attributes : attribute.bonus := (others => 0);
|
||||
hire_fee : natural := 0;
|
||||
weekly_fee : natural := 0;
|
||||
@ -27,6 +31,14 @@ package unit is
|
||||
equipments : equipment.equip_array := equipment.default;
|
||||
end record;
|
||||
|
||||
type point is record
|
||||
index : enumeration := none;
|
||||
value : natural := 0;
|
||||
limit : natural := 0;
|
||||
end record;
|
||||
|
||||
type points is array (0 .. limit - 1) of point;
|
||||
|
||||
--~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,
|
||||
@ -56,60 +68,58 @@ package unit is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
count : constant natural := enumeration'pos (enumeration'last) + 1;
|
||||
|
||||
description : constant array (enumeration) of definition := (
|
||||
none => (others => <>),
|
||||
--
|
||||
dwarf_villager => (new string'("Villager"), faction.dwarf, (2, 1, 1, 1, 2, 1), 2, 1, 1, (
|
||||
dwarf_villager => (new string'("Villager"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 2, 1, 1, (
|
||||
equipment.grey_tunic, equipment.none, equipment.none, equipment.none,
|
||||
equipment.none, equipment.none, equipment.club, equipment.none)),
|
||||
dwarf_miner => (new string'("Miner"), faction.dwarf, (2, 1, 1, 1, 2, 1), 2, 1, 1, (
|
||||
dwarf_miner => (new string'("Miner"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 2, 1, 1, (
|
||||
equipment.grey_tunic, equipment.none, equipment.none, equipment.fur_gauntlets,
|
||||
equipment.fur_greaves, equipment.none, equipment.pickaxe, equipment.none)),
|
||||
dwarf_blacksmith => (new string'("Blacksmith"), faction.dwarf, (2, 1, 1, 1, 2, 1), 3, 1, 2, (
|
||||
dwarf_blacksmith => (new string'("Blacksmith"), faction.dwarf, 90, (2, 1, 1, 1, 2, 1), 3, 1, 2, (
|
||||
equipment.grey_tunic, equipment.leather_helmet, equipment.none, equipment.leather_gauntlets,
|
||||
equipment.leather_greaves, equipment.none, equipment.sledge_hammer, equipment.none)),
|
||||
dwarf_hunter => (new string'("Hunter"), faction.dwarf, (2, 1, 1, 1, 2, 1), 3, 2, 2, (
|
||||
dwarf_hunter => (new string'("Hunter"), faction.dwarf, 90, (2, 1, 1, 1, 2, 1), 3, 2, 2, (
|
||||
equipment.grey_tunic, equipment.none, equipment.leather_chestplate, equipment.fur_gauntlets,
|
||||
equipment.fur_greaves, equipment.none, equipment.wooden_bow, equipment.none)),
|
||||
dwarf_bowman => (new string'("Bowman"), faction.dwarf, (2, 1, 1, 1, 2, 1), 5, 3, 2, (
|
||||
dwarf_bowman => (new string'("Bowman"), faction.dwarf, 90, (2, 1, 1, 1, 2, 1), 5, 3, 2, (
|
||||
equipment.blue_tunic, equipment.leather_helmet, equipment.iron_chestplate, equipment.none,
|
||||
equipment.leather_greaves, equipment.none, equipment.iron_bow, equipment.none)),
|
||||
dwarf_warrior => (new string'("Warrior"), faction.dwarf, (2, 1, 1, 1, 2, 1), 7, 3, 3, (
|
||||
dwarf_warrior => (new string'("Warrior"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 7, 3, 3, (
|
||||
equipment.blue_tunic, equipment.leather_helmet, equipment.iron_chestplate, equipment.leather_gauntlets,
|
||||
equipment.leather_greaves, equipment.none, equipment.iron_mace, equipment.wooden_shield)),
|
||||
dwarf_axeman => (new string'("Axeman"), faction.dwarf, (2, 1, 1, 1, 2, 1), 7, 3, 3, (
|
||||
dwarf_axeman => (new string'("Axeman"), faction.dwarf, 120, (2, 1, 1, 1, 2, 1), 7, 3, 3, (
|
||||
equipment.blue_tunic, equipment.leather_helmet, equipment.iron_chestplate, equipment.leather_gauntlets,
|
||||
equipment.leather_greaves, equipment.none, equipment.iron_axe, equipment.wooden_shield)),
|
||||
dwarf_crossbowman => (new string'("Crossbowman"), faction.dwarf, (2, 1, 1, 2, 2, 1), 7, 5, 3, (
|
||||
dwarf_crossbowman => (new string'("Crossbowman"), faction.dwarf, 90, (2, 1, 1, 2, 2, 1), 7, 5, 3, (
|
||||
equipment.blue_tunic, equipment.iron_helmet, equipment.iron_chestplate, equipment.leather_gauntlets,
|
||||
equipment.leather_greaves, equipment.none, equipment.light_crossbow, equipment.none)),
|
||||
dwarf_berserker => (new string'("Berserker"), faction.dwarf, (3, 2, 1, 3, 3, 1), 7, 3, 5, (
|
||||
dwarf_berserker => (new string'("Berserker"), faction.dwarf, 120, (3, 2, 1, 3, 3, 1), 7, 3, 5, (
|
||||
equipment.blue_pants, equipment.none, equipment.none, equipment.leather_gauntlets,
|
||||
equipment.leather_greaves, equipment.none, equipment.iron_axe, equipment.none)),
|
||||
dwarf_guard => (new string'("Guard"), faction.dwarf, (2, 3, 1, 3, 2, 1), 17, 5, 3, (
|
||||
dwarf_guard => (new string'("Guard"), faction.dwarf, 90, (2, 3, 1, 3, 2, 1), 17, 5, 3, (
|
||||
equipment.cyan_tunic, equipment.iron_helmet, equipment.iron_chestplate, equipment.leather_gauntlets,
|
||||
equipment.leather_greaves, equipment.none, equipment.iron_spear, equipment.iron_shield)),
|
||||
dwarf_elite_guard => (new string'("Elite Guard"), faction.dwarf, (3, 3, 1, 3, 2, 1), 23, 7, 2, (
|
||||
dwarf_elite_guard => (new string'("Elite Guard"), faction.dwarf, 90, (3, 3, 1, 3, 2, 1), 23, 7, 2, (
|
||||
equipment.cyan_tunic, equipment.mithril_helmet, equipment.mithril_chestplate, equipment.steel_gauntlets,
|
||||
equipment.steel_greaves, equipment.none, equipment.mithril_spear, equipment.steel_shield)),
|
||||
dwarf_war_druid => (new string'("War Druid"), faction.dwarf, (1, 1, 3, 1, 1, 1), 23, 3, 0, (
|
||||
dwarf_war_druid => (new string'("War Druid"), faction.dwarf, 60, (1, 1, 3, 1, 1, 1), 23, 3, 0, (
|
||||
equipment.black_robe, equipment.black_hood, equipment.mithril_chestplate, equipment.none,
|
||||
equipment.none, equipment.none, equipment.staff_of_earth, equipment.none)),
|
||||
dwarf_pig_rider => (new string'("Pig Rider"), faction.dwarf, others => <>), -- todo
|
||||
dwarf_boar_rider => (new string'("Boar Rider"), faction.dwarf, others => <>), -- todo
|
||||
dwarf_giant_mole_rider => (new string'("Giant Mole Rider"), faction.dwarf, others => <>), -- todo
|
||||
dwarf_siegebowman => (new string'("Siegebowman"), faction.dwarf, others => <>), -- todo
|
||||
dwarf_knight => (new string'("Knight"), faction.dwarf, (5, 3, 2, 3, 3, 1), 29, 7, 13, ( -- todo
|
||||
dwarf_pig_rider => (new string'("Pig Rider"), faction.dwarf, 30, others => <>), -- todo
|
||||
dwarf_boar_rider => (new string'("Boar Rider"), faction.dwarf, 30, others => <>), -- todo
|
||||
dwarf_giant_mole_rider => (new string'("Giant Mole Rider"), faction.dwarf, 30, others => <>), -- todo
|
||||
dwarf_siegebowman => (new string'("Siegebowman"), faction.dwarf, 60, others => <>), -- todo
|
||||
dwarf_knight => (new string'("Knight"), faction.dwarf, 60, (5, 3, 2, 3, 3, 1), 29, 7, 13, ( -- todo
|
||||
equipment.cyan_robe, equipment.mithril_helmet, equipment.mithril_chestplate, equipment.mithril_gauntlets,
|
||||
equipment.mithril_greaves, equipment.none, equipment.mithril_battleaxe, equipment.mithril_shield)),
|
||||
dwarf_flag_carrier => (new string'("Flag Carrier"), faction.dwarf, (5, 3, 2, 3, 5, 1), 29, 13, 0, (
|
||||
dwarf_flag_carrier => (new string'("Flag Carrier"), faction.dwarf, 10, (5, 3, 2, 3, 5, 1), 29, 13, 0, (
|
||||
equipment.cyan_robe, equipment.mithril_helmet, equipment.mithril_chestplate, equipment.mithril_gauntlets,
|
||||
equipment.mithril_greaves, equipment.none, equipment.mithril_mace, equipment.mithril_shield))
|
||||
);
|
||||
|
||||
base : array (faction.fairy .. faction.imp) of core.sprite;
|
||||
base : array (faction.enumeration) of core.sprite;
|
||||
--~icon : array (faction.fairy .. faction.imp) of core.sprite;
|
||||
--~view : array (faction.fairy .. faction.imp) of core.sprite;
|
||||
|
||||
|
@ -335,6 +335,10 @@ package body world is
|
||||
end loop;
|
||||
end if;
|
||||
--
|
||||
for index in 0 .. unit.limit - 1 loop core.io.write (file, unit.enumeration'pos (map.chads (1).units (index).index)); end loop;
|
||||
for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (1).units (index).value); end loop;
|
||||
for index in 0 .. unit.limit - 1 loop core.io.write (file, map.chads (1).units (index).limit); end loop;
|
||||
--
|
||||
core.io.close (file);
|
||||
--
|
||||
core.echo (core.success, "Saved current map as '" & file_name & "'.");
|
||||
@ -407,6 +411,10 @@ package body world is
|
||||
end loop;
|
||||
end if;
|
||||
--
|
||||
for index in 0 .. unit.limit - 1 loop core.io.read (file, this); map.chads (1).units (index).index := unit.enumeration'val (this); end loop;
|
||||
for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (1).units (index).value); end loop;
|
||||
for index in 0 .. unit.limit - 1 loop core.io.read (file, map.chads (1).units (index).limit); end loop;
|
||||
--
|
||||
core.io.close (file);
|
||||
--
|
||||
core.echo (core.success, "Loaded map from file '" & file_name & "'.");
|
||||
@ -1023,6 +1031,17 @@ package body world is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer) is
|
||||
begin
|
||||
core.draw (unit.base (unit.description (data).kind), x, y, state => state);
|
||||
--
|
||||
for kind in equipment.kind loop
|
||||
core.draw (equipment.sprite (unit.description (data).equipments (kind)), x, y, state => state);
|
||||
end loop;
|
||||
end draw_unit;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_units (offset, view_from, view_to : in core.vector) is
|
||||
time : float := 0.0;
|
||||
begin
|
||||
@ -1032,20 +1051,10 @@ package body world is
|
||||
if map.views (map.units (index).x, map.units (index).y)
|
||||
and map.units (index).x > view_from.x and map.units (index).x < view_from.x + view_to.x
|
||||
and map.units (index).y > view_from.y and map.units (index).y < view_from.y + view_to.y then
|
||||
core.draw (data => unit.base (unit.description (unit.enumeration'val (map.units (index).index)).kind),
|
||||
draw_unit (data => unit.enumeration'val (map.units (index).index),
|
||||
state => core.animation'val (map.units (index).state),
|
||||
x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom,
|
||||
state => core.animation'val (map.units (index).state));
|
||||
--
|
||||
for kind in equipment.kind loop
|
||||
if equipment.enumeration'pos (unit.description (unit.enumeration'val (map.units (index).index)).equipments (kind))
|
||||
/= equipment.enumeration'pos (equipment.none) then
|
||||
core.draw (data => equipment.sprite (unit.description (unit.enumeration'val (map.units (index).index)).equipments (kind)),
|
||||
x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom,
|
||||
y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom,
|
||||
state => core.animation'val (map.units (index).state));
|
||||
end if;
|
||||
end loop;
|
||||
y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom);
|
||||
--
|
||||
core.increment (drawn_units);
|
||||
end if;
|
||||
|
@ -229,6 +229,8 @@ package world is
|
||||
|
||||
procedure add_chad (data : in chad.information);
|
||||
|
||||
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y : in integer);
|
||||
|
||||
procedure resource_cheat_1;
|
||||
procedure resource_cheat_2;
|
||||
procedure resource_cheat_3;
|
||||
|
Loading…
Reference in New Issue
Block a user