/// <summary> /// /// </summary> /// <param name="sendFunc">int func(byte[],int offset, int size). send를 누를 때 buff를 보낼 sendFunction.</param> /// <param name="endian"></param> /// <param name="isStringWithNullEnd"></param> /// <param name="stringEncoding"></param> public void setEnv(SendFunc sendFunc, Endians endian = Endians.Big, bool isStringWithNullEnd = false, StrEncoding stringEncoding = StrEncoding.UTF8) { _endian = endian; _isStringWithNullEnd = isStringWithNullEnd; switch (stringEncoding) { case StrEncoding.Unicode: _strEncoding = Encoding.Unicode; break; case StrEncoding.UTF8: _strEncoding = Encoding.UTF8; break; case StrEncoding.UTF7: _strEncoding = Encoding.UTF7; break; case StrEncoding.UTF32: _strEncoding = Encoding.UTF32; break; case StrEncoding.ASCII: _strEncoding = Encoding.ASCII; break; } _sendFunc = sendFunc; initList(); }
public GameCoreServer ( int width, int height, Size playerSize, Size playerOnDeathSize, Size bombSize, Size explosionSize, Size wallSize, string dirResources, SendFunc sendFunc ) { this.map = new PhysicalMap(width, height); objectsList = new ObjectsLists(); spawnPoints = new List <Point>(); this.sendFunc = sendFunc; timer = new Timer(); delay = 60; timer.Interval = delay; timer.Elapsed += TimerEvent; randomGen = new Random(); scriptEngine = new ScriptEngine(); this.playerSize = playerSize; this.bombSize = bombSize; this.explosionSize = explosionSize; this.wallSize = wallSize; this.playerOnDeathSize = playerOnDeathSize; GenerateWalls(); }
// Encode public void Encode(float[] floats, SendFunc send) { byte[] bytes = new byte[floats.Length]; for(int i = 0; i < bytes.Length; i++) { bytes[i] = (byte)(floats[i] * 127f + 128); } send(bytes, bytes.Length); }
// Encode public void Encode(float[] floats, SendFunc send) { byte[] bytes = new byte[floats.Length]; for (int i = 0; i < bytes.Length; i++) { bytes[i] = (byte)(floats[i] * 127f + 128); } send(bytes, bytes.Length); }
// Encode public void Encode(float[] floats, SendFunc send) { int len = floats.Length * 4; byte[] bytes = new byte[len]; int pos = 0; // TODO: Pretty sure this could be done faster... foreach (float f in floats) { byte[] data = System.BitConverter.GetBytes(f); System.Array.Copy(data, 0, bytes, pos, 4); pos += 4; } send(bytes, bytes.Length); }
// Encode public void Encode(float[] floats, SendFunc send) { byte[] bytes = CLZF2.Compress(SnapByte.EncodeFloats(floats)); send(bytes, bytes.Length); }