public void createFight(BattleDataErlang battleData, ErlNullList el, int frame) { BattleClipErlang battleClip = new BattleClipErlang(); battleClip.frame = frame; battleData.battleClip.Add(battleClip); }
override public void bytesWrite(ByteBuffer data) { base.bytesWrite(data); if (_value == null || _value.Length < 1) { new ErlNullList().bytesWrite(data); } else { if (_value.Length > 0xff) { data.writeByte(TAG [1]); data.writeInt(_value.Length); } else { data.writeByte(TAG [0]); data.writeByte(_value.Length); } ErlBytesWriter erlBW; for (int i = 0; i < _value.Length; i++) { erlBW = _value [i] as ErlBytesWriter; if (erlBW == null) { erlBW = new ErlNullList(); } erlBW.bytesWrite(data); } } }
private static ErlType[] getErlArr(List <object> jsonList) { ErlType[] arr = new ErlType[jsonList.Count]; for (int i = 0; i < jsonList.Count; i++) { List <object> data = jsonList[i] as List <object>; ErlType erl = null; if (data[0] as string == typeof(ErlInt).Name) { erl = new ErlInt(StringKit.toInt(data[1].ToString())); } else if (data[0] as string == typeof(ErlString).Name) { erl = new ErlString(data[1].ToString()); } else if (data[0] as string == typeof(ErlByte).Name) { erl = new ErlByte(byte.Parse(data[1].ToString())); } else if (data[0] as string == typeof(ErlAtom).Name) { erl = new ErlAtom(data[1].ToString()); } else if (data[0] as string == typeof(ErlNullList).Name) { erl = new ErlNullList(); } else if (data[0] as string == typeof(ErlArray).Name) { erl = new ErlArray(getErlArr(data[1] as List <object>)); } arr[i] = erl; } return(arr); }
public static ErlType complexAnalyse(ByteBuffer data) { int position = data.position; int num2 = data.readByte(); data.position = position; if ((num2 == ErlArray.TAG[0]) || (num2 == ErlArray.TAG[1])) { ErlArray array = new ErlArray(null); array.bytesRead(data); return array; } switch (num2) { case 0x6a: { ErlNullList list = new ErlNullList(); list.bytesRead(data); return list; } case 0x6c: { ErlList list2 = new ErlList(null); list2.bytesRead(data); return list2; } case 100: { ErlAtom atom = new ErlAtom(null); atom.bytesRead(data); return atom; } case 0x6b: { ErlString str = new ErlString(null); str.sampleBytesRead(data); return str; } case 110: { ErlLong @long = new ErlLong(); @long.bytesRead(data); return @long; } case 0x6d: { ErlByteArray array2 = new ErlByteArray(null); array2.bytesRead(data); return array2; } } return null; }
public void bytesWriteValue(ByteBuffer sc_data, object value) { ErlType erlType = value as ErlType; if (erlType == null) { erlType = new ErlNullList(); } ByteBuffer data = new ByteBuffer(); erlType.bytesWrite(data); sc_data.writeBytes(data, 0, (uint)data.bytesAvailable); }
/// <summary> /// 二进制数据解析 走到这里,肯定是erlang标准二进制数据 /// </summary> /// <returns>The analyse.</returns> /// <param name="data">Data.</param> public static ErlType complexAnalyse(ByteBuffer data) { int position = data.position; int tag = data.readByte(); data.position = position; // MonoBehaviour.print("----------complexAnalyse--------------"+tag); if (tag == ErlArray.TAG [0] || tag == ErlArray.TAG [1]) { ErlArray erlArray = new ErlArray(null); erlArray.bytesRead(data); return(erlArray); } else if (tag == ErlNullList.TAG) { ErlNullList erlNullList = new ErlNullList(); erlNullList.bytesRead(data); return(erlNullList); } else if (tag == ErlList.TAG) { ErlList erlList = new ErlList(null); erlList.bytesRead(data); return(erlList); } else if (tag == ErlAtom.TAG) { ErlAtom erlAtom = new ErlAtom(null); erlAtom.bytesRead(data); return(erlAtom); } else if (tag == ErlString.TAG) { ErlString erlString = new ErlString(null); erlString.sampleBytesRead(data); return(erlString); } else { return(null); } }
public void bytesWriteValue(ByteBuffer sc_data, object value) { ErlType type = value as ErlType; if (type == null) { type = new ErlNullList(); } ByteBuffer data = new ByteBuffer(); type.bytesWrite(data); sc_data.writeBytes(data, 0, data.bytesAvailable); }
private static ErlType[] getErlArr(List<object> jsonList) { ErlType[] typeArray = new ErlType[jsonList.Count]; for (int i = 0; i < jsonList.Count; i++) { List<object> list = jsonList[i] as List<object>; ErlType type = null; if ((list[0] as string) == typeof(ErlInt).Name) { type = new ErlInt(StringKit.toInt(list[1].ToString())); } else if ((list[0] as string) == typeof(ErlString).Name) { type = new ErlString(list[1].ToString()); } else if ((list[0] as string) == typeof(ErlByte).Name) { type = new ErlByte(byte.Parse(list[1].ToString())); } else if ((list[0] as string) == typeof(ErlAtom).Name) { type = new ErlAtom(list[1].ToString()); } else if ((list[0] as string) == typeof(ErlNullList).Name) { type = new ErlNullList(); } else if ((list[0] as string) == typeof(ErlArray).Name) { type = new ErlArray(getErlArr(list[1] as List<object>)); } typeArray[i] = type; } return typeArray; }
public override void bytesWrite(ByteBuffer data) { base.bytesWrite(data); if ((this._value == null) || (this._value.Length < 1)) { //new ErlNullList().bytesWrite(data); //(new ErlType[0]). data.writeByte(TAG[0]); data.writeByte(0); } else { if (this._value.Length > 0xff) { data.writeByte(TAG[1]); data.writeInt(this._value.Length); } else { data.writeByte(TAG[0]); data.writeByte(this._value.Length); } for (int i = 0; i < this._value.Length; i++) { ErlBytesWriter writer = this._value[i]; if (writer == null) { writer = new ErlNullList(); } writer.bytesWriteServer(data); } } }
public void bytesWriteValue(ByteBuffer sc_data, object value) { ErlType type = value as ErlType; if (type == null) { type = new ErlNullList(); } ByteBuffer data = new ByteBuffer(); if (type.GetType ().ToString () == "ErlArray"||type.GetType ().ToString () == "ErlAtom") { data.writeByte ((byte)0x83); Log.Info (type.GetType ().ToString ()); type.bytesWriteServer (data); sc_data.writeByte (0); sc_data.writeByte ((byte)data.bytesAvailable); sc_data.writeBytes (data, 0, data.bytesAvailable); } else { type.bytesWrite (data); sc_data.writeBytes (data, 0, data.bytesAvailable); } }