Commit cf6f0916 authored by Maxime's avatar Maxime
Browse files

fix id issue

parent 638e2111
......@@ -32,6 +32,7 @@ namespace WebAPI.Controller
[HttpPut("SendPlayer")]
public IActionResult SendPlayer(string code, int id, float x, float y, bool flipX, bool flipY)
{
Trace.WriteLine($"Sendplayer{id} <{code}>");
var game = GameManager.Instance.Games.Find(x => x.Code == code);
if (game == null)
return BadRequest("Game not found");
......
......@@ -86,7 +86,7 @@ namespace ZZZZZZ
while (true)
{
API.UpdateLocal(LocalPlayerManager.Character as LocalCharacter);
Task.Delay(50).Wait();
Task.Delay(16).Wait();
}
});
......@@ -95,7 +95,7 @@ namespace ZZZZZZ
while (true)
{
API.UpdateRemote(RemotePlayerManager.Character as RemoteCharacter);
Task.Delay(50).Wait();
Task.Delay(16).Wait();
}
});
}
......
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Http;
......@@ -68,7 +69,7 @@ namespace ZZZZZZ.WebAPIs
{
try
{
Console.WriteLine($"Local at\t{(int)player.Node.Position2D.X}\t{(int)player.Node.Position2D.Y}");
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);
post.Wait();
var content = post.Result.Content.ReadAsStringAsync();
......@@ -86,7 +87,8 @@ namespace ZZZZZZ.WebAPIs
{
try
{
var get = Client.GetAsync($"{Hook}Game/GetPlayer?code={Code}&ownId={remote.ID}");
var get = Client.GetAsync($"{Hook}Game/GetPlayer?code={Code}&ownId={(remote.CharacterID+1)%2}");
get.Wait();
var content = get.Result.Content.ReadAsStringAsync();
content.Wait();
......@@ -100,8 +102,7 @@ namespace ZZZZZZ.WebAPIs
var flipX = bool.Parse(values["flipX"]);
var flipY = bool.Parse(values["flipY"]);
var online = bool.Parse(values["online"]);
Console.WriteLine($"Remote at\t{(int)x}\t{(int)y}");
remote.Move(new Vector2(x, y));
remote.Flip = (flipX, flipY);
remote.Online = online;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment