public void MoveUser(RoomSlot rs, int Scale) { XPos = rs.XPos; YPos = rs.YPos; Size = Scale * 3; RoomSlotIndex = rs.IndexNumber; }
/** * Draws the position of the all clients in the client dict */ private void DrawClientPositions() { //Free all room positions foreach (Room r in currentMap) { r.FreeAllSlots(); } //If there is a local client(there should be!) Centre the map on them //And draw them if (LocalClient != null) { RoomSlot prs = currentMap[LocalClient.RoomNum].GetNextRoomSlot(3 * Scale); LocalClient.MoveUser(prs, Scale); XOffset = -LocalClient.XPos + Width / 2; YOffset = -LocalClient.YPos + Height / 2; LocalClient.DrawMe(G, XOffset, YOffset); } //for all other clients draw regularly. foreach (KeyValuePair <String, User> u in ClientDrawDict) { RoomSlot rs = currentMap[u.Value.RoomNum].GetNextRoomSlot(3 * Scale); if (rs != null && u.Key != LocalClient.Name) { u.Value.MoveUser(rs, Scale); u.Value.DrawMe(G, XOffset, YOffset); } } }
/** * Gets roomslots (basically just positions) * Filling from the middle then out * @param PLayerSize if not roomslots it will use this to generate new ones */ public RoomSlot GetNextRoomSlot(int PlayerSize) { if (!HasSlots) { MakeRoomSpaces(PlayerSize); } int index = RoomSlotList.Count / 2; int iter = 0; bool flipFlop = true; while (index >= 0 && index < RoomSlotList.Count) { RoomSlot rs = RoomSlotList[index]; if (!rs.InUse) { rs.IndexNumber = index; InUseSlots.Add(index); rs.InUse = true; return(rs); } //alternate between getting ones to the left and to the right of the middle index = RoomSlotList.Count / 2; if (flipFlop) { index += iter; flipFlop = false; } else { index -= iter; iter++; flipFlop = true; } } return(null); }