YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Pokemon.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Game/Pokemon/Pokemon.hpp
"
2
#include "
YAPOG/Graphics/Game/Sprite/Sprite.hpp
"
3
#include "
YAPOG/System/StringHelper.hpp
"
4
#include "
YAPOG/Game/Factory/XmlObjectIDLoader.hpp
"
5
#include "
YAPOG/Game/Factory/ObjectFactory.hpp
"
6
#include "
YAPOG/Game/Pokemon/PokemonMoveSet.hpp
"
7
#include "
YAPOG/Audio/AudioManager.hpp
"
8
9
#include "Pokemon/Pokemon.hpp"
10
#include "Pokemon/PokemonInfo.hpp"
11
12
namespace
ycl
13
{
14
Pokemon::Pokemon
(
const
yap::ID
& staticID)
15
: yap::
Pokemon
(staticID)
16
, icon_ (nullptr)
17
, genderIcon_ (nullptr)
18
, battleBack_ (nullptr)
19
, battleFront_ (nullptr)
20
, type1Icon_ (nullptr)
21
, type2Icon_ (nullptr)
22
{
23
Init
();
24
}
25
26
Pokemon::Pokemon
(
27
const
yap::ID
& staticID,
28
const
yap::UInt16
& level,
29
const
bool
& shiny)
30
: yap::
Pokemon
(staticID, level, shiny)
31
, icon_ (nullptr)
32
, genderIcon_ (nullptr)
33
, battleBack_ (nullptr)
34
, battleFront_ (nullptr)
35
, type1Icon_ (nullptr)
36
, type2Icon_ (nullptr)
37
{
38
Init
();
39
}
40
41
Pokemon::Pokemon
(
42
const
yap::ID
& uniqueID,
43
const
yap::ID
& staticID,
44
const
yap::String
& trainerName,
45
const
yap::String
& nickname,
46
const
yap::PokemonStat
& stats,
47
const
yap::Gender& gender,
48
const
yap::PokemonStatus& status,
49
const
bool
shiny,
50
const
yap::Int16
& loyalty,
51
const
yap::PokemonMoveSet
& moveSet,
52
const
yap::ID
& natureID,
53
const
yap::uint
& exp,
54
const
yap::UInt8
& boxNumber,
55
const
yap::ID
& boxIndex,
56
const
yap::String
& catchDate)
57
: yap::
Pokemon
(
58
uniqueID,
59
staticID,
60
trainerName,
61
nickname,
62
stats,
63
gender,
64
status,
65
shiny,
66
loyalty,
67
moveSet,
68
natureID,
69
exp,
70
boxNumber,
71
boxIndex,
72
catchDate)
73
, icon_ (nullptr)
74
, genderIcon_ (nullptr)
75
, battleBack_ (nullptr)
76
, battleFront_ (nullptr)
77
, type1Icon_ (nullptr)
78
, type2Icon_ (nullptr)
79
{
80
Init
();
81
}
82
83
Pokemon::~Pokemon
()
84
{
85
}
86
87
void
Pokemon::PlayCry
()
88
{
89
yap::AudioManager::Instance
().
PlaySound
(
"Cries/"
+
90
yap::StringHelper::ToString
(
staticID_
.
GetValue
())
91
+
".wav"
);
92
}
93
94
void
Pokemon::Init
()
95
{
96
graphicPokemonInfo_
=
yap::ObjectFactory::Instance
().
97
Create<PokemonInfo> (
"PokemonInfo"
,
staticID_
);
98
99
LoadSprites
();
100
}
101
102
void
Pokemon::LoadSprites
()
103
{
104
icon_
=
new
yap::Sprite
(
graphicPokemonInfo_
->
GetIconPath
());
105
106
type1Icon_
=
new
yap::Sprite
(
107
"Pictures/Types/"
+
108
yap::StringHelper::ToString
(
109
GetType1
().GetID ().GetValue ()) +
".png"
);
110
111
type2Icon_
=
new
yap::Sprite
(
112
"Pictures/Types/"
+
113
yap::StringHelper::ToString
(
114
GetType2
().GetID ().GetValue ()) +
".png"
);
115
116
if
(
gender_
== yap::Gender::Female)
117
{
118
genderIcon_
=
new
yap::Sprite
(
"Pictures/Battle/FemaleIcon.png"
);
119
120
if
(
shiny_
)
121
{
122
battleFront_
=
new
yap::Sprite
(
123
new
yap::Texture
(
graphicPokemonInfo_
->
GetShinyFemaleFrontPath
()));
124
125
battleBack_
=
new
yap::Sprite
(
126
new
yap::Texture
(
graphicPokemonInfo_
->
GetShinyFemaleBackPath
()));
127
}
128
else
129
{
130
battleFront_
=
new
yap::Sprite
(
131
new
yap::Texture
(
graphicPokemonInfo_
->
GetFemaleFrontPath
()));
132
133
battleBack_
=
new
yap::Sprite
(
134
new
yap::Texture
(
graphicPokemonInfo_
->
GetFemaleBackPath
()));
135
}
136
}
137
else
138
{
139
genderIcon_
=
new
yap::Sprite
(
"Pictures/Battle/MaleIcon.png"
);
140
141
if
(
shiny_
)
142
{
143
battleFront_
=
new
yap::Sprite
(
144
new
yap::Texture
(
graphicPokemonInfo_
->
GetShinyMaleFrontPath
()));
145
146
battleBack_
=
new
yap::Sprite
(
147
new
yap::Texture
(
graphicPokemonInfo_
->
GetShinyMaleBackPath
()));
148
}
149
else
150
{
151
battleFront_
=
new
yap::Sprite
(
152
new
yap::Texture
(
graphicPokemonInfo_
->
GetMaleFrontPath
()));
153
154
battleBack_
=
new
yap::Sprite
(
155
new
yap::Texture
(
graphicPokemonInfo_
->
GetMaleBackPath
()));
156
}
157
}
158
}
159
160
// Getters
161
yap::ISprite
&
Pokemon::GetIcon
()
const
162
{
return
*
icon_
; }
163
yap::ISprite
&
Pokemon::GetGenderIcon
()
const
164
{
return
*
genderIcon_
; }
165
yap::ISprite
&
Pokemon::GetBattleBack
()
const
166
{
return
*
battleBack_
; }
167
yap::ISprite
&
Pokemon::GetBattleFront
()
const
168
{
return
*
battleFront_
; }
169
yap::ISprite
&
Pokemon::GetType1Icon
()
const
170
{
return
*
type1Icon_
; }
171
yap::ISprite
&
Pokemon::GetType2Icon
()
const
172
{
return
*
type2Icon_
; }
173
174
}
// namespace ycl
YAPOG.Client
src
Pokemon
Pokemon.cpp
Generated on Mon Sep 17 2012 22:24:24 for YAPOG by
1.8.1.1