refined player pointers. final ping changes
This commit is contained in:
parent
efc9e13737
commit
73c8ca4e0f
2 changed files with 45 additions and 25 deletions
|
@ -12,6 +12,7 @@ namespace Sledgemapper
|
|||
public Color NoteColor { get; set; }
|
||||
public string MachineName { get; set; }
|
||||
public int TileDeleteDivider { get; set; }
|
||||
public int PingDuration {get;set;}
|
||||
|
||||
public Settings()
|
||||
{
|
||||
|
@ -20,6 +21,7 @@ namespace Sledgemapper
|
|||
NoteColor = Color.DarkRed;
|
||||
OverlayTintColor = new Color(24, 118, 157);
|
||||
TileDeleteDivider = 14;
|
||||
PingDuration = 4000;
|
||||
try
|
||||
{
|
||||
MachineName = Environment.MachineName;
|
||||
|
|
|
@ -634,7 +634,7 @@ namespace Sledgemapper
|
|||
}
|
||||
}
|
||||
|
||||
if (oldState.IsKeyDown(Keys.LeftShift) && newState.IsKeyUp(Keys.LeftShift))
|
||||
if (oldState.IsKeyDown(Keys.P) && newState.IsKeyUp(Keys.P))
|
||||
{
|
||||
_communicationManager.Ping(_state.HoveredTile).SafeFireAndForget();
|
||||
}
|
||||
|
@ -738,11 +738,11 @@ namespace Sledgemapper
|
|||
DrawLinePreview();
|
||||
|
||||
DrawRoomPreview();
|
||||
|
||||
_spriteBatch.End();
|
||||
|
||||
DrawRipple(gameTime);
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
_desktop?.Render();
|
||||
|
@ -753,8 +753,6 @@ namespace Sledgemapper
|
|||
}
|
||||
base.Draw(gameTime);
|
||||
}
|
||||
private int _rippleFrameIndex = 0;
|
||||
|
||||
|
||||
private void DrawRipple(GameTime gameTime)
|
||||
{
|
||||
|
@ -821,7 +819,7 @@ namespace Sledgemapper
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((gameTime.TotalGameTime.TotalMilliseconds - ping.StartTime) > 3000)
|
||||
if ((gameTime.TotalGameTime.TotalMilliseconds - ping.StartTime) > _settings.PingDuration)
|
||||
{
|
||||
_sessionData.Pings.TryRemove(guid, out var _);
|
||||
}
|
||||
|
@ -1343,11 +1341,12 @@ namespace Sledgemapper
|
|||
|
||||
var playerCells = _sessionData.Players.Select(m => m.Position).Distinct().ToList();
|
||||
|
||||
foreach (var cell in playerCells)
|
||||
foreach (var cell in playerCells.Where(c => !IsOffscreen(c)))
|
||||
{
|
||||
var playersInCell = _sessionData.Players.Where(m => m.Position == cell).ToList();
|
||||
var i = 0;
|
||||
foreach (var player in playersInCell)
|
||||
|
||||
{
|
||||
var color = player.Color.ToColor();
|
||||
|
||||
|
@ -1365,7 +1364,7 @@ namespace Sledgemapper
|
|||
_state.TileSize - 1,
|
||||
_state.TileSize - 1);
|
||||
stringPosition = new Vector2(
|
||||
player.Position.X * _state.TileSize,
|
||||
player.Position.X * _state.TileSize + 1,
|
||||
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
|
||||
}
|
||||
else if (playersInCell.Count == 2)
|
||||
|
@ -1380,7 +1379,7 @@ namespace Sledgemapper
|
|||
_state.TileSize / 2 - 1,
|
||||
_state.TileSize - 1);
|
||||
stringPosition = new Vector2(
|
||||
player.Position.X * _state.TileSize,
|
||||
player.Position.X * _state.TileSize + 1,
|
||||
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
|
||||
}
|
||||
else
|
||||
|
@ -1391,7 +1390,7 @@ namespace Sledgemapper
|
|||
_state.TileSize / 2 - 1,
|
||||
_state.TileSize - 1);
|
||||
stringPosition = new Vector2(
|
||||
player.Position.X * _state.TileSize + _state.TileSize / 2,
|
||||
player.Position.X * _state.TileSize + _state.TileSize / 2 + 1,
|
||||
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
|
||||
}
|
||||
i++;
|
||||
|
@ -1408,7 +1407,7 @@ namespace Sledgemapper
|
|||
_state.TileSize / 2 - 1,
|
||||
_state.TileSize / 2 - 1);
|
||||
stringPosition = new Vector2(
|
||||
player.Position.X * _state.TileSize,
|
||||
player.Position.X * _state.TileSize + 1,
|
||||
player.Position.Y * _state.TileSize + _state.TileSize / 2 - measure.Y * fscale);
|
||||
|
||||
break;
|
||||
|
@ -1419,7 +1418,7 @@ namespace Sledgemapper
|
|||
_state.TileSize / 2 - 1,
|
||||
_state.TileSize / 2 - 1);
|
||||
stringPosition = new Vector2(
|
||||
player.Position.X * _state.TileSize + _state.TileSize / 2,
|
||||
player.Position.X * _state.TileSize + _state.TileSize / 2 + 1,
|
||||
player.Position.Y * _state.TileSize + _state.TileSize / 2 - measure.Y * fscale);
|
||||
|
||||
break;
|
||||
|
@ -1430,7 +1429,7 @@ namespace Sledgemapper
|
|||
_state.TileSize / 2 - 1,
|
||||
_state.TileSize / 2 - 1);
|
||||
stringPosition = new Vector2(
|
||||
player.Position.X * _state.TileSize,
|
||||
player.Position.X * _state.TileSize + 1,
|
||||
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
|
||||
|
||||
break;
|
||||
|
@ -1442,7 +1441,7 @@ namespace Sledgemapper
|
|||
_state.TileSize / 2 - 1,
|
||||
_state.TileSize / 2 - 1);
|
||||
stringPosition = new Vector2(
|
||||
player.Position.X * _state.TileSize + _state.TileSize / 2,
|
||||
player.Position.X * _state.TileSize + _state.TileSize / 2 + 1,
|
||||
player.Position.Y * _state.TileSize + _state.TileSize - measure.Y * fscale);
|
||||
|
||||
break;
|
||||
|
@ -1518,17 +1517,32 @@ namespace Sledgemapper
|
|||
|
||||
private bool GetPointerVector(Point target, out Vector2[] points)
|
||||
{
|
||||
var leftBound = 200;
|
||||
var topBound = 75;
|
||||
var bottomBound = 25;
|
||||
var offset = _state.TileSize / 2;
|
||||
var leftBound = 200 + offset;
|
||||
var topBound = 75 + offset;
|
||||
var bottomBound = 25 + offset;
|
||||
var rightBound = offset;
|
||||
points = new Vector2[0];
|
||||
var center = new Point((Window.ClientBounds.Width + leftBound) / 2 - (int)_viewportCenter.X, Window.ClientBounds.Height / 2 - (int)_viewportCenter.Y);
|
||||
|
||||
// center
|
||||
var p1 = new Vector2(center.X, center.Y);
|
||||
var p2 = new Vector2(target.X * _state.TileSize, target.Y * _state.TileSize);
|
||||
|
||||
var p3 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, topBound - _viewportCenter.Y);
|
||||
var p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y-bottomBound);
|
||||
// point
|
||||
var p2 = new Vector2(
|
||||
target.X * _state.TileSize + offset,
|
||||
target.Y * _state.TileSize + offset);
|
||||
|
||||
// top right
|
||||
var p3 = new Vector2(
|
||||
Window.ClientBounds.Width - _viewportCenter.X - rightBound,
|
||||
topBound - _viewportCenter.Y);
|
||||
|
||||
//bottom right
|
||||
var p4 = new Vector2(
|
||||
Window.ClientBounds.Width - _viewportCenter.X - rightBound,
|
||||
Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
|
||||
|
||||
var ua1 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
|
||||
|
||||
p3 = new Vector2(leftBound - _viewportCenter.X, topBound - _viewportCenter.Y);
|
||||
|
@ -1536,11 +1550,11 @@ namespace Sledgemapper
|
|||
var ua2 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
|
||||
|
||||
p3 = new Vector2(leftBound - _viewportCenter.X, topBound - _viewportCenter.Y);
|
||||
p4 = new Vector2(leftBound - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y-bottomBound);
|
||||
p4 = new Vector2(leftBound - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
|
||||
var ua3 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
|
||||
|
||||
p3 = new Vector2(leftBound - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y-bottomBound);
|
||||
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y-bottomBound);
|
||||
p3 = new Vector2(leftBound - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
|
||||
p4 = new Vector2(Window.ClientBounds.Width - _viewportCenter.X, Window.ClientBounds.Height - _viewportCenter.Y - bottomBound);
|
||||
var ua4 = ((p4.X - p3.X) * (p1.Y - p3.Y) - (p4.Y - p3.Y) * (p1.X - p3.X)) / ((p4.Y - p3.Y) * (p2.X - p1.X) - (p4.X - p3.X) * (p2.Y - p1.Y));
|
||||
|
||||
var uas = new List<float> { ua1, ua2, ua3, ua4 };
|
||||
|
@ -1554,16 +1568,20 @@ namespace Sledgemapper
|
|||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
points = new Vector2[] { new Vector2(x, y), new Vector2(x - 20, y - 10), new Vector2(x - 20, y + 10),new Vector2(x, y) };
|
||||
x += offset;
|
||||
points = new Vector2[] { new Vector2(x, y), new Vector2(x - 20, y - 10), new Vector2(x - 20, y + 10), new Vector2(x, y) };
|
||||
break;
|
||||
case 1:
|
||||
y -= offset;
|
||||
points = new Vector2[] { new Vector2(x, y), new Vector2(x - 10, y + 20), new Vector2(x + 10, y + 20), new Vector2(x, y) };
|
||||
break;
|
||||
case 2:
|
||||
x -= offset;
|
||||
points = new Vector2[] { new Vector2(x, y), new Vector2(x + 20, y + 10), new Vector2(x + 20, y - 10), new Vector2(x, y) };
|
||||
break;
|
||||
case 3:
|
||||
points = new Vector2[] { new Vector2(x, y), new Vector2(x + 10, y - 20),new Vector2(x - 10, y - 20), new Vector2(x, y) };
|
||||
y += offset;
|
||||
points = new Vector2[] { new Vector2(x, y), new Vector2(x + 10, y - 20), new Vector2(x - 10, y - 20), new Vector2(x, y) };
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue