-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject.cpp
123 lines (89 loc) · 2.54 KB
/
object.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "object.h"
namespace SSJ {
Object::Object(float x, float y){
this->mapPosition.x = x;
this->mapPosition.y = y;
this->setDefaultVar();
}
Object::Object(Point position){
this->mapPosition = position;
this->setDefaultVar();
}
Object::Object(){
this->mapPosition.x = 0;
this->mapPosition.y = 0;
this->setDefaultVar();
}
Point Object::getMapPosition() const{
return mapPosition;
}
void Object::setMapPosition(float x, float y){
this->mapPosition.x = x;
this->mapPosition.y = y;
}
void Object::setMapPosition(const Point position){
this->mapPosition = position;
}
Point Object::getScreenPosition() const
{
return Helpers::getOnScreenPosition(this->mapPosition);
}
void Object::setActivity(const bool activity){
this->activity = activity;
}
bool Object::isActive() const{
return activity;
}
Sprite *Object::getSprite()
{
return &sprite;
}
void Object::setSprite(const Sprite value)
{
sprite = value;
}
bool Object::isDesynchronization() const
{
return desynchronization;
}
void Object::setDesynchronization(bool value)
{
desynchronization = value;
}
void Object::setDefaultVar()
{
this->desynchronization = false;
//this->syncId = -1;
this->activity = true;
}
void Object::AddAction(sf::Event::EventType type, Object* object, ActionEvent function){
Event temp;
temp.ActionFunction = function;
temp.EventType = type;
temp.object = object;
DataContainer::EventList.push_back(temp);
}
void Object::AddActionKeyboard(sf::Event::EventType type, sf::Keyboard::Key key, Object* object , ActionEvent function){
Event temp;
temp.ActionFunction = function;
temp.EventType = type;
temp.KeyAction = key;
temp.object = object;
DataContainer::EventList.push_back(temp);
}
void Object::SynchronizationObject(Json::Value jsonObject)
{
if(jsonObject.isMember(_J(_activity))){
this->activity = jsonObject[_J(_activity)].asBool();
}
if(activity)
{
if(jsonObject.isMember(_J(_mapPositionX))){
this->mapPosition.x = jsonObject[_J(_mapPositionX)].asFloat();
}
if(jsonObject.isMember(_J(_mapPositionY))){
this->mapPosition.y = jsonObject[_J(_mapPositionY)].asFloat();
}
}
}
}