public void SetGame(Game game) { lock (gameLock) { if (Viewport != null) { Viewport.CleanUp(); DeleteChild(Viewport); Viewport = null; } Game = game; player = null; if (Game != null) { if (game.Map == null) { SetGame(null); Log.Debug.Write(ErrorSystemType.Game, "Internal error. Map is null."); return; } game.Map.AttachToRenderLayer(RenderView.GetLayer(Freeserf.Layer.Landscape), RenderView.GetLayer(Freeserf.Layer.Waves), RenderView.DataSource); // Note: The render map must be created above with AttachToRenderLayer before viewport creation. Viewport = new Viewport(this, Game.Map); Viewport.Displayed = true; AddChild(Viewport, 0, 0); } Layout(); } }
void AddBuildingRoadSegment(MapPos position, Direction direction) { // We only support road segments in direcitons Right, DownRight and Down. // So if it is another direction, we use the reverse direction with the opposite position. if (direction > Direction.Down) { position = Game.Map.Move(position, direction); direction = direction.Reverse(); } var segment = new RenderRoadSegment(Game.Map, position, direction, RenderView.GetLayer(Freeserf.Layer.Paths), RenderView.SpriteFactory, RenderView.DataSource); segment.Visible = true; buildingRoadSegments.Push(segment); }