private FrameworkElement RenderActiveObject(MapActiveObjectState activeObject, Rect area) { if (activeObject == null) { return(null); } if (activeObject.ActiveObject == null) { return(null); } MapImageWPF imageSource = new MapImageWPF(activeObject.Image); Image image = new Image { Source = imageSource.Image, Stretch = Stretch.Fill }; double wallWidth = area.Width * WallPadding; double wallHeight = area.Height * WallPadding; double imageWidth = area.Width - wallWidth * 2; double imageHeight = area.Height - wallHeight * 2; Canvas.SetLeft(image, area.Left + wallWidth); Canvas.SetTop(image, area.Top + wallHeight); image.Width = imageWidth; image.Height = imageHeight; return(image); }
private static MapState DeserializeMapState(BinaryReader Reader, Map map) { MapState state = new MapState(map); for (UInt16 z = 0; z < map.Levels.Length; z++) { for (UInt16 x = 0; x < map.Size.Width; x++) { for (UInt16 y = 0; y < map.Size.Height; y++) { state.Levels[z].Cells[x, y] = DeserializeMapCellState(Reader, map.Levels[z].Cells[x, y], new MapPoint(z, x, y)); } } } state.Areas = DeserializeMapAreasState(Reader, map.Areas); int activeObjectsCount = DeserializeLength(Reader); for (int i = 0; i < activeObjectsCount; i++) { Guid id = DeserializeGuid(Reader); MapActiveObjectState activeObject = DeserializeMapActiveObjectState(Reader, map.TileSet); state.AddActiveObject(activeObject, id); } return(state); }
public static MapActiveObjectState DeserializeMapActiveObjectState(BinaryReader Reader, MapTileSet mapTileSet) { Guid activeObjectId = DeserializeMapObjectReference(Reader); if (activeObjectId == Guid.Empty) { return(null); } MapActiveObject activeObject = null; if ((mapTileSet != null) && mapTileSet.ContainsId(activeObjectId)) { activeObject = mapTileSet[activeObjectId] as MapActiveObject; } if (activeObject == null) { return(null); } MapPoint position = DeserializeMapPoint(Reader); MapActiveObjectState state = new MapActiveObjectState(activeObject, position); state.Direction = DeserializeMapDirection(Reader); state.ArmorType = DeserializeMapArmorType(Reader); state.Health = Reader.ReadUInt16(); return(state); }
public static void SerializeMapActiveObjectState(BinaryWriter Writer, MapActiveObjectState ActiveObjectState) { SerializeMapVisualObjectState(Writer, ActiveObjectState); SerializeMapObjectReference(Writer, ActiveObjectState.ActiveObject); SerializeMapPoint(Writer, ActiveObjectState.Position); SerializeMapDirection(Writer, ActiveObjectState.Direction); SerializeMapArmorType(Writer, ActiveObjectState.ArmorType); Writer.Write(ActiveObjectState.Health); }
public static MapActiveObjectState DeserializeMapActiveObjectState(BinaryReader Reader, MapTileSet mapTileSet) { Guid activeObjectId = DeserializeMapObjectReference(Reader); if (activeObjectId == Guid.Empty) return null; MapActiveObject activeObject = null; if ((mapTileSet != null) && mapTileSet.ContainsId(activeObjectId)) activeObject = mapTileSet[activeObjectId] as MapActiveObject; if (activeObject == null) return null; MapPoint position = DeserializeMapPoint(Reader); MapActiveObjectState state = new MapActiveObjectState(activeObject, position); state.Direction = DeserializeMapDirection(Reader); state.ArmorType = DeserializeMapArmorType(Reader); state.Health = Reader.ReadUInt16(); return state; }
public static void SerializeMapActiveObjectState(BinaryWriter Writer, MapActiveObjectState ActiveObjectState) { SerializeMapVisualObjectState(Writer, ActiveObjectState); SerializeMapObjectReference(Writer, ActiveObjectState.ActiveObject); SerializeMapPoint(Writer, ActiveObjectState.Position); SerializeMapDirection(Writer, ActiveObjectState.Direction); SerializeMapArmorType(Writer, ActiveObjectState.ArmorType); Writer.Write(ActiveObjectState.Health); }