Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
GameDevWeek
Sommersemester 2019
Cpp
PhaseShifter
Commits
a8f92995
Commit
a8f92995
authored
Sep 19, 2019
by
Florian Oetke
Browse files
win condition
parent
8d29140a
Changes
8
Hide whitespace changes
Inline
Side-by-side
assets/game_assets/blueprints/
test_particle_emitter
.json
→
assets/game_assets/blueprints/
goal
.json
View file @
a8f92995
...
...
@@ -2,6 +2,7 @@
"Transform"
:{
"scale"
:
{
"x"
:
1.0
,
"y"
:
1.0
,
"z"
:
1.0
}
},
"Goal"
:
{},
"Particle_system"
:
{
"cfg"
:
"particle_sys:test_particles"
}
...
...
assets/game_assets/level/dummy.lvl
View file @
a8f92995
...
...
@@ -5,6 +5,6 @@ dummy
#| p h |#
#| |---- b |#
##----####| |#
##########| b
|#
##########| b
G
|#
###########-----##
##################
assets/game_assets/tilesets/dummy.json
View file @
a8f92995
...
...
@@ -34,6 +34,12 @@
"solid"
:
false
,
"spawn"
:
true
,
"spawns"
:
"basic_enemy"
},
"G"
:
{
"blueprint"
:
"dummy_floor"
,
"solid"
:
false
,
"spawn"
:
true
,
"spawns"
:
"goal"
}
}
}
src/gameplay/combat_system.cpp
View file @
a8f92995
#include
"combat_system.hpp"
#include
"goal_comp.hpp"
#include
"player_comp.hpp"
#include
"../messages.hpp"
#include
<mirrage/ecs/components/transform_comp.hpp>
#include
<mirrage/ecs/entity_set_view.hpp>
namespace
phase_shifter
::
gameplay
{
using
mirrage
::
ecs
::
components
::
Transform_comp
;
namespace
{
constexpr
auto
damage_beat_penalty
=
10
;
}
...
...
@@ -12,9 +20,10 @@ namespace phase_shifter::gameplay {
Combat_system
::
Combat_system
(
mirrage
::
util
::
Message_bus
&
bus
,
mirrage
::
ecs
::
Entity_manager
&
ecs
,
Beat_system
&
beats
)
:
_mailbox
(
bus
),
_ecs
(
ecs
),
_beat_system
(
beats
)
:
_bus
(
bus
),
_mailbox
(
bus
),
_ecs
(
ecs
),
_beat_system
(
beats
)
{
_ecs
.
register_component_type
<
Player_comp
>
();
_ecs
.
register_component_type
<
Goal_comp
>
();
_mailbox
.
subscribe_to
([
&
](
Damaged_msg
&
e
)
{
_ecs
.
get
(
e
.
entity
).
process
([
&
](
auto
&
entity
)
{
...
...
@@ -26,7 +35,18 @@ namespace phase_shifter::gameplay {
void
Combat_system
::
update
(
mirrage
::
util
::
Time
)
{
_mailbox
.
update_subscriptions
();
// TODO
if
(
_game_won
)
return
;
for
(
auto
&&
[
player_transform
,
p
]
:
_ecs
.
list
<
Transform_comp
,
Player_comp
>
())
{
for
(
auto
&&
[
transform
,
goal
]
:
_ecs
.
list
<
Transform_comp
,
Goal_comp
>
())
{
if
(
glm
::
distance2
(
player_transform
.
position
,
transform
.
position
)
<
1.
f
)
{
_game_won
=
true
;
_bus
.
send
<
Win_msg
>
();
}
}
}
}
}
// namespace phase_shifter::gameplay
src/gameplay/combat_system.hpp
View file @
a8f92995
...
...
@@ -24,9 +24,12 @@ namespace phase_shifter::gameplay {
void
update
(
mirrage
::
util
::
Time
);
private:
mirrage
::
util
::
Message_bus
&
_bus
;
mirrage
::
util
::
Mailbox_collection
_mailbox
;
mirrage
::
ecs
::
Entity_manager
&
_ecs
;
Beat_system
&
_beat_system
;
bool
_game_won
=
false
;
};
}
// namespace phase_shifter::gameplay
src/gameplay/goal_comp.cpp
0 → 100644
View file @
a8f92995
#include
"goal_comp.hpp"
src/gameplay/goal_comp.hpp
0 → 100644
View file @
a8f92995
#pragma once
#include
<mirrage/ecs/ecs.hpp>
#include
<mirrage/utils/sf2_glm.hpp>
#include
<mirrage/utils/units.hpp>
namespace
phase_shifter
::
gameplay
{
struct
Goal_comp
:
public
mirrage
::
ecs
::
Stateless_tag_component
<
Goal_comp
>
{
static
constexpr
const
char
*
name
()
{
return
"Goal"
;
}
using
Stateless_tag_component
::
Stateless_tag_component
;
};
}
// namespace phase_shifter::gameplay
src/meta_system.cpp
View file @
a8f92995
...
...
@@ -86,9 +86,6 @@ namespace phase_shifter {
});
_level_system
->
load
(
"dummy"
);
// TODO: remove
entities
().
entity_builder
(
"test_particle_emitter"
).
position
(
glm
::
vec3
(
11
,
0
,
11
)).
create
();
}
Meta_system
::~
Meta_system
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment