mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-05-25 15:49:42 +00:00
Adidng save, message and bye inputs of Mia
This commit is contained in:
+6
-2
@@ -64,9 +64,13 @@ void enemy_attack(gc_engine *engine, gc_entity *from, gc_entity *enemy);
|
||||
void load_attacks(gc_scene *scene);
|
||||
|
||||
|
||||
void mia_setup(gc_engine *engine);
|
||||
bool mia_heal(gc_engine *engine, gc_entity *entity, \
|
||||
gc_vector2 pos, enum gc_mousekeys key);
|
||||
void mia_setup(gc_engine *engine);
|
||||
bool mia_save(gc_engine *engine, gc_entity *entity, \
|
||||
gc_vector2 pos, enum gc_mousekeys key);
|
||||
bool mia_fish(gc_engine *engine, gc_entity *entity, \
|
||||
gc_vector2 pos, enum gc_mousekeys key);
|
||||
|
||||
void load_data(gc_scene *scene, const gc_data *datas);
|
||||
void load_data(gc_scene *scene, const gc_data *datas);
|
||||
extern const struct gc_data game_data[];
|
||||
@@ -13,6 +13,7 @@
|
||||
struct game_manager_system {
|
||||
gc_system base;
|
||||
bool is_inventory;
|
||||
bool has_message;
|
||||
};
|
||||
|
||||
const struct game_manager_system game_manager_system;
|
||||
|
||||
@@ -225,7 +225,7 @@
|
||||
<Mia line="Do you want something?" >
|
||||
<input text="Heal me" click="mia_heal" />
|
||||
<input text="Save game" click="mia_save" />
|
||||
<input text="Fisherman" click="mia_fisherman" />
|
||||
<input text="Message" click="mia_fish" />
|
||||
<input text="Bye" />
|
||||
</Mia>
|
||||
</dialog_holder>
|
||||
|
||||
@@ -66,7 +66,10 @@ bool dialog_parse_inputs(struct dialog_line *txt, gc_scene *scene, node *n)
|
||||
for (n = n->child; n; n = n->next) {
|
||||
txt->inputs[i].text = xml_getproperty(n, "text");
|
||||
click = xml_gettempprop(n, "click");
|
||||
txt->inputs[i].callback = scene->get_data(scene, "input", click);
|
||||
if (click)
|
||||
txt->inputs[i].callback = scene->get_data(scene, "input", click);
|
||||
else
|
||||
txt->inputs[i].callback = NULL;
|
||||
if (!txt->inputs[i++].callback && click)
|
||||
my_printf("Couldn't find an input with the name: %s.\n", click);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ const struct callback callbacks[] = {
|
||||
|
||||
const struct gc_data game_data[] = {
|
||||
{"input", "mia_heal", &mia_heal, NULL},
|
||||
{"input", "mia_save", &mia_save, NULL},
|
||||
{"input", "mia_fish", &mia_fish, NULL},
|
||||
{"dialog_callback", "mia_setup", &mia_setup, NULL},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
+36
-2
@@ -1,12 +1,13 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** my_rpg
|
||||
** my_rpg
|
||||
** File description:
|
||||
** mia.c
|
||||
*/
|
||||
|
||||
#include <components/health_component.h>
|
||||
#include <components/dialog_holder.h>
|
||||
#include <systems/game_manager_system.h>
|
||||
#include "engine.h"
|
||||
|
||||
struct dialog_holder *dialog_get_current(gc_engine *engine)
|
||||
@@ -46,4 +47,37 @@ any wounds.", NULL);
|
||||
here for that?", NULL);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
bool mia_save(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, "Mia", "Save the GAME?\n\
|
||||
What are you talking about?", NULL);
|
||||
dialog_add_line(dialog, "Mia", "Do you think this is a game?", NULL);
|
||||
dialog_add_line(dialog, "Mia", "We are dying for real here.\n\
|
||||
Go cure the village NOW.", NULL);
|
||||
return (true);
|
||||
}
|
||||
|
||||
bool mia_fish(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);
|
||||
if (!GETSYS(engine, game_manager_system)->has_message) {
|
||||
dialog_add_line(dialog, "", "You don't have any message\n\
|
||||
to give to Mia", NULL);
|
||||
return (true);
|
||||
}
|
||||
dialog_add_line(dialog, "Mia", "The fisherman?\n\
|
||||
Oh so he will come for dinner.", NULL);
|
||||
dialog_add_line(dialog, "Mia", "Than you for telling me!", NULL);
|
||||
return (true);
|
||||
}
|
||||
|
||||
@@ -51,9 +51,11 @@ float dtime)
|
||||
static void ctr(void *system, va_list list)
|
||||
{
|
||||
gc_engine *engine = va_arg(list, gc_engine *);
|
||||
|
||||
struct game_manager_system *this = system;
|
||||
|
||||
engine->add_event_listener(engine, "key_pressed", &key_pressed);
|
||||
this->has_message = false;
|
||||
this->is_inventory = false;
|
||||
}
|
||||
|
||||
static void dtr(void *system, gc_engine *engine)
|
||||
@@ -63,7 +65,7 @@ static void dtr(void *system, gc_engine *engine)
|
||||
|
||||
const struct game_manager_system game_manager_system = {
|
||||
base : {
|
||||
name: "game_cycle",
|
||||
name: "game_manager_system",
|
||||
component_name: "game_manager",
|
||||
size: sizeof(struct game_manager_system),
|
||||
ctr: &ctr,
|
||||
|
||||
Reference in New Issue
Block a user