marge and adding the dialog for the sage

This commit is contained in:
Clément Le Bihan
2020-05-01 17:51:49 +02:00
11 changed files with 104 additions and 20 deletions
+1 -1
View File
@@ -298,7 +298,7 @@ add_executable(my_rpg
include/components/attack_component.h
src/systems/combat_methods.c
src/combat/attacks.c
src/player_utilities.c include/player_utilities.h src/systems/inventory.c include/systems/inventory.h src/systems/game_over.c include/systems/game_over.h src/npc/mia.c lib/gamacon/src/scene/scene_constructor.c)
src/player_utilities.c include/player_utilities.h src/systems/inventory.c include/systems/inventory.h src/systems/game_over.c include/systems/game_over.h src/npc/mia.c lib/gamacon/src/scene/scene_constructor.c src/npc/fisherman.c)
add_compile_options(-W -Wall -Wextra -Wshadow)
+2 -1
View File
@@ -42,7 +42,8 @@ SRC = src/main.c \
src/player_utilities.c \
src/systems/inventory.c \
src/systems/game_over.c \
src/npc/mia.c
src/npc/mia.c \
src/npc/fisherman.c
OBJ = $(SRC:%.c=%.o)
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

+1
View File
@@ -50,5 +50,6 @@ void dialog_next(gc_engine *engine);
struct dialog_line *dialog_add_line(struct dialog_holder *this, char *name, \
char *text, struct dialog_input *inputs);
void show_dialog_if_hidden(gc_engine *engine);
struct dialog_holder *dialog_get_current(gc_engine *engine);
#endif //MY_RPG_DIALOG_HOLDER_H
+4
View File
@@ -72,5 +72,9 @@ gc_vector2 pos, enum gc_mousekeys key);
bool mia_fish(gc_engine *engine, gc_entity *entity, \
gc_vector2 pos, enum gc_mousekeys key);
void fisherman_setup(gc_engine *engine);
bool fisherman_next(gc_engine *engine, gc_entity *entity, \
gc_vector2 pos, enum gc_mousekeys key);
void load_data(gc_scene *scene, const gc_data *datas);
extern const struct gc_data game_data[];
+40 -7
View File
@@ -146,6 +146,7 @@
<sprite name="mayor" src="assets/sprites/npc/mayor.png" />
<sprite name="mia" src="assets/sprites/npc/mia.png" />
<sprite name="sage" src="assets/sprites/npc/sage.png" />
<sprite name="fisherman" src="assets/sprites/npc/fisherman.png" />
<enemies>
<enemy name="bee" src="prefabs/enemies/bee.gcprefab" spawn_rate="17%" />
@@ -237,6 +238,26 @@
</dialog_holder>
</gc_entity>
<gc_entity>
<transform_component>
<Position x="0" y="0" />
<Size x="70" y="90" />
</transform_component>
<renderer src="fisherman">
<Rect height="32" width="24" top="64" left="24" />
</renderer>
<map_linker x="15" y="51" />
<dialog_holder x="15" y="50" tile_texture="npc_interact">
<Fisherman line="Hello dear hero!\nI caught some fish for you." />
<Fisherman line="Do you want some?" callback="fisherman_setup" >
<input text="Yes" click="fisherman_next" />
<input text="Of course" click="fisherman_next" />
<input text="No" />
<input text="Bye" />
</Fisherman>
</dialog_holder>
</gc_entity>
<gc_entity>
<transform_component>
<Position x="0" y="0" />
@@ -245,16 +266,28 @@
<renderer src="sage">
<Rect height="32" width="24" top="64" left="24" />
</renderer>
<map_linker x="39" y="30" />
<map_linker x="39" y="30" centered="true" />
<dialog_holder x="39" y="29" tile_texture="npc_interact">
<Sage line="Nice to meet you !" />
<Sage line="I will explain to you the legends\n and secrets of this village" />
<Sage line="There are 4 legendary items, \none for each attack you can perform in combat." />
<Sage line="First the fireball upgrade, \nits majestic fire wand c" />
<Sage line="This weapon makes your fireball attack stronger" />
<Sage line="Second the Water Jet update, \nthis wand was." />
<Sage line="The third item is uppercut upgrade ,\nthose gante" />
<Sage line="The fourth and final item is the,\n HERO shield is d" />
<Sage line="There are 4 legendary items, \n one for each attack" />
<Sage line="you can perform in combat." />
<Sage line="First the fireball upgrade, \nits majestic fire wand created by" />
<Sage line="the sorcerer 'Perry the platypus'" />
<Sage line="This weapon makes your \nfireball attack stronger" />
<Sage line="Second, the Water Jet update, \nthis wand was used during the" />
<Sage line="great war of Hyrule by \nPrincess Mipha." />
<Sage line="This weapon makes your \nWater Jet attack stronger" />
<Sage line="The third item is the uppercut \nupgrade, those gantlets belonged" />
<Sage line=" to Dedue Molinaro a great \nwarrior of the Blue lion house" />
<Sage line="This weapon makes your \nUppercut attack stronger" />
<Sage line="The fourth and final item \nis the HERO shield" />
<Sage line="he's the twin shield of \nthe well konwn hylian shield" />
<Sage line="This weapon makes your \nShield defence stronger" />
</dialog_holder>
</gc_entity>
+8 -5
View File
@@ -79,17 +79,20 @@ bool dialog_parse_inputs(struct dialog_line *txt, gc_scene *scene, node *n)
struct dialog_line *dialog_parse_text(gc_scene *scene, node *n)
{
struct dialog_line *txt = malloc(sizeof(struct dialog_line));
char *callback;
char *clb;
if (!txt)
return (NULL);
txt->name = my_strdup(n->name);
txt->text = xml_getproperty(n, "line");
txt->input_count = xml_getchildcount_filtered(n, "input");
callback = xml_gettempprop(n, "callback");
txt->callback = scene->get_data(scene, "dialog_callback", callback);
if (callback && !txt->callback)
my_printf("Couldn't find an callback with the name: %s.\n", callback);
clb = xml_gettempprop(n, "clb");
if (clb) {
txt->callback = scene->get_data(scene, "dialog_callback", clb);
if (!txt->callback)
my_printf("Couldn't find an clb with the name: %s.\n", clb);
} else
txt->callback = NULL;
txt->inputs = NULL;
if (txt->input_count == 0)
return (txt);
+7
View File
@@ -32,4 +32,11 @@ struct dialog_input *inputs)
this->text[count] = line;
this->text[count + 1] = NULL;
return (line);
}
struct dialog_holder *dialog_get_current(gc_engine *engine)
{
struct dialog_manager *manager = GETSYS(engine, dialog_manager);
return (manager->current_dialog);
}
+2
View File
@@ -58,6 +58,8 @@ const struct gc_data game_data[] = {
{"input", "mia_save", &mia_save, NULL},
{"input", "mia_fish", &mia_fish, NULL},
{"dialog_callback", "mia_setup", &mia_setup, NULL},
{"dialog_callback", "fisherman_setup", &fisherman_setup, NULL},
{"input", "fisherman_next", &fisherman_next, NULL},
{NULL, NULL, NULL, NULL}
};
+39
View File
@@ -0,0 +1,39 @@
/*
** EPITECH PROJECT, 2020
** my_rpg
** File description:
** fisherman.c
*/
#include "components/dialog_holder.h"
#include "systems/game_manager_system.h"
#include "engine.h"
void fisherman_setup(gc_engine *engine)
{
struct dialog_holder *holder = dialog_get_current(engine);
holder->text[2] = NULL;
}
bool fisherman_next(gc_engine *engine, gc_entity *entity, \
gc_vector2 pos, enum gc_mousekeys key)
{
struct dialog_holder *dialog = dialog_get_current(engine);
if (!dialog)
return (false);
dialog_add_line(dialog, "Fisherman", "Sometimes I catch \
fishes with\na strange ability:", NULL);
dialog_add_line(dialog, "Fisherman", "they can throw a powerful Water\n\
Jet at their enemies.", NULL);
dialog_add_line(dialog, "Fisherman", "This kind of fish seems \
to come from the\nsource of the river, something must be there.", NULL);
dialog_add_line(dialog, "Fisherman", "You should check it out!", NULL);
dialog_add_line(dialog, "Fisherman", "If you pass nearby Mia, tell her\n\
that I will show up at...", NULL);
dialog_add_line(dialog, "Fisherman", "her house for dinner tonight.", NULL);
GETSYS(engine, game_manager_system)->has_message = true;
return (true);
}
-6
View File
@@ -10,12 +10,6 @@
#include <systems/game_manager_system.h>
#include "engine.h"
struct dialog_holder *dialog_get_current(gc_engine *engine)
{
struct dialog_manager *manager = GETSYS(engine, dialog_manager);
return (manager->current_dialog);
}
void mia_setup(gc_engine *engine)
{