small changes
This commit is contained in:
parent
49bde02544
commit
0b7b3116b4
4 changed files with 26 additions and 7 deletions
|
@ -38,7 +38,8 @@ namespace SignalRChat.Hubs
|
|||
"#911eb4",
|
||||
"#800000",
|
||||
"#808000",
|
||||
"#469990"};
|
||||
"#469990"
|
||||
};
|
||||
|
||||
public async Task NewTile(string sessionName, Tile tile)
|
||||
{
|
||||
|
@ -107,7 +108,7 @@ namespace SignalRChat.Hubs
|
|||
var userId = int.Parse(Context.User.Identity.Name);
|
||||
var SessionUsers = _dbContext.SessionUsers.Where(m => m.SessionId == sessionId).OrderBy(m => m.UserId).ToList();
|
||||
var user = _datacontext.Users.First(u => u.Id == userId);
|
||||
var player = new Player { UserId = userId, Initials = user.Initials, Position = tile, Color = Colors[SessionUsers.IndexOf(SessionUsers.FirstOrDefault(m => m.UserId == userId))] };
|
||||
var player = new Player { UserId = userId, Initials = user.Initials, Position = tile, Color = UserColors[userId]};
|
||||
await Clients.Group(sessionName).PlayerUpdate(player);
|
||||
}
|
||||
|
||||
|
@ -125,12 +126,13 @@ namespace SignalRChat.Hubs
|
|||
public override async Task OnDisconnectedAsync(Exception exception)
|
||||
{
|
||||
var userConnection = _dbContext.UserConnections.FirstOrDefault(m => m.ConnectionId == Context.ConnectionId);
|
||||
var userId=userConnection.UserId;
|
||||
if (userConnection != null)
|
||||
{
|
||||
_dbContext.UserConnections.Remove(userConnection);
|
||||
}
|
||||
|
||||
var userSessions = _dbContext.SessionUsers.Where(m => m.UserId == userConnection.UserId).ToList();
|
||||
var userSessions = _dbContext.SessionUsers.Where(m => m.UserId == userId).ToList();
|
||||
{
|
||||
foreach (var userSession in userSessions)
|
||||
{
|
||||
|
@ -138,7 +140,6 @@ namespace SignalRChat.Hubs
|
|||
await Clients.Group(session.SessionName).PlayerUpdate(null); //send remove player
|
||||
_dbContext.SessionUsers.Remove(userSession);
|
||||
}
|
||||
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
|
||||
|
|
Binary file not shown.
|
@ -122,10 +122,10 @@ namespace Sledgemapper
|
|||
return Task.FromResult(_authenticateResponse.Token);
|
||||
}
|
||||
|
||||
public async Task<bool> Register(RegisterModel registerModel)
|
||||
public async Task<HttpResponseMessage> Register(RegisterModel registerModel)
|
||||
{
|
||||
var result = await Api.Register(registerModel).ConfigureAwait(false);
|
||||
return result.IsSuccessStatusCode;
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<AuthenticateResponse> Login(AuthenticateModel authenticateModel)
|
||||
|
|
|
@ -153,6 +153,11 @@ namespace Sledgemapper
|
|||
_state.SelectOverlay(screenPosition);
|
||||
}
|
||||
|
||||
if (newState.IsKeyDown(Keys.LeftControl) && newState.IsKeyDown(Keys.C))
|
||||
{
|
||||
CenterOnSelectedTile();
|
||||
}
|
||||
|
||||
if (mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton != oldMouseState.LeftButton)
|
||||
{
|
||||
_state._selectedTile.X = _state._hoveredTile.X;
|
||||
|
@ -187,6 +192,8 @@ namespace Sledgemapper
|
|||
if (!newState.IsKeyDown(Keys.LeftControl) && mouseState.LeftButton == ButtonState.Pressed && mouseState.LeftButton == oldMouseState.LeftButton)
|
||||
{
|
||||
_viewportCenter = new Vector3(_viewportCenter.X + mouseState.Position.X - oldMouseState.Position.X, _viewportCenter.Y + mouseState.Position.Y - oldMouseState.Position.Y, 0);
|
||||
|
||||
Console.WriteLine($"{_state._selectedTile.X}:{_state._selectedTile.Y} / {_viewportCenter.X}:{_viewportCenter.Y}");
|
||||
}
|
||||
|
||||
if (newState.IsKeyDown(Keys.LeftControl) && mouseState.ScrollWheelValue != oldMouseState.ScrollWheelValue)
|
||||
|
@ -254,6 +261,12 @@ namespace Sledgemapper
|
|||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
private void CenterOnSelectedTile()
|
||||
{
|
||||
_viewportCenter.X=_state._selectedTile.X*_state._tileSize;
|
||||
_viewportCenter.Y=_state._selectedTile.Y*_state._tileSize;
|
||||
}
|
||||
|
||||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
if (_spriteBatch is null)
|
||||
|
@ -676,7 +689,7 @@ namespace Sledgemapper
|
|||
LastName = localContent.TxtLastname.Text,
|
||||
Initials = localContent.TxtInitials.Text
|
||||
});
|
||||
if (result)
|
||||
if (result.IsSuccessStatusCode)
|
||||
{
|
||||
_authResponse = await _communicationManager.Login(new AuthenticateModel
|
||||
{
|
||||
|
@ -685,6 +698,11 @@ namespace Sledgemapper
|
|||
});
|
||||
successful = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
localContent.LblLoginError.Text = result.ReasonPhrase;
|
||||
localContent.LblLoginError.Visible = true;
|
||||
}
|
||||
}
|
||||
catch (Refit.ApiException refitException)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue