raccoons-rise-up / client-unity Goto Github PK
View Code? Open in Web Editor NEWGame client. This is no longer being used.
Home Page: https://discord.gg/cDNf8ja
License: GNU General Public License v3.0
Game client. This is no longer being used.
Home Page: https://discord.gg/cDNf8ja
License: GNU General Public License v3.0
Since ENet is generally said not to be thread safe, should Peer
be defined in the scope of the ENet thread worker? If this is the case how would one do peer.Send(...)
inside Unity's Update() loop? Below can be seen the current method for using peer.Send(...)
as one defined Peer
outside the scope of the thread worker.
The UILoop coroutine should be stopped when the player times out from the server.
The client player gold / other simulation values should be reset as well.
The terminal feedback window should be cleared as well.
A need for communicating data with unpredictable length has risen.
I need to be able to send gold and structureHut data or sometimes just gold or sometimes just structureHut data alone. This will get even messier when new resources and structures are added in the future.
Data looks like the following...
opcode, data, opcode, data, opcode, data, ....
Each opcode describes what each data is in the list.
Data looks like the following...
opcode, data, data, data
opcode, data, data
opcode, data, data, data, data
This solution would require many combinations of opcodes. For e.g. goldHut if wanting to send data info about gold and huts or gold opcode if just wanting to send data about gold. This is really messy.
100
in console)100
is no longer being logged)The client has 2 threads, the unity thread and the enet thread. ENet must run on its own separate thread otherwise it will clog up the unity thread. The need for doing Unity related things during ENet specific events like when a packet has been received or a connection event occurs has risen.
Consider the following code to communicate from enet thread to unity thread.
public class UnityInstruction
{
public UnityInstructionOpcode Opcode { get; set; }
public List<object> Data { get; set; }
public UnityInstruction(UnityInstructionOpcode opcode)
{
Opcode = opcode;
Data = new List<object>();
}
public void Write(object obj)
{
Data.Add(obj);
}
}
public enum UnityInstructionOpcode
{
LoadSceneForDisconnectTimeout,
LoadMainScene,
LogMessage,
ServerResponseMessage,
NotifyUserOfTimeout,
UpdateGoldText,
LoginSuccess
}
// ENet Thread
var instruction = new UnityInstruction(UnityInstructionOpcode.ServerResponseMessage);
instruction.Write($"Version mismatch. Server ver. {serverVersion} Client ver. {clientVersion}");
unityInstructions.Enqueue(instruction);
// Unity Thread
while (unityInstructions.TryDequeue(out UnityInstruction result))
{
switch (result.Opcode)
{
case UnityInstructionOpcode.ServerResponseMessage:
loginScript.loginFeedbackText.text = (string)result.Data[0];
break;
}
}
The above works just fine. My question is, is there a better way about doing this?
Because it could be better.
Sometimes this warning pops up in the console, I have no idea why.
Failed to load XML documentation:
System.Threading.ThreadAbortException
at System.Xml.XmlTextReaderImpl+NodeData.SetNamedNode (System.Xml.XmlNodeType type, System.String localName, System.String prefix, System.String nameWPrefix) [0x00007] in <0f9699188f0c414ea6fb5557f5c16d15>:0
at System.Xml.XmlTextReaderImpl.AddAttribute (System.String localName, System.String prefix, System.String nameWPrefix) [0x0001e] in <0f9699188f0c414ea6fb5557f5c16d15>:0
at System.Xml.XmlTextReaderImpl.AddAttribute (System.Int32 endNamePos, System.Int32 colonPos) [0x0003b] in <0f9699188f0c414ea6fb5557f5c16d15>:0
at System.Xml.XmlTextReaderImpl.ParseAttributes () [0x00263] in <0f9699188f0c414ea6fb5557f5c16d15>:0
at System.Xml.XmlTextReaderImpl.ParseElement () [0x001df] in <0f9699188f0c414ea6fb5557f5c16d15>:0
at System.Xml.XmlTextReaderImpl.ParseElementContent () [0x0016f] in <0f9699188f0c414ea6fb5557f5c16d15>:0
at System.Xml.XmlTextReaderImpl.Read () [0x00085] in <0f9699188f0c414ea6fb5557f5c16d15>:0
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r) [0x00201] in <a9ef27d60e3144519c0741b6584ba229>:0
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader r, System.Xml.Linq.LoadOptions o) [0x00005] in <a9ef27d60e3144519c0741b6584ba229>:0
at System.Xml.Linq.XDocument.Load (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options) [0x00080] in <a9ef27d60e3144519c0741b6584ba229>:0
at System.Xml.Linq.XDocument.Load (System.String uri, System.Xml.Linq.LoadOptions options) [0x0000f] in <a9ef27d60e3144519c0741b6584ba229>:0
at System.Xml.Linq.XDocument.Load (System.String uri) [0x00000] in <a9ef27d60e3144519c0741b6584ba229>:0
at Unity.VisualScripting.XmlDocumentation.GetDocumentationUncached (System.Reflection.Assembly assembly) [0x00094] in C:\Users\VALK-DESKTOP\Documents\Unity Projects\Kittens Rise Up\client\Library\PackageCache\[email protected]\Editor\VisualScripting.Core\Documentation\XmlDocumentation.cs:132
UnityEngine.Debug:LogWarning (object)
Unity.VisualScripting.XmlDocumentation:GetDocumentationUncached (System.Reflection.Assembly) (at Library/PackageCache/[email protected]/Editor/VisualScripting.Core/Documentation/XmlDocumentation.cs:136)
Unity.VisualScripting.XmlDocumentation:BackgroundWork () (at Library/PackageCache/[email protected]/Editor/VisualScripting.Core/Documentation/XmlDocumentation.cs:49)
System.Reflection.MethodBase:Invoke (object,object[])
Unity.VisualScripting.BackgroundWorker/<>c__DisplayClass0_0:<.cctor>b__3 () (at Library/PackageCache/[email protected]/Editor/VisualScripting.Core/Threading/BackgroundWorker.cs:82)
Unity.VisualScripting.BackgroundWorker:Work () (at Library/PackageCache/[email protected]/Editor/VisualScripting.Core/Threading/BackgroundWorker.cs:157)
System.Threading.ThreadHelper:ThreadStart ()
text_ServerResponse width is set to 600, ideally this should be set dynamically so it fills the entire screen however the Vertical Layout Group component is constantly resetting the anchor preset to the top left. (text_ServerResponse should retain its position in the vertical layout while stretching its width to the full monitor width)
Always outputs zero meaning trees can even spawn on cliffs which is unwanted behavior.
This should output steepness values between 0 and 90
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.