From 75cdc13fc19c35c416692e4c6509b432046fd711 Mon Sep 17 00:00:00 2001 From: Shawdooow Date: Sun, 18 Mar 2018 23:52:04 -0400 Subject: [PATCH] updates inline with `Battleship` --- .../Containers/SymcolDialContainer.cs | 58 +++++++++++++++++++ .../Networking/NetworkingClientHandler.cs | 2 +- Symcol.Core/Symcol.Core.csproj | 1 + 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 Symcol.Core/Graphics/Containers/SymcolDialContainer.cs diff --git a/Symcol.Core/Graphics/Containers/SymcolDialContainer.cs b/Symcol.Core/Graphics/Containers/SymcolDialContainer.cs new file mode 100644 index 0000000000..b23c1ae15c --- /dev/null +++ b/Symcol.Core/Graphics/Containers/SymcolDialContainer.cs @@ -0,0 +1,58 @@ +using OpenTK; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Input; +using System; + +namespace Symcol.Core.Graphics.Containers +{ + public class SymcolDialContainer : CircularContainer + { + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + + private Vector2 mousePosition; + + private float lastAngle; + private float currentRotation; + public float RotationAbsolute; + + private int completeTick; + + private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 360)); + + private bool rotationTransferred; + + protected override bool OnMouseMove(InputState state) + { + mousePosition = Parent.ToLocalSpace(state.Mouse.NativeState.Position); + return base.OnMouseMove(state); + } + + protected override void Update() + { + base.Update(); + + var thisAngle = -(float)MathHelper.RadiansToDegrees(Math.Atan2(mousePosition.X - DrawSize.X / 2, mousePosition.Y - DrawSize.Y / 2)); + + + if (!rotationTransferred) + { + currentRotation = Rotation * 2; + rotationTransferred = true; + } + + if (thisAngle - lastAngle > 180) + lastAngle += 360; + else if (lastAngle - thisAngle > 180) + lastAngle -= 360; + + currentRotation += thisAngle - lastAngle; + RotationAbsolute += Math.Abs(thisAngle - lastAngle); + + lastAngle = thisAngle; + + foreach(Drawable drawable in Children) + drawable.RotateTo(currentRotation / 2, 200, Easing.OutExpo); + } + } +} diff --git a/Symcol.Core/Networking/NetworkingClientHandler.cs b/Symcol.Core/Networking/NetworkingClientHandler.cs index 4f4b5ccc87..c2d70119bb 100644 --- a/Symcol.Core/Networking/NetworkingClientHandler.cs +++ b/Symcol.Core/Networking/NetworkingClientHandler.cs @@ -559,7 +559,7 @@ namespace Symcol.Core.Networking public void ShareWithOtherPeers(Packet packet) { if (SendClient == null) - foreach (ClientInfo clientInfo in InGameClients) + foreach (ClientInfo clientInfo in ConncetedClients) if (packet.ClientInfo.IP != clientInfo.IP) { NetworkingClient client = new NetworkingClient(true, clientInfo.IP, clientInfo.Port); diff --git a/Symcol.Core/Symcol.Core.csproj b/Symcol.Core/Symcol.Core.csproj index 9076a3e53d..ac72610da3 100644 --- a/Symcol.Core/Symcol.Core.csproj +++ b/Symcol.Core/Symcol.Core.csproj @@ -73,6 +73,7 @@ +