Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime POULAIN
ZZZZZZ
Commits
46d24ae2
Commit
46d24ae2
authored
Feb 14, 2022
by
Maxime POULAIN
Browse files
fix api not getting character rotation
parent
47096c66
Changes
4
Hide whitespace changes
Inline
Side-by-side
Code/ZZZZZZ-Server/WebAPI/Controller/GameController.cs
View file @
46d24ae2
...
...
@@ -30,9 +30,8 @@ namespace WebAPI.Controller
}
[
HttpPut
(
"SendPlayer"
)]
public
IActionResult
SendPlayer
(
string
code
,
int
id
,
float
x
,
float
y
,
bool
flipX
,
bool
flipY
)
public
IActionResult
SendPlayer
(
string
code
,
int
id
,
float
x
,
float
y
,
bool
flipX
,
bool
flipY
,
int
rotation
)
{
Trace
.
WriteLine
(
$"Sendplayer
{
id
}
<
{
code
}
>"
);
var
game
=
GameManager
.
Instance
.
Games
.
Find
(
x
=>
x
.
Code
==
code
);
if
(
game
==
null
)
return
BadRequest
(
"Game not found"
);
...
...
@@ -45,6 +44,7 @@ namespace WebAPI.Controller
player
.
Y
=
y
;
player
.
FlipX
=
flipX
;
player
.
FlipY
=
flipY
;
player
.
Rotation
=
rotation
;
}
return
Ok
();
...
...
Code/ZZZZZZ-Server/WebAPI/Model/Player.cs
View file @
46d24ae2
...
...
@@ -8,6 +8,7 @@
public
bool
FlipX
{
get
;
set
;
}
public
bool
FlipY
{
get
;
set
;
}
public
bool
Online
{
get
;
set
;
}
public
int
Rotation
{
get
;
set
;
}
public
Player
(
int
id
)
...
...
Code/ZZZZZZ/ZZZZZZ/GameManagerUtils.cs
View file @
46d24ae2
...
...
@@ -49,7 +49,7 @@ namespace ZZZZZZ
{
Task
.
Run
(()
=>
{
API
=
new
WebAPI
();
API
=
new
WebAPI
(
"https://localhost:5000/"
);
if
(
string
.
IsNullOrEmpty
(
gamecode
))
{
API
.
CreateGame
();
...
...
Code/ZZZZZZ/ZZZZZZ/WebAPIs/WebAPI.cs
View file @
46d24ae2
...
...
@@ -18,7 +18,7 @@ namespace ZZZZZZ.WebAPIs
public
string
Hook
{
get
;
}
public
HttpClient
Client
{
get
;
}
public
WebAPI
(
string
hook
=
"http://91.170.211.147:5000/"
)
public
WebAPI
(
string
hook
=
"http://91.170.211.147:5000
0
/"
)
{
Hook
=
hook
;
ServicePointManager
.
SecurityProtocol
=
SecurityProtocolType
.
Tls12
|
SecurityProtocolType
.
Tls11
|
SecurityProtocolType
.
Tls
;
...
...
@@ -69,8 +69,7 @@ namespace ZZZZZZ.WebAPIs
{
try
{
Trace
.
WriteLine
(
$"
{
Hook
}
Game/SendPlayer?code=
{
Code
}
&id=
{
player
.
CharacterID
}
&x=
{
FormatFloat
(
player
.
Node
.
Position2D
.
X
)}
&y=
{
FormatFloat
(
player
.
Node
.
Position2D
.
Y
)}
&flipX=
{
player
.
Flip
.
X
}
&flipY=
{
player
.
Flip
.
Y
}
"
);
var
post
=
Client
.
PutAsync
(
$"
{
Hook
}
Game/SendPlayer?code=
{
Code
}
&id=
{
player
.
CharacterID
}
&x=
{
FormatFloat
(
player
.
Node
.
Position2D
.
X
)}
&y=
{
FormatFloat
(
player
.
Node
.
Position2D
.
Y
)}
&flipX=
{
player
.
Flip
.
X
}
&flipY=
{
player
.
Flip
.
Y
}
"
,
null
);
var
post
=
Client
.
PutAsync
(
$"
{
Hook
}
Game/SendPlayer?code=
{
Code
}
&id=
{
player
.
CharacterID
}
&x=
{
FormatFloat
(
player
.
Node
.
Position2D
.
X
)}
&y=
{
FormatFloat
(
player
.
Node
.
Position2D
.
Y
)}
&flipX=
{
player
.
Flip
.
X
}
&flipY=
{
player
.
Flip
.
Y
}
&rotation=
{(
int
)
player
.
Node
.
Rotation2D
}
"
,
null
);
post
.
Wait
();
var
content
=
post
.
Result
.
Content
.
ReadAsStringAsync
();
content
.
Wait
();
...
...
@@ -87,8 +86,8 @@ namespace ZZZZZZ.WebAPIs
{
try
{
var
get
=
Client
.
GetAsync
(
$"
{
Hook
}
Game/GetPlayer?code=
{
Code
}
&ownId=
{(
remote
.
CharacterID
+
1
)%
2
}
"
);
var
get
=
Client
.
GetAsync
(
$"
{
Hook
}
Game/GetPlayer?code=
{
Code
}
&ownId=
{(
remote
.
CharacterID
+
1
)
%
2
}
"
);
get
.
Wait
();
var
content
=
get
.
Result
.
Content
.
ReadAsStringAsync
();
content
.
Wait
();
...
...
@@ -102,9 +101,11 @@ namespace ZZZZZZ.WebAPIs
var
flipX
=
bool
.
Parse
(
values
[
"flipX"
]);
var
flipY
=
bool
.
Parse
(
values
[
"flipY"
]);
var
online
=
bool
.
Parse
(
values
[
"online"
]);
var
rotation
=
int
.
Parse
(
values
[
"rotation"
]);
remote
.
Move
(
new
Vector2
(
x
,
y
));
remote
.
Flip
=
(
flipX
,
flipY
);
remote
.
Node
.
Rotation2D
=
rotation
;
remote
.
Online
=
online
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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