static FakeStructArray SaveCategory(DataBuffer buffer) { FakeStructArray array = new FakeStructArray(buffer, 4, lsc.Count); for (int i = 0; i < lsc.Count; i++) { array.SetData(i, 0, lsc[i].txtName); array.SetData(i, 1, SaveSprites(buffer, lsc[i].sprites)); array.SetInt32(i, 2, lsc[i].width); array.SetInt32(i, 3, lsc[i].height); } return(array); }
static void QueryRoom(KcpUser linker, DataBuffer buffer) { var list = RoomManager.QueryFreeRoom(); if (list.Count == 0) { ErrorCode.SendErrorCode(linker, ErrorCode.NoFreeRoom); return; } DataBuffer db = new DataBuffer(); FakeStruct fake = new FakeStruct(db, Req.Length); fake[Req.Cmd] = QueryCmd.QueryRoom; fake[Req.Type] = MessageType.Query; db.fakeStruct = fake; int c = list.Count; FakeStructArray array = new FakeStructArray(db, 3, c); for (int i = 0; i < c; i++) { var room = list[i]; array[c, 0] = room.RoomId; array[c, 1] = room.Number; array.SetData(c, 2, room.Name); } fake.SetData(Req.Args, array); linker.Send(AES.Instance.Encrypt(db.ToBytes()), EnvelopeType.AesDataBuffer); }
/// <summary> /// 存储布局数据 /// </summary> /// <param name="fake"></param> /// <param name="index"></param> public void SaveToDataBuffer(FakeStructArray fake, int index) { fake[index, 0] = (int)direction; fake.SetFloat(index, 1, Enity.m_sizeDelta.x); fake.SetFloat(index, 2, Enity.m_sizeDelta.y); fake.SetFloat(index, 3, Enity.transform.localPosition.x); fake.SetFloat(index, 4, Enity.transform.localPosition.y); fake[index, 5] = layout.GetLineID(LineStart); fake[index, 6] = layout.GetLineID(LineEnd); fake.SetData(index, 7, SaveAdjacentArea(Left)); fake.SetData(index, 8, SaveAdjacentArea(Right)); fake.SetData(index, 9, SaveAdjacentArea(Top)); fake.SetData(index, 10, SaveAdjacentArea(Down)); if (AdjacentLines.Count > 0) { int[] tmp = new int[AdjacentLines.Count]; for (int i = 0; i < tmp.Length; i++) { tmp[i] = layout.GetLineID(AdjacentLines[i]); } fake.SetData(index, 11, tmp); } }
static void GetAllServerIp(KcpUser linker, DataBuffer data) { int index = data.fakeStruct[Req.Args]; var info = ServerTable.GetAllServer(); int c = info.Count; if (c > 0) { DataBuffer db = new DataBuffer(); FakeStruct fake = new FakeStruct(db, Req.Length); fake[Req.Cmd] = ProCmd.AllServer; fake[Req.Type] = MessageType.Pro; FakeStructArray array = new FakeStructArray(db, 3, c); for (int i = 0; i < c; i++) { array[i, 0] = info[i].ip; array[i, 1] = info[i].port; array.SetData(i, 2, info[i].name); } fake.SetData(Req.Args, array); db.fakeStruct = fake; linker.Send(AES.Instance.Encrypt(db.ToBytes()), EnvelopeType.AesDataBuffer); } }