diff --git a/.gitignore b/.gitignore index 29f9459..2cfce91 100644 --- a/.gitignore +++ b/.gitignore @@ -102,4 +102,5 @@ InitTestScene*.unity LightingData.asset* # Sprites +!/[Aa]ssets/[Gg]raphics/[Ss]plashes/**/* !/[Aa]ssets/[Gg]raphics/[Ss]prites/**/* diff --git a/Assets/Graphics/Splashes/NeonTea.png b/Assets/Graphics/Splashes/NeonTea.png new file mode 100644 index 0000000..4651f54 Binary files /dev/null and b/Assets/Graphics/Splashes/NeonTea.png differ diff --git a/Assets/Graphics/Splashes/NeonTea.png.meta b/Assets/Graphics/Splashes/NeonTea.png.meta new file mode 100644 index 0000000..cadfff8 --- /dev/null +++ b/Assets/Graphics/Splashes/NeonTea.png.meta @@ -0,0 +1,118 @@ +fileFormatVersion: 2 +guid: 49f9a3737fb462a4b9e0b34216971d29 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Networking/Instances/Client.cs b/Assets/Scripts/Networking/Instances/Client.cs index 45ece22..b0800cd 100644 --- a/Assets/Scripts/Networking/Instances/Client.cs +++ b/Assets/Scripts/Networking/Instances/Client.cs @@ -15,13 +15,19 @@ namespace NeonTea.Quakeball.Networking.Instances { private Connection Server; private Dictionary Players = new Dictionary(); - private NetPlayer LocalPlayer; private bool SelfIdentified = false; public float Ping { get; private set; } private float LastPingReceived; private byte LastPingIdent; + public Client() { + Net = GameObject.FindGameObjectWithTag("Net").GetComponent(); + + LocalPlayer = new NetPlayer(ulong.MaxValue - 1); + LocalPlayer.Controlled = GameObject.FindGameObjectWithTag("Player").GetComponent(); + } + public override void Start(string address, int port, PeerMessageListener listener) { if (Peer.Running) { return; @@ -31,11 +37,6 @@ namespace NeonTea.Quakeball.Networking.Instances { Peer.Start(0); byte ident = Peer.RegisterProtocol(new GameProtocol(this)); Peer.Connect(address, port, ident); - - Net = GameObject.FindGameObjectWithTag("Net").GetComponent(); - - LocalPlayer = new NetPlayer(ulong.MaxValue - 1); - LocalPlayer.Controlled = GameObject.FindGameObjectWithTag("Player").GetComponent(); } public override void OnStop() { @@ -130,7 +131,7 @@ namespace NeonTea.Quakeball.Networking.Instances { } else if (packet is HitPckt) { HitPckt hit = (HitPckt)packet; if (Players[hit.Target].Controlled != null) { - Players[hit.Target].Controlled.Hit(); + Players[hit.Target].Controlled.Hit(hit.Source); } } } diff --git a/Assets/Scripts/Networking/Instances/NetInstance.cs b/Assets/Scripts/Networking/Instances/NetInstance.cs index 790bea0..01ec7e7 100644 --- a/Assets/Scripts/Networking/Instances/NetInstance.cs +++ b/Assets/Scripts/Networking/Instances/NetInstance.cs @@ -13,6 +13,8 @@ namespace NeonTea.Quakeball.Networking.Instances { public Peer Peer; public List Connections = new List(); + public NetPlayer LocalPlayer; + public NetInstance() { Peer = new Peer(Fingerprint); } diff --git a/Assets/Scripts/Networking/Instances/Server.cs b/Assets/Scripts/Networking/Instances/Server.cs index 8c183a3..fa9742f 100644 --- a/Assets/Scripts/Networking/Instances/Server.cs +++ b/Assets/Scripts/Networking/Instances/Server.cs @@ -16,12 +16,14 @@ namespace NeonTea.Quakeball.Networking.Instances { public List PlayerList { get; private set; } = new List(); private ulong PlayerIdCounter; - private NetPlayer LocalPlayer = new NetPlayer(ulong.MaxValue); - private byte LastPingIdent; private float LastSentPing; public static float PingInterval = 1; + public Server() { + LocalPlayer = new NetPlayer(ulong.MaxValue); + } + public override void Start(string address, int port, PeerMessageListener listener) { if (Peer.Running) { return; @@ -201,8 +203,8 @@ namespace NeonTea.Quakeball.Networking.Instances { SendUnreliableToAll(pckt); } - public void SendHit(ulong id) { - HitPckt hit = new HitPckt(id); + public void SendHit(ulong source, ulong target) { + HitPckt hit = new HitPckt(source, target); SendReliableToAll(hit); } diff --git a/Assets/Scripts/Networking/Packets/HitPckt.cs b/Assets/Scripts/Networking/Packets/HitPckt.cs index 997587a..617cd02 100644 --- a/Assets/Scripts/Networking/Packets/HitPckt.cs +++ b/Assets/Scripts/Networking/Packets/HitPckt.cs @@ -4,16 +4,22 @@ using NeonTea.Quakeball.TeaNet.Packets; namespace NeonTea.Quakeball.Networking.Packets { public class HitPckt : Packet { + public ulong Source; public ulong Target; public HitPckt() { } - public HitPckt(ulong id) { Target = id; } + public HitPckt(ulong source, ulong target) { + Source = source; + Target = target; + } public override void Read(ByteBuffer buffer) { + Source = buffer.ReadULong(); Target = buffer.ReadULong(); } public override void Write(ByteBuffer buffer) { + buffer.Write(Source); buffer.Write(Target); } } diff --git a/Assets/Scripts/Players/LocalPlayer.cs b/Assets/Scripts/Players/LocalPlayer.cs index 2cf1ee9..0546947 100644 --- a/Assets/Scripts/Players/LocalPlayer.cs +++ b/Assets/Scripts/Players/LocalPlayer.cs @@ -60,11 +60,6 @@ namespace NeonTea.Quakeball.Players { transform.position = new Vector3(float.Parse(args[0]), float.Parse(args[1]), float.Parse(args[2])); return true; }, "tp x y z - Teleports the local player to the specified coordinates."); - - Terminal.Singleton.RegisterCommand("hit", args => { - Player.Hit(); - return true; - }); } private void Update() { diff --git a/Assets/Scripts/Players/Player.cs b/Assets/Scripts/Players/Player.cs index 12c4bc3..6e2b4b1 100644 --- a/Assets/Scripts/Players/Player.cs +++ b/Assets/Scripts/Players/Player.cs @@ -179,8 +179,8 @@ namespace NeonTea.Quakeball.Players { } if (Player != null) { if (Net.Singleton.Instance is Server) { - ((Server)Net.Singleton.Instance).SendHit(Player.NetId); - Player.Hit(); + ((Server)Net.Singleton.Instance).SendHit(NetId, Player.NetId); + Player.Hit(NetId); } } break; @@ -194,10 +194,14 @@ namespace NeonTea.Quakeball.Players { AudioSource.PlayOneShot(RaygunAudio); } - public void Hit() { + public void Hit(ulong sourceUid) { if (Net.Singleton.Instance is Server) { ((Server)Net.Singleton.Instance).HandlePlayerDeath(NetId); } + bool IsLocal = true; + if (Net.Singleton.Instance != null) { + IsLocal = Net.Singleton.Instance.LocalPlayer.Id == sourceUid; + } Debug.Log("I was hit! Aaagh!"); Splatter.Play(); }