Ejemplo n.º 1
0
 private void Initialize()
 {
     Map = new Map();
     _renderer = new MapRenderer();
     InitializeViewport();
     Touch += MapControl_Touch;
 }
Ejemplo n.º 2
0
		public void Initialize() 
		{
			Map = new Map();

			_renderer = new MapRenderer();
			BackgroundColor = UIColor.White;
		
			InitializeViewport();

			ClipsToBounds = true;

			var pinchGesture = new UIPinchGestureRecognizer(PinchGesture) { Enabled = true };
			AddGestureRecognizer(pinchGesture);

			UIDevice.Notifications.ObserveOrientationDidChange((n, a) => {
				if (this.Window != null) {

					// after rotation all textures show up as white. I don't know why. 
					// By deleting all textures they are rebound and they show up properly.
					_renderer.DeleteAllBoundTextures();	

					Frame = new CGRect (0, 0, Frame.Width, Frame.Height);
					Map.Viewport.Width = Frame.Width;
					Map.Viewport.Height = Frame.Height;
					Map.NavigateTo(Map.Viewport.Extent);
				}});
							
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new map control.
        /// </summary>
        public MapControl()
        {
            InitializeComponent();

            this.DoubleBuffered = true;
            _renderer = new MapRenderer<Graphics>(new GraphicsRenderer2D());

            this.MapAllowPan = true;
            this.MapAllowZoom = true;
        }
Ejemplo n.º 4
0
        public MasterRenderer(DataMaster dataMaster)
        {
            this.dataMaster = dataMaster;

            UnitRenderers = new List<UnitRenderer>(dataMaster.Units.Count);

            mapRenderer = new MapRenderer(dataMaster.map);
            interfaceBarRenderer = new InterfaceBarRenderer(dataMaster.InterfaceBar);
            initUnitsRenderers();
        }
Ejemplo n.º 5
0
        public void RenderPointsWithDifferentSymbolTypes()
        {
            // arrange
            var map = ArrangeRenderingTests.PointsWithDifferentSymbolTypes();
            const string fileName = "vector_symbol_symboltype.png";
            
            // act
            var bitmap = new MapRenderer().RenderToBitmapStream(map.Viewport, map.Layers);

            // aside
            File.Write(fileName, bitmap);

            // assert
            Assert.AreEqual(File.Read(fileName).ToArray(), bitmap.ToArray());
        }
Ejemplo n.º 6
0
        public void RenderRotatedBitmapSymbolWithOffset()
        {
            // arrange
            var map = ArrangeRenderingTests.PointsWithBitmapRotatedAndOffset();
            const string fileName = "bitmap_symbol.png";

            // act
            var bitmap = new MapRenderer().RenderToBitmapStream(map.Viewport, map.Layers);

            // aside
            File.Write(fileName, bitmap);

            // assert
            Assert.AreEqual(File.Read(fileName).ToArray(), bitmap.ToArray());
        }
Ejemplo n.º 7
0
        public Ets2MapDemo()
        {
            var projectMap = @"C:\Projects\Software\ets2-map\";

            map = new Ets2Mapper(
                projectMap + @"SCS\europe\",
                projectMap + @"SCS\prefab",
                projectMap + @"SCS\LUT1.19",
                projectMap + @"LUT\LUT1.19");
            map.Parse(true);

            render = new MapRenderer(map, new SimpleMapPalette());

            InitializeComponent();

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);

            refresh = new Timer();
            refresh.Interval = 250;
            refresh.Tick += (sender, args) => Invalidate();
            refresh.Start();

            // Panning around
            MouseDown += (s, e) => dragPoint = e.Location;
            MouseUp += (s, e) => dragPoint = null;
            MouseMove += (s, e) =>
            {
                if (dragPoint.HasValue)
                {
                    var spd = mapScale/Math.Max(this.Width, this.Height);
                    location = new Ets2Point(location.X - (e.X - dragPoint.Value.X)*spd,
                        0,
                        location.Z - (e.Y - dragPoint.Value.Y)*spd,
                        0);
                    dragPoint = e.Location;
                }
            };

            // Zooming in
            MouseWheel += Ets2MapDemo_MouseWheel;

            // Navigation
            MouseDoubleClick += Ets2MapDemo_MouseDoubleClick;

            Resize += Ets2MapDemo_Resize;
        }
Ejemplo n.º 8
0
        public static void RenderSymbolWithVectorStyle()
        {
            // arrange
            var viewport = new Viewport { Center = new Point(100, 100), Width = 200, Height = 200, Resolution = 1 };
            var layer = new InMemoryLayer();
            layer.MemoryProvider.Features.Add(new Feature { Geometry = new Point(50, 50), Styles = new[] { new VectorStyle { Fill = new Brush(Color.Red)} } });
            layer.MemoryProvider.Features.Add(new Feature { Geometry = new Point(50, 100), Styles = new[] { new VectorStyle { Fill = new Brush(Color.Yellow), Outline = new Pen(Color.Black, 2) } } });
            layer.MemoryProvider.Features.Add(new Feature { Geometry = new Point(100, 50), Styles = new[] { new VectorStyle { Fill = new Brush(Color.Blue), Outline = new Pen(Color.White, 2) } } });
            layer.MemoryProvider.Features.Add(new Feature { Geometry = new Point(100, 100), Styles = new[] { new VectorStyle { Fill = new Brush(Color.Green), Outline = null } } });
            var layers = new[] { layer };
            var renderer = new MapRenderer();
            const string imagePath = ImagesFolder + "\\vector_symbol.png";

            // act
            renderer.Render(viewport, layers);
            var bitmap = renderer.ToBitmapStream(viewport.Width, viewport.Height);

            // aside
            if (Rendering.Default.WriteImageToDisk) WriteToDisk(imagePath, bitmap);

            // assert
            Assert.AreEqual(ReadFile(imagePath), bitmap.ToArray());
        }
Ejemplo n.º 9
0
        public static void RenderSymbolWithUnitTypes()
        {
            // arrange
            var viewport = new Viewport { Center = new Point(0, 0), Width = 200, Height = 100, Resolution = 0.5 };
            var features = new Features
                {
                    CreateFeature(-20, 0, new SymbolStyle {UnitType = UnitType.Pixel}),
                    CreateFeature(20, 0, new SymbolStyle {UnitType = UnitType.WorldUnit})
                };
            var layers = new[] { new InMemoryLayer(new MemoryProvider(features)) };
            var renderer = new MapRenderer();
            const string imagePath = ImagesFolder + "\\vector_symbol_unittype.png";
            
            // act
            renderer.Render(viewport, layers);
            var bitmap = renderer.ToBitmapStream(viewport.Width, viewport.Height);

            // aside
            if (Rendering.Default.WriteImageToDisk) WriteToDisk(imagePath, bitmap);

            // assert
            Assert.AreEqual(ReadFile(imagePath), bitmap.ToArray());
        }
Ejemplo n.º 10
0
    public bool Raycast(
        RayStep step,
        LayerMask[] prioritizedLayerMasks,
        bool focusIndividualCompoundCollider,
        out MixedRealityRaycastHit hitInfo)
    {
        var hasPhysicsHit =
            MixedRealityRaycaster.RaycastSimplePhysicsStep(
                step,
                prioritizedLayerMasks,
                focusIndividualCompoundCollider,
                out RaycastHit physicsHit);

        MapRendererRaycastHit?closestMapHitInfo  = null;
        MapRenderer           closestMapRenderer = null;

        foreach (var mapRenderer in _mapRenderers)
        {
            if (
                mapRenderer.Raycast(
                    step,
                    out var mapHitInfo,
                    hasPhysicsHit ? physicsHit.distance : step.Length))
            {
                if (hasPhysicsHit)
                {
                    if (physicsHit.distance > mapHitInfo.Distance)
                    {
                        if (!closestMapHitInfo.HasValue || closestMapHitInfo.Value.Distance > mapHitInfo.Distance)
                        {
                            closestMapRenderer = mapRenderer;
                            closestMapHitInfo  = mapHitInfo;
                        }
                    }
                }
                else
                {
                    if (!closestMapHitInfo.HasValue || closestMapHitInfo.Value.Distance > mapHitInfo.Distance)
                    {
                        closestMapRenderer = mapRenderer;
                        closestMapHitInfo  = mapHitInfo;
                    }
                }
            }
        }

        if (closestMapHitInfo != null)
        {
            hitInfo = new MixedRealityRaycastHit();
            var mapRendererHitInfo = closestMapHitInfo.Value;
            hitInfo.distance  = mapRendererHitInfo.Distance;
            hitInfo.point     = mapRendererHitInfo.Point;
            hitInfo.normal    = mapRendererHitInfo.Normal;
            hitInfo.transform = closestMapRenderer.transform;
            return(true);
        }
        else
        {
            hitInfo = new MixedRealityRaycastHit(hasPhysicsHit, physicsHit);
            return(hasPhysicsHit);
        }
    }
Ejemplo n.º 11
0
            private void Update()
            {
                if (MapView.MapIsEnabled && map_renderer_ == null) {
                  map_renderer_ = MapView.MapCamera.gameObject.AddComponent<MapRenderer>();
                  map_renderer_.render_on_pre_cull = RenderTrajectories;
                }
                override_rsas_target_ = false;
                Vessel active_vessel = FlightGlobals.ActiveVessel;
                if (active_vessel != null &&
                !FlightGlobals.ActiveVessel.isEVA) {
                  if (navball_ == null) {
                navball_ = (NavBall)FindObjectOfType(typeof(NavBall));
                  }
                  if (compass_navball_texture_ == null) {
                compass_navball_texture_ =
                navball_.navBall.renderer.material.mainTexture;
                  }

                  if (navball_changed_) {
                // Texture the ball.
                navball_changed_ = false;
                if (!fix_navball_in_plotting_frame_ || !PluginRunning()) {
                  navball_.navBall.renderer.material.mainTexture =
                  compass_navball_texture_;
                } else if (first_selected_celestial_ == second_selected_celestial_) {
                  navball_.navBall.renderer.material.mainTexture =
                  inertial_navball_texture_;
                } else {
                  navball_.navBall.renderer.material.mainTexture =
                  barycentric_navball_texture_;
                }
                  }

                  if (PluginRunning() && fix_navball_in_plotting_frame_) {
                // Orient the ball.
                navball_.navBall.rotation =
                (UnityEngine.QuaternionD)navball_.attitudeGymbal *  // sic.
                (UnityEngine.QuaternionD)NavballOrientation(
                    plugin_,
                    transforms_,
                    (XYZ)Planetarium.fetch.Sun.position,
                    (XYZ)(Vector3d)active_vessel.ReferenceTransform.position);
                // TODO(egg): the navball should be independent from the frame of the
                // Frenet trihedron (seeing your body-centric velocity with a compass
                // navball like in stock makes sense, so does seeing your velocity in
                // any reference frame with the fixed stars navball), although the
                // Frenet trihedron should be in the same frame as the map view
                // trajectory.  Right now when in space the navball is always linked to
                // the frame of the Frenet trihedron and the trajectory.
                if (has_active_vessel_in_space() &&
                has_vessel(plugin_, active_vessel.id.ToString())) {
                  // Orient the Frenet trihedron.
                  // TODO(egg): just the tangent for now.
                  Vector3d prograde =
                  (Vector3d)VesselTangent(plugin_,
                                      active_vessel.id.ToString(),
                                      transforms_);
                  navball_.progradeVector.transform.localPosition =
                  (UnityEngine.QuaternionD)navball_.attitudeGymbal *
                  prograde * 0.05;
                  navball_.retrogradeVector.transform.localPosition =
                  -navball_.progradeVector.transform.localPosition;
                  // Make the autopilot target our Frenet trihedron.
                  // TODO(egg): just the tangent for now.
                  if (active_vessel.OnAutopilotUpdate.GetInvocationList()[0] !=
                  (Delegate)(FlightInputCallback)OverrideRSASTarget) {
                Log.Info("Prepending RSAS override");
                active_vessel.OnAutopilotUpdate =
                (FlightInputCallback)Delegate.Combine(
                    new FlightInputCallback(OverrideRSASTarget),
                    active_vessel.OnAutopilotUpdate);
                  }
                  if (active_vessel.Autopilot.Enabled) {
                override_rsas_target_ = true;
                switch (active_vessel.Autopilot.Mode) {
                  case VesselAutopilot.AutopilotMode.Prograde:
                rsas_target_ = prograde;
                break;
                  case VesselAutopilot.AutopilotMode.Retrograde:
                rsas_target_ = -prograde;
                break;
                  default:
                override_rsas_target_ = false;
                break;
                }
                  }
                }
                  }
                }
            }
        /// <summary>
        /// Tests rendering the given serialized scene.
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="box"></param>
        /// <param name="testCount"></param>
        public static void TestRenderScene(Stream stream, GeoCoordinateBox box, int testCount)
        {
            WebMercator projection = new WebMercator();

            // build a map.
            Map map = new Map();
            IScene2DPrimitivesSource sceneSource = Scene2DLayered.Deserialize(stream, true);
            LayerScene layerScene = map.AddLayerScene(sceneSource);

            // build the target to render to.
            Bitmap imageTarget = new Bitmap(TargetWidth, TargetHeight);
            Graphics target = Graphics.FromImage(imageTarget);
            target.SmoothingMode = SmoothingMode.HighQuality;
            target.PixelOffsetMode = PixelOffsetMode.HighQuality;
            target.CompositingQuality = CompositingQuality.HighQuality;
            target.InterpolationMode = InterpolationMode.HighQualityBicubic;
            MapRenderer<Graphics> mapRenderer = new MapRenderer<Graphics>(
                new GraphicsRenderer2D());

            // render the map.
            PerformanceInfoConsumer performanceInfo = new PerformanceInfoConsumer("Scene2DLayeredRendering");
            performanceInfo.Start();
            performanceInfo.Report("Rendering {0} random images...", testCount);

            while (testCount > 0)
            {
                // randomize view.
                int zoom = OsmSharp.Math.Random.StaticRandomGenerator.Get().Generate(10) + 10;
                GeoCoordinate center = box.GenerateRandomIn();
                View2D view = mapRenderer.Create(TargetWidth, TargetHeight, map,
                    (float)projection.ToZoomFactor(zoom), center, false, true);

                layerScene.ViewChanged(map, (float)projection.ToZoomFactor(zoom), center, view);

                mapRenderer.Render(target, map, view);

                if (WriteResults)
                {
                    imageTarget.Save(Guid.NewGuid().ToString() + ".png", ImageFormat.Png);
                }

                testCount--;
            }

            performanceInfo.Stop();
        }
Ejemplo n.º 13
0
            private void Update()
            {
                if (MapView.MapIsEnabled && map_renderer_ == null) {
                  map_renderer_ = MapView.MapCamera.gameObject.AddComponent<MapRenderer>();
                  map_renderer_.render_on_pre_cull = RenderTrajectories;
                }
                override_rsas_target_ = false;
                Vessel active_vessel = FlightGlobals.ActiveVessel;
                if (active_vessel != null &&
                !FlightGlobals.ActiveVessel.isEVA) {
                  if (navball_ == null) {
                navball_ = (NavBall)FindObjectOfType(typeof(NavBall));
                  }
                  if (compass_navball_texture_ == null) {
                compass_navball_texture_ =
                navball_.navBall.renderer.material.mainTexture;
                  }

                  if (navball_changed_) {
                // Texture the ball.
                navball_changed_ = false;
                // TODO(egg): switch over all frame types and have more navball textures
                // when more frames are available.
                if (!fix_navball_in_plotting_frame_ || !PluginRunning()) {
                  navball_.navBall.renderer.material.mainTexture =
                  compass_navball_texture_;
                } else if (plotting_frame_selector_.get().frame_type ==
                   ReferenceFrameSelector.FrameType.BODY_CENTRED_NON_ROTATING) {
                  navball_.navBall.renderer.material.mainTexture =
                  inertial_navball_texture_;
                } else {
                  navball_.navBall.renderer.material.mainTexture =
                  barycentric_navball_texture_;
                }
                  }

                  if (PluginRunning() && fix_navball_in_plotting_frame_) {
                // Orient the ball.
                navball_.navBall.rotation =
                (UnityEngine.QuaternionD)navball_.attitudeGymbal *  // sic.
                (UnityEngine.QuaternionD)plugin_.NavballOrientation(
                    (XYZ)Planetarium.fetch.Sun.position,
                    (XYZ)(Vector3d)active_vessel.ReferenceTransform.position);
                // TODO(egg): the navball should be independent from the frame of the
                // Frenet trihedron (seeing your body-centric velocity with a compass
                // navball like in stock makes sense, so does seeing your velocity in
                // any reference frame with the fixed stars navball), although the
                // Frenet trihedron should be in the same frame as the map view
                // trajectory.  Right now when in space the navball is always linked to
                // the frame of the Frenet trihedron and the trajectory.
                if (has_active_vessel_in_space() &&
                  plugin_.HasVessel(active_vessel.id.ToString())) {
                  // Orient the Frenet trihedron.
                  Vector3d prograde =
                  (Vector3d)plugin_.VesselTangent(active_vessel.id.ToString());
                  Vector3d radial =
                  (Vector3d)plugin_.VesselNormal(active_vessel.id.ToString());
                  // Yes, the astrodynamicist's normal is the mathematician's binormal.
                  // Don't ask.
                  Vector3d normal =
                  (Vector3d)plugin_.VesselBinormal(active_vessel.id.ToString());

                  navball_.progradeVector.transform.localPosition =
                  (UnityEngine.QuaternionD)navball_.attitudeGymbal *
                  prograde * 0.05;
                  navball_.radialInVector.transform.localPosition =
                  (UnityEngine.QuaternionD)navball_.attitudeGymbal *
                  radial * 0.05;
                  navball_.normalVector.transform.localPosition =
                  (UnityEngine.QuaternionD)navball_.attitudeGymbal *
                  normal * 0.05;
                  navball_.retrogradeVector.transform.localPosition =
                  -navball_.progradeVector.transform.localPosition;
                  navball_.radialOutVector.transform.localPosition =
                  -navball_.radialInVector.transform.localPosition;
                  navball_.antiNormalVector.transform.localPosition =
                  -navball_.normalVector.transform.localPosition;
                  // Make the autopilot target our Frenet trihedron.
                  if (active_vessel.OnAutopilotUpdate.GetInvocationList()[0] !=
                  (Delegate)(FlightInputCallback)OverrideRSASTarget) {
                Log.Info("Prepending RSAS override");
                active_vessel.OnAutopilotUpdate =
                (FlightInputCallback)Delegate.Combine(
                    new FlightInputCallback(OverrideRSASTarget),
                    active_vessel.OnAutopilotUpdate);
                  }
                  if (active_vessel.Autopilot.Enabled) {
                override_rsas_target_ = true;
                switch (active_vessel.Autopilot.Mode) {
                  case VesselAutopilot.AutopilotMode.Prograde:
                rsas_target_ = prograde;
                break;
                  case VesselAutopilot.AutopilotMode.Retrograde:
                rsas_target_ = -prograde;
                break;
                  case VesselAutopilot.AutopilotMode.RadialIn:
                rsas_target_ = radial;
                break;
                  case VesselAutopilot.AutopilotMode.RadialOut:
                rsas_target_ = -radial;
                break;
                  case VesselAutopilot.AutopilotMode.Normal:
                rsas_target_ = normal;
                break;
                  case VesselAutopilot.AutopilotMode.Antinormal:
                rsas_target_ = -normal;
                break;
                  default:
                override_rsas_target_ = false;
                break;
                }
                  }
                }
                  }
                }
            }
        /// <summary>
        /// Renders the given data onto a 100x100 image using bounds around null-island (1,1,-1,-1) and the MapCSS definition.
        /// </summary>
        /// <param name="dataSource"></param>
        /// <param name="mapCSS"></param>
        /// <returns></returns>
        private Bitmap Render(IDataSourceReadOnly dataSource, string mapCSS)
        {
            // create projection.
            WebMercator projection = new WebMercator();
            double[] topLeft = projection.ToPixel(new Math.Geo.GeoCoordinate(1, 1));
            double[] bottomRight = projection.ToPixel(new Math.Geo.GeoCoordinate(-1, -1));

            // create view (this comes down to (1,1,-1,-1) for a size of 100x100).
            View2D view = View2D.CreateFromBounds(bottomRight[1], topLeft[0], topLeft[1], bottomRight[0]);
            //View2D view = View2D.CreateFrom(0, 0, 100, 100, 1.0 / 200.0, false, true);

            // create graphics
            Bitmap rendering = new Bitmap(100, 100);
            Graphics renderingGraphics = Graphics.FromImage(rendering);
            renderingGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            renderingGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            renderingGraphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            renderingGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            // create renderer.
            GraphicsRenderer2D graphicsRenderer = new GraphicsRenderer2D();
            MapRenderer<Graphics> renderer = new MapRenderer<Graphics>(graphicsRenderer);

            // create map.
            OsmSharp.UI.Map.Map map = new OsmSharp.UI.Map.Map();
            map.AddLayer(new LayerOsm(dataSource, new MapCSSInterpreter(mapCSS), projection));

            // notify the map that there was a view change!
            map.ViewChanged((float)view.CalculateZoom(100, 100), new Math.Geo.GeoCoordinate(0, 0), view);

            // ... and finally do the actual rendering.
            renderer.Render(Graphics.FromImage(rendering), map, view);

            //rendering.Save(@"c:\temp\rendering.bmp");

            return rendering;
        }
Ejemplo n.º 15
0
 public void UnregisterMapRenderer(MapRenderer mapRenderer)
 {
     _mapRenderers.Remove(mapRenderer);
 }
Ejemplo n.º 16
0
 public DisableCommand(MapRenderer MapRenderer)
     : base("disable", Help)
 {
     this.MapRenderer = MapRenderer;
 }
Ejemplo n.º 17
0
 private void Awake()
 {
     _mapRenderer = GetComponent <MapRenderer>();
 }
Ejemplo n.º 18
0
 public void Start()
 {
     passButton50.onClick.AddListener(Render50Passes);
     this.mapRenderer  = mainRenderCam.GetComponent <MapRenderer>();
     this.burnRenderer = burnRenderCam.GetComponent <BurnRenderer>();
 }
Ejemplo n.º 19
0
 public RegressionMapControl()
 {
     Renderer         = new MapRenderer();
     _limitedViewport = new LimitedViewport();
 }
 private void Awake()
 {
     _camera      = Camera.main;
     _mapRenderer = GetComponent <MapRenderer>();
 }
Ejemplo n.º 21
0
        public void LookMode(PlayerTurnEvent e, bool startInTravelMode = false, TravelDestinationPriority travelPriority = TravelDestinationPriority.Explore)
        {
            bool         travelMode         = startInTravelMode;
            List <Point> travelDestinations = GetTravelDestinations(travelPriority);            //todo, start this as null or not?
            DijkstraMap  playerMovementMap  = new DijkstraMap(point => (!Map.Seen[point] || !TileDefinition.IsPassable(TileTypeAt(point)))? -1 : 10);

            playerMovementMap.Scan(Player.Position);
            PointArray <bool> knownReachable           = null;
            DijkstraMap       distanceToKnownReachable = null;
            int   travelIndex = 0;
            Point p           = travelDestinations[0];

            while (true)
            {
                Screen.HoldUpdates();
                Screen.Clear(MessageBuffer.RowOffset, ColOffset, 4, MapDisplayWidth);
                Screen.Clear(GameRunUI.EnviromentalDescriptionRow, ColOffset, 1, MapDisplayWidth);
                Screen.Clear(GameRunUI.CommandListRow, ColOffset, 1, MapDisplayWidth);
                GameRunUI.DrawGameUI(
                    sidebar: DrawOption.Normal,
                    messages: DrawOption.DoNotDraw,
                    environmentalDesc: DrawOption.DoNotDraw,
                    commands: DrawOption.DoNotDraw
                    );
                string moveCursorMsg = travelMode? "Travel mode -- Move cursor to choose destination." : "Move cursor to look around.";
                Screen.Write(MessageBuffer.RowOffset, ColOffset, moveCursorMsg);
                Screen.Write(MessageBuffer.RowOffset + 2, ColOffset, "[Tab] to cycle between interesting targets          [m]ore details");
                Screen.Write(MessageBuffer.RowOffset + 2, ColOffset + 1, "Tab", Color.Cyan);
                Screen.Write(MessageBuffer.RowOffset + 2, ColOffset + 53, 'm', Color.Cyan);
                if (travelMode)
                {
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset, "[x] to confirm destination           [Space] to cancel travel mode");
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset + 1, 'x', Color.Cyan);
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset + 38, "Space", Color.Cyan);
                }
                else
                {
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset, "[x] to enter travel mode");
                    Screen.Write(MessageBuffer.RowOffset + 3, ColOffset + 1, 'x', Color.Cyan);
                }
                Highlight highlight;
                if (travelMode)
                {
                    List <Point> path = GetPathToNearbyReachable(p, playerMovementMap, ref knownReachable, ref distanceToKnownReachable);
                    highlight = new Highlight(MapHighlightType.Path)
                    {
                        Source      = Player.Position,
                        Destination = p,
                        LineOrPath  = path
                    };
                }
                else
                {
                    highlight = new Highlight(MapHighlightType.SinglePoint)
                    {
                        Destination = p
                    };
                }
                MapRenderer.UpdateAllSettings(p, highlight);
                MapRenderer.DrawMap(e);
                bool   hasLOS          = e.CellsVisibleThisTurn[p];
                bool   seen            = Map.Seen[p];
                string lookDescription = hasLOS? GetDescriptionAtCell(p)
                                        : seen?GetLastKnownDescriptionAtCell(p)
                                             : "";

                if (lookDescription.Length > MapDisplayWidth)
                {
                    int splitIdx = 0;
                    for (int idx = MapDisplayWidth - 1; idx >= 0; --idx)
                    {
                        if (lookDescription[idx] == ' ')
                        {
                            splitIdx = idx;
                            break;
                        }
                    }
                    int firstLineRow = Option.IsSet(BoolOptionType.MessagesAtBottom)? GameRunUI.CommandListRow
                                                : GameRunUI.EnviromentalDescriptionRow; // Start printing at whichever is higher onscreen
                    string firstLine  = lookDescription.Substring(0, splitIdx);
                    string secondLine = lookDescription.Substring(splitIdx + 1);        // Remove the space
                    if (secondLine.Length > MapDisplayWidth)
                    {
                        firstLine = hasLOS? "You see many things here."
                                                        : "You remember seeing many things here."; //todo, what should this say?
                        secondLine = "(Press 'm' for more details)";
                        //secondLine = "(Use the '[m]ore details' command for the full list)"; todo...any better options?
                    }
                    Screen.Write(firstLineRow, ColOffset, firstLine, Color.Green);
                    Screen.Write(firstLineRow + 1, ColOffset, secondLine, Color.Green);
                }
                else
                {
                    Screen.Write(GameRunUI.EnviromentalDescriptionRow, ColOffset, lookDescription, Color.Green);
                }
                Screen.ResumeUpdates();
                bool needsRedraw = false;
                while (!needsRedraw)
                {
                    ConsoleKeyInfo key   = Input.ReadKey();
                    bool           shift = (key.Modifiers & ConsoleModifiers.Shift) == ConsoleModifiers.Shift;
                    switch (key.Key)
                    {
                    case ConsoleKey.Tab:
                        if (shift)
                        {
                            travelIndex--;
                        }
                        else
                        {
                            travelIndex++;
                        }
                        if (travelIndex < 0)
                        {
                            travelIndex = travelDestinations.Count - 1;
                        }
                        else if (travelIndex >= travelDestinations.Count)
                        {
                            travelIndex = 0;
                        }
                        p           = travelDestinations[travelIndex];
                        needsRedraw = true;
                        break;

                    case ConsoleKey.Escape:
                        return;                                 // Done

                    case ConsoleKey.Spacebar:
                        if (travelMode)
                        {
                            travelMode  = false;
                            needsRedraw = true;
                        }
                        else
                        {
                            return;
                        }
                        break;

                    case ConsoleKey.Enter:
                        if (travelMode)
                        {
                            goto case ConsoleKey.X;                                            // Allow Enter to confirm travel destination, or cancel look mode.
                        }
                        else
                        {
                            goto case ConsoleKey.Escape;
                        }

                    case ConsoleKey.X:
                        if (travelMode)
                        {
                            List <Point> path = GetPathToNearbyReachable(p, playerMovementMap, ref knownReachable, ref distanceToKnownReachable);
                            if (path.Count > 0)
                            {
                                GameEventHandler.Path          = path;
                                GameEventHandler.NextPathIndex = 0;
                            }
                            //if(false) GameEventHandler.Autoexplore = true; //todo, option here
                            return;
                        }
                        else
                        {
                            travelMode  = true;
                            needsRedraw = true;
                        }
                        break;

                    case ConsoleKey.NumPad8:
                        p           = p.PointInDir(Dir8.N, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad6:
                        p           = p.PointInDir(Dir8.E, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad4:
                        p           = p.PointInDir(Dir8.W, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad2:
                        p           = p.PointInDir(Dir8.S, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad9:
                        p           = p.PointInDir(Dir8.NE, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad3:
                        p           = p.PointInDir(Dir8.SE, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad1:
                        p           = p.PointInDir(Dir8.SW, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    case ConsoleKey.NumPad7:
                        p           = p.PointInDir(Dir8.NW, shift? 6 : 1);
                        needsRedraw = true;
                        break;

                    default:
                        break;
                    }
                    if (!p.ExistsOnMap())
                    {
                        int newX, newY;
                        if (p.X < 0)
                        {
                            newX = 0;
                        }
                        else if (p.X >= GameUniverse.MapWidth)
                        {
                            newX = GameUniverse.MapWidth - 1;
                        }
                        else
                        {
                            newX = p.X;
                        }
                        if (p.Y < 0)
                        {
                            newY = 0;
                        }
                        else if (p.Y >= GameUniverse.MapHeight)
                        {
                            newY = GameUniverse.MapHeight - 1;
                        }
                        else
                        {
                            newY = p.Y;
                        }
                        p = new Point(newX, newY);
                    }
                }
            }
        }
Ejemplo n.º 22
0
 public GodManager(GameController GameController, MapRenderer MapRenderer)
 {
     this.GameController = GameController;
     this.Map            = GameController.Map;
     this.MapRenderer    = MapRenderer;
 }
Ejemplo n.º 23
0
            private void LateUpdate()
            {
                if (MapView.MapIsEnabled && map_renderer_ == null) {
                  map_renderer_ =
                  PlanetariumCamera.Camera.gameObject.AddComponent<MapRenderer>();
                  map_renderer_.post_render = RenderTrajectories;
                }
                override_rsas_target_ = false;
                Vessel active_vessel = FlightGlobals.ActiveVessel;
                if (active_vessel != null &&
                !FlightGlobals.ActiveVessel.isEVA) {
                  if (navball_ == null) {
                navball_ = (KSP.UI.Screens.Flight.NavBall)FindObjectOfType(
                       typeof(KSP.UI.Screens.Flight.NavBall));
                  }
                  var navball_material =
                  navball_.navBall.GetComponent<UnityEngine.Renderer>().material;

                  if (compass_navball_texture_ == null) {
                compass_navball_texture_ = navball_material.GetTexture("_MainTexture");
                  }

                  Action<UnityEngine.Texture> set_navball_texture = (texture) =>
                  navball_material.SetTexture("_MainTexture", texture);

                  if (navball_changed_) {
                // Texture the ball.
                navball_changed_ = false;
                // TODO(egg): switch over all frame types and have more navball textures
                // when more frames are available.
                if (!fix_navball_in_plotting_frame_ || !PluginRunning()) {
                  set_navball_texture(compass_navball_texture_);
                } else if (plotting_frame_selector_.get().frame_type ==
                   ReferenceFrameSelector.FrameType.BODY_CENTRED_NON_ROTATING) {
                  set_navball_texture(inertial_navball_texture_);
                } else {
                  set_navball_texture(barycentric_navball_texture_);
                }
                  }

                  // Orient the ball.
                  if (PluginRunning() && fix_navball_in_plotting_frame_) {
                navball_.navBall.rotation =
                (UnityEngine.QuaternionD)navball_.attitudeGymbal *  // sic.
                (UnityEngine.QuaternionD)plugin_.NavballOrientation(
                (XYZ)Planetarium.fetch.Sun.position,
                (XYZ)(Vector3d)active_vessel.ReferenceTransform.position);
                  }

                  if (PluginRunning() &&
                  has_active_vessel_in_space() &&
                  plugin_.HasVessel(active_vessel.id.ToString()) &&
                  FlightGlobals.speedDisplayMode ==
                  FlightGlobals.SpeedDisplayModes.Orbit) {
                KSP.UI.Screens.Flight.SpeedDisplay speed_display =
                KSP.UI.Screens.Flight.SpeedDisplay.Instance;
                if (speed_display?.textTitle != null &&
                speed_display?.textSpeed != null) {
                  speed_display.textTitle.text =
                  plotting_frame_selector_.get().ShortName();
                  speed_display.textSpeed.text =
                  ((Vector3d)plugin_.VesselVelocity(active_vessel.id.ToString()))
                  .magnitude.ToString("F1") + "m/s";
                }

                // Orient the Frenet trihedron.
                Vector3d prograde =
                (Vector3d)plugin_.VesselTangent(active_vessel.id.ToString());
                Vector3d radial =
                (Vector3d)plugin_.VesselNormal(active_vessel.id.ToString());
                // Yes, the astrodynamicist's normal is the mathematician's binormal.
                // Don't ask.
                Vector3d normal =
                (Vector3d)plugin_.VesselBinormal(active_vessel.id.ToString());

                SetNavballVector(navball_.progradeVector, prograde);
                SetNavballVector(navball_.radialInVector, radial);
                SetNavballVector(navball_.normalVector, normal);
                SetNavballVector(navball_.retrogradeVector, -prograde);
                SetNavballVector(navball_.radialOutVector, -radial);
                SetNavballVector(navball_.antiNormalVector, -normal);

                // Make the autopilot target our Frenet trihedron.
                if (active_vessel.OnAutopilotUpdate.GetInvocationList()[0] !=
                (Delegate)(FlightInputCallback)OverrideRSASTarget) {
                  Log.Info("Prepending RSAS override");
                  active_vessel.OnAutopilotUpdate =
                  (FlightInputCallback)Delegate.Combine(
                  new FlightInputCallback(OverrideRSASTarget),
                  active_vessel.OnAutopilotUpdate);
                }
                if (active_vessel.Autopilot.Enabled) {
                  override_rsas_target_ = true;
                  switch (active_vessel.Autopilot.Mode) {
                case VesselAutopilot.AutopilotMode.Prograde:
                  rsas_target_ = prograde;
                  break;
                case VesselAutopilot.AutopilotMode.Retrograde:
                  rsas_target_ = -prograde;
                  break;
                case VesselAutopilot.AutopilotMode.RadialIn:
                  rsas_target_ = radial;
                  break;
                case VesselAutopilot.AutopilotMode.RadialOut:
                  rsas_target_ = -radial;
                  break;
                case VesselAutopilot.AutopilotMode.Normal:
                  rsas_target_ = normal;
                  break;
                case VesselAutopilot.AutopilotMode.Antinormal:
                  rsas_target_ = -normal;
                  break;
                default:
                  override_rsas_target_ = false;
                  break;
                  }
                }
                  }
                }
            }
Ejemplo n.º 24
0
 public void Awake()
 {
     _mapRenderer = GetComponent <MapRenderer>();
     Debug.Assert(_mapRenderer != null);
     Debug.Assert(_mapPinLayer != null);
 }
Ejemplo n.º 25
0
        public static int Main(string[] args)
        {
            // Applikation ist "Windows-Anwendung" -> losgelöst von bestehender Konsole
            // App wird geladen, damit der MapRenderer Zugriff auf die Ressourcen hat.
            App app = new App();

            if (args != null && args.Length > 0)
            {
                bool attached      = false;
                bool helpRequested = false;
                try
                {
                    // mit bestehender Konsole verbinden, sonst neue erstellen
                    attached = AttachConsole(-1);
                    if (!attached)
                    {
                        ShowConsoleWindow();
                    }

                    // weil gelöst von aktueller Konsole war, steht jetzt der Prompt in der Zeile -> Zeile leeren
                    int pos = Console.CursorLeft;
                    Console.CursorLeft = 0;
                    Console.Write(new String(' ', pos));
                    Console.CursorLeft = 0;

                    // Argumente parsen
                    AppSettings set = CommandLine <AppSettings> .Parse(args);

                    // wenn Hilfe angefordert, dann diese ausgeben
                    if (args.Contains("/?") || args.Contains("--help") || args.Contains("-h"))
                    {
                        CommandLine <AppSettings> .PrintHelp();

                        helpRequested = true;
                    }
                    else
                    {
                        IProgressService progress = new ConsoleOutput();
                        var mapfilename           = System.IO.Path.GetFileNameWithoutExtension(set.MapFilePath);
                        var mapdirectory          = System.IO.Path.GetDirectoryName(set.MapFilePath);
                        if (String.IsNullOrEmpty(set.ImageFilePath))
                        {
                            set.ImageFilePath = System.IO.Path.Combine(mapdirectory, mapfilename + ".png");
                        }

                        var pois = POI.FromCsvFile(set.PoiFilePath);
                        // PlayerProfile hat den Namen der Map-Datei, nur mit der Endung .ttp
                        string ttpfilename = System.IO.Path.Combine(mapdirectory, mapfilename + ".ttp");
                        var    waypoints   = POI.FromTtpFile(ttpfilename);
                        pois = pois.Concat(waypoints);

                        var map = new MapRenderer();
                        map.TileSize         = (int)set.SelectedTileSize;
                        map.RenderBackground = set.RenderBackground;
                        map.RenderGrid       = set.RenderGrid;
                        map.GridSize         = set.GridSize;
                        map.GridColor        = System.Drawing.Color.FromArgb(set.AlphaValue,
                                                                             System.Drawing.Color.FromName(set.SelectedGridColorName));
                        map.RenderRegionNumbers = set.RenderRegionNumbers;
                        map.RegionFontName      = set.RegionFontName;
                        map.RegionFontEmSize    = set.RegionFontEmSize;
                        map.RenderWaypoints     = set.RenderWaypoints;
                        map.WaypointFontColor   = System.Drawing.Color.FromName(set.SelectedWaypointFontColorName);
                        map.WaypointFontName    = set.WaypointFontName;
                        map.WaypointFontEmSize  = set.WaypointFontEmSize;
                        map.UseDataStore        = set.UseDataStore;

                        map.RenderWholeMap(set.MapFilePath, set.ImageFilePath, pois, progress);
                    }
                }
                catch (Exception ex)
                {
                    var oldfore = Console.ForegroundColor;
                    var oldback = Console.BackgroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.WriteLine(ex.Message);
                    Console.ForegroundColor = oldfore;
                    Console.BackgroundColor = oldback;
                }
                finally
                {
                    /*
                     * Der auskommentierte Code sollte das Problem beheben, dass die Konsole nicht wieder auf den Prompt zurückspringt.
                     * Grund für das Verhalten: Applikation ist eine "Windows-Anwendung"
                     * Das Verhalten des Workarounds ist aber unlogisch, da einfach die Konsole aktiviert wird und damit das aktuelle Fenster seinen Fokus verliert.
                     * Besonders nervig, falls man grade in einem anderen Fenster etwas tippt.
                     *
                     * Wird die Anwendung über einen Shortcut gestartet, dann tritt das Verhalten nicht auf und die Konsole schließt sich automatisch.
                     */

                    //var hnd = GetConsoleWindow();
                    //bool res = false;
                    //if (hnd != IntPtr.Zero)
                    //    res = SetForegroundWindow(hnd);

                    if (!helpRequested)
                    {
                        Console.WriteLine("Please press Enter.");
                    }

                    if (attached)
                    {
                        FreeConsole();
                    }

                    //if (res != false)
                    if (helpRequested)
                    {
                        // normalen prompt wieder holen
                        // HACK from http://stackoverflow.com/questions/1305257/using-attachconsole-user-must-hit-enter-to-get-%20regular-command-line/2463039#2463039
                        System.Windows.Forms.SendKeys.SendWait("{ENTER}");
                    }
                }
            }
            else
            {
                app.Run(new MainWindow());
            }
            app.Shutdown(0);
            return(0);
        }
Ejemplo n.º 26
0
        public void Initialize()
        {
            Map = new Map();
            BackgroundColor = UIColor.White;
            _renderer = new MapRenderer();

            InitializeViewport();

            ClipsToBounds = true;

            var pinchGesture = new UIPinchGestureRecognizer(PinchGesture) { Enabled = true };
            AddGestureRecognizer(pinchGesture);

            PaintSurface += OnPaintSurface;
        }
Ejemplo n.º 27
0
 private void Cleanup()
 {
     UnityEngine.Object.Destroy(map_renderer_);
     map_renderer_ = null;
     Interface.DeletePlugin(ref plugin_);
     plotting_frame_selector_.reset();
     flight_planner_.reset();
     DestroyRenderedTrajectory();
     DestroyRenderedFlightPlan();
     navball_changed_ = true;
 }
Ejemplo n.º 28
0
        protected override void LoadContent()
        {
            _camera2D = new Camera2D(GraphicsDevice.Viewport);
            Services.AddService(_camera2D);

            Services.AddService(_penumbra);
            Services.AddService(_timeService = new TimeService(Services));
            Services.AddService(GraphicsDevice);
            Services.AddService(_aiService = new AIService(Services, Content));

            var mapService = new MapService();

            Services.AddService(mapService);

            _gameObjectManager = new GameObjectManager();
            Services.AddService(_gameObjectManager);

            _pathFindingService = new PathFindingService(mapService, _gameObjectManager);

            _character = new PlayerCharacter(Services);
            _character.LoadContent(Content);
            Services.AddService(_character);

            _spriteBatch = new SpriteBatch(GraphicsDevice);

            Services.AddService(_uiManager = new UIManager(Services, Content));

            //var mapGenerator = new MapGenerator(Services, GraphicsDevice, Guid.NewGuid().GetHashCode(), Content);
            var mapGenerator = new MapGenerator(Services, GraphicsDevice, -425262119, Content);

            _map = mapGenerator.Generate(400, 400);
            //_map = mapGenerator.Generate(100, 100);

            mapService.Map      = _map;
            _character.Position = _map.StartPosition;

            _gameObjectManager.LoadAll(Content);

            _pathFindingService = new PathFindingService(mapService, _gameObjectManager);
            _pathFindingService.Initialize();
            Services.AddService(_pathFindingService);


            _mapRenderer = new MapRenderer(Services, _map);
            _mapRenderer.LoadContent(Content);


            _uiManager.Initialize();
            _uiManager.AddVisual(new HotbarPanel());
            _uiManager.AddVisual(new TimePanel(Services)
            {
                Position = new UVector2(UDim.Relative(0.01f), UDim.Relative(0.5f))
            });

            _chicken = new Chicken(Services);
            _chicken.LoadContent(Content);
            _chicken.Position = _character.Position + new Vector2(4f * 32f, 4f * 32f);

            _gameObjectManager.AddGameObject(_chicken);
            _gameObjectManager.AddGameObject(_character);

            _temp = new PrimitiveRectangle(GraphicsDevice, Color.Black, false);
        }
Ejemplo n.º 29
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (FrameCount > 0)
            {
                System.Diagnostics.Debug.WriteLine("{0}: {1} seconds per paint (spp)", this, _stopwatch.Elapsed.TotalSeconds / FrameCount);
            }
            _stopwatch.Start();

            MapRenderer<Drawable> renderer = new MapRenderer<Drawable>(new EtoRenderer2D(e.Graphics));
            View2D view = renderer.Create(ClientSize.Width, ClientSize.Height, _map, Zoom, Center, XInverted, YInverted);
            _map.ViewChanged(Zoom, Center, null, view);
            renderer.Render(this, _map, view, Zoom);

            _stopwatch.Stop();
            FrameCount++;
        }
Ejemplo n.º 30
0
 private void Cleanup()
 {
     UnityEngine.Object.Destroy(map_renderer_);
     map_renderer_ = null;
     DeletePlugin(ref plugin_);
     DeleteRenderingFrame(ref rendering_frame_);
     DestroyRenderedTrajectory();
     navball_changed_ = true;
 }
Ejemplo n.º 31
0
 private void Cleanup()
 {
     UnityEngine.Object.Destroy(map_renderer_);
     map_renderer_ = null;
     DeletePlugin(ref plugin_);
     DeleteTransforms(ref transforms_);
     DestroyRenderedTrajectory();
     navball_changed_ = true;
 }
Ejemplo n.º 32
0
        protected override void OnLoad( EventArgs e )
        {
            #if !USE_DX
            Graphics = new OpenGLApi();
            #else
            Graphics = new Direct3D9Api( this );
            #endif
            Graphics.MakeGraphicsInfo();

            Options.Load();
            ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 );
            InputHandler = new InputHandler( this );
            Chat = new ChatLog( this );
            Chat.FontSize = Options.GetInt( OptionsKey.FontSize, 6, 30, 12 );
            defaultIb = Graphics.MakeDefaultIb();
            MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 );
            BlockInfo = new BlockInfo();
            BlockInfo.Init();
            ChatLines = Options.GetInt( OptionsKey.ChatLines, 1, 30, 12 );
            ModelCache = new ModelCache( this );
            ModelCache.InitCache();
            AsyncDownloader = new AsyncDownloader( skinServer );
            Drawer2D = new GdiPlusDrawer2D( Graphics );
            Drawer2D.UseBitmappedChat = !Options.GetBool( OptionsKey.ArialChatFont, false );

            TerrainAtlas1D = new TerrainAtlas1D( Graphics );
            TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D );
            Animations = new Animations( this );
            TexturePackExtractor extractor = new TexturePackExtractor();
            extractor.Extract( defaultTexPack, this );
            Inventory = new Inventory( this );

            BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete );
            Map = new Map( this );
            LocalPlayer = new LocalPlayer( this );
            LocalPlayer.SpeedMultiplier = Options.GetInt( OptionsKey.Speed, 1, 50, 10 );
            Players[255] = LocalPlayer;
            width = Width;
            height = Height;
            MapRenderer = new MapRenderer( this );
            MapEnvRenderer = new MapEnvRenderer( this );
            EnvRenderer = new StandardEnvRenderer( this );
            if( IPAddress == null ) {
                Network = new Singleplayer.SinglePlayerServer( this );
            } else {
                Network = new NetworkProcessor( this );
            }
            Graphics.LostContextFunction = Network.Tick;

            firstPersonCam = new FirstPersonCamera( this );
            thirdPersonCam = new ThirdPersonCamera( this );
            forwardThirdPersonCam = new ForwardThirdPersonCamera( this );
            Camera = firstPersonCam;
            CommandManager = new CommandManager();
            CommandManager.Init( this );
            SelectionManager = new SelectionManager( this );
            ParticleManager = new ParticleManager( this );
            WeatherRenderer = new WeatherRenderer( this );
            WeatherRenderer.Init();

            bool vsync = Options.GetBool( OptionsKey.VSync, true );
            Graphics.SetVSync( this, vsync );
            Graphics.DepthTest = true;
            Graphics.DepthTestFunc( CompareFunc.LessEqual );
            //Graphics.DepthWrite = true;
            Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha );
            Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f );
            fpsScreen = new FpsScreen( this );
            fpsScreen.Init();
            Culling = new FrustumCulling();
            EnvRenderer.Init();
            MapEnvRenderer.Init();
            Picking = new PickingRenderer( this );

            string connectString = "Connecting to " + IPAddress + ":" + Port +  "..";
            Graphics.WarnIfNecessary( Chat );
            SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) );
            Network.Connect( IPAddress, Port );
        }
Ejemplo n.º 33
0
        public void RenderLabels()
        {
            // arrange
            var map = ArrangeRenderingTests.Labels();
            const string fileName = "labels.png";

            // act
            var bitmap = new MapRenderer().RenderToBitmapStream(map.Viewport, map.Layers);

            // aside;
            File.Write(fileName, bitmap);

            // assert
            Assert.AreEqual(File.Read(fileName).ToArray(), bitmap.ToArray());
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            _mapView = mapLayout;
            this.SetWillNotDraw(false);

            this.MapMinZoomLevel = 10;
            this.MapMaxZoomLevel = 20;

            _renderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D());

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            // initialize all the caching stuff.
            _cacheRenderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D());
            _scene = new Scene2DSimple();
            _scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;

            new Timer(InvalidateSimple, null, 0, 50);
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Diposes of all resources associated with this object.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing == true)
            {
                //someone wants the deterministic release of all resources
                //Let us release all the managed resources
            }
            else
            {
                // Do nothing, no one asked a dispose, the object went out of
                // scope and finalized is called so lets next round of GC
                // release these resources
            }

            // Release the unmanaged resource in any case as they will not be
            // released by GC
            this._cacheRenderer = null;
            if (this._offScreenBuffer != null)
            { // dispose of the map view surface.
                this._offScreenBuffer.Dispose();
                this._offScreenBuffer = null;
            }
            if (this._onScreenBuffer != null)
            { // dispose of the map view surface.
                this._onScreenBuffer.Dispose();
                this._onScreenBuffer = null;
            }
            if (this._mapViewAnimator != null)
            {
                _mapViewAnimator.Stop();
                _mapViewAnimator = null;
            }
            if (this._map != null)
            {
                this._map = null;
            }
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Initialize the specified defaultMapCenter, defaultMap, defaultMapTilt and defaultMapZoom.
        /// </summary>
        /// <param name="defaultMapCenter">Default map center.</param>
        /// <param name="defaultMap">Default map.</param>
        /// <param name="defaultMapTilt">Default map tilt.</param>
        /// <param name="defaultMapZoom">Default map zoom.</param>
        public void Initialize(GeoCoordinate defaultMapCenter, Map defaultMap, Degree defaultMapTilt, float defaultMapZoom)
        {
            // register the default listener.
            (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this));

            // enable all interactions by default.
            this.MapAllowPan  = true;
            this.MapAllowTilt = true;
            this.MapAllowZoom = true;

            // set clip to bounds to prevent objects from being rendered/show outside of the mapview.
            this.ClipsToBounds = true;

            _mapCenter = defaultMapCenter;
            _map       = defaultMap;
            _mapTilt   = defaultMapTilt;
            _mapZoom   = defaultMapZoom;

            _doubleTapAnimator = new MapViewAnimator(this);

            this.BackgroundColor        = UIColor.White;
            this.UserInteractionEnabled = true;

            _markers = new List <MapMarker>();

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                panGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return(false);
                };
                panGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return(false);
                };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                pinchGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return(false);
                };
                pinchGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return(false);
                };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                rotationGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return(false);
                };
                rotationGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return(false);
                };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                // TODO: workaround for xamarin bug, remove later!
//				singleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
//				singleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                // TODO: workaround for xamarin bug, remove later!
//				doubleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
//				doubleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                //singleTapGesture.RequireGestureRecognizerToFail (doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }
            else
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return(true);
                };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return(true);
                };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return(true);
                };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                //singleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //singleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslySingle;

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                //doubleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //doubleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslyDouble;

                singleTapGesture.RequireGestureRecognizerToFail(doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }

            // set scalefactor.
            _scaleFactor = this.ContentScaleFactor;

            // create the cache renderer.
            _cacheRenderer = new MapRenderer <CGContextWrapper>(
                new CGContextRenderer(_scaleFactor));
            _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
Ejemplo n.º 37
0
Archivo: Map.cs Proyecto: Porkka/CDIO4
    void BuildMap()
    {
        // Setup Map
        this.mapWidth = ((this.maxRoomPosition + 1) * 32);
        this.mapHeight = ((this.maxRoomPosition + 1) * 32);

        // Get map's rooms, corridors, walls etc
        Map.data = this.GetMapData();

        // Use map's layout to render right prefabs
        Map.renderer = new MapRenderer(Map.data, this.mapWidth, this.mapHeight);
        //  TODO: Dynamic theme
        MapRenderer.MapTheme theme = MapRenderer.MapTheme.PIRATE;

        switch(gameLevel)
        {
            case 1:
            theme = MapRenderer.MapTheme.PIRATE;
                break;
            case 2:
                theme = MapRenderer.MapTheme.JUNGLE;
                break;
            case 3:
                theme = MapRenderer.MapTheme.DUNGEON;
                break;
        }

        Map.renderer.SetMapTheme(theme);
        // Instantiate prefabs
        Map.renderer.Render(this.transform);
        this.StartingTile = this._Rooms[Random.Range(0, this._Rooms.Count - 1)].CenterTile;
        // Setup Player
        this._setupPlayer();

        // Setup game assets like items, monsters / other npcs to a pool from which to draw from while spawning them to the map . Logic is n/y ?

        // Setup gameobjects - items
        // this._items = this.SetupItems();

        //this.SpawnPotions();
        //testiansa();

        // Setup gameobject - npcs
        // this._monsters = this.SetupMonsters();
        List<Object> tmp = new List<Object> ();

        string path = Map.renderer.ThemePath();
        tmp.Add(Resources.Load(path + "Enemy"));
        tmp.Add(Resources.Load(path + "obstacle"));
        //tmp.Add (Resources.Load("Dungeon/lvlpirate/Parrot"));
        //tmp.Add (Resources.Load("Enemy"));

        for (int i = 1; i < this._Rooms.Count ; i++) {
            Spawn s = new Spawn (this._Rooms [i], tmp);

            // HMMMH min and max must be associated with room sizes
            // HMMMH room can't be used as spawn point more than once
            s.MinSpawns = 1;
            s.MaxSpawns = 3;
            s.Release ();
        }

        tmp.Clear ();
        tmp.Add(Resources.Load(path + "Boss"));

        Spawn boss = new Spawn (this._Rooms [0], tmp);
        boss.MinSpawns = 0;
        boss.MaxSpawns = 0;
        boss.Release ();

        // Setup Boss

        // ============================================================

        // Spawn above items with some logic

        // Spawn.SpawnItems(this._monsters, rnd collection of rooms);
        // or
        // Spawn.SpawnItems(this._monsters, rnd collection of rooms);
        // Spawn.SpawnConsealedItems(this._monsters, rnd collection of rooms); // barrels, chests

        // Spawn enemies with some logic

        //Spawn.SpawnEnemies(this._monsters, rnd collection of rooms);
        // Enemies.StartRoaming();

        //Spawn.SpawnBoss(this.Boss, Room.BiggestRoom(this._Rooms))
    }
Ejemplo n.º 38
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Set the sharing mode of the graphics device to turn on XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);

            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);

            // Initialize the graphics renderer.
            _renderer = new MapRenderer<GraphicsDevice>(new GraphicsDeviceRenderer2D());

            // TODO: use this.content to load your game content here

            // Start the timer
            _timer.Start();

            base.OnNavigatedTo(e);
        }
Ejemplo n.º 39
0
        protected override void OnLoad( EventArgs e )
        {
            #if !USE_DX
            Graphics = new OpenGLApi();
            #else
            Graphics = new Direct3D9Api( this );
            #endif
            try {
                Options.Load();
            } catch( IOException ) {
                Utils.LogWarning( "Unable to load options.txt" );
            }
            ViewDistance = Options.GetInt( "viewdist", 16, 8192, 512 );
            Keys = new KeyMap();
            InputHandler = new InputHandler( this );
            Chat = new ChatLog( this );
            Drawer2D = new GdiPlusDrawer2D( Graphics );
            defaultIb = Graphics.MakeDefaultIb();

            ModelCache = new ModelCache( this );
            ModelCache.InitCache();
            AsyncDownloader = new AsyncDownloader( skinServer );
            Graphics.PrintGraphicsInfo();
            TerrainAtlas1D = new TerrainAtlas1D( Graphics );
            TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D );
            Animations = new Animations( this );
            TexturePackExtractor extractor = new TexturePackExtractor();
            extractor.Extract( defaultTexPack, this );
            Inventory = new Inventory( this );

            BlockInfo = new BlockInfo();
            BlockInfo.Init();
            BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete );
            Map = new Map( this );
            LocalPlayer = new LocalPlayer( this );
            Players[255] = LocalPlayer;
            width = Width;
            height = Height;
            MapRenderer = new MapRenderer( this );
            MapEnvRenderer = new MapEnvRenderer( this );
            EnvRenderer = new StandardEnvRenderer( this );
            if( IPAddress == null ) {
                Network = new Singleplayer.SinglePlayerServer( this );
            } else {
                Network = new NetworkProcessor( this );
            }
            Graphics.LostContextFunction = Network.Tick;

            firstPersonCam = new FirstPersonCamera( this );
            thirdPersonCam = new ThirdPersonCamera( this );
            Camera = firstPersonCam;
            CommandManager = new CommandManager();
            CommandManager.Init( this );
            SelectionManager = new SelectionManager( this );
            ParticleManager = new ParticleManager( this );
            WeatherRenderer = new WeatherRenderer( this );
            WeatherRenderer.Init();

            Graphics.SetVSync( this, true );
            Graphics.DepthTest = true;
            Graphics.DepthTestFunc( CompareFunc.LessEqual );
            //Graphics.DepthWrite = true;
            Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha );
            Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f );
            Title = Utils.AppName;
            fpsScreen = new FpsScreen( this );
            fpsScreen.Init();
            Culling = new FrustumCulling();
            EnvRenderer.Init();
            MapEnvRenderer.Init();
            Picking = new PickingRenderer( this );

            string connectString = "Connecting to " + IPAddress + ":" + Port +  "..";
            SetNewScreen( new LoadingMapScreen( this, connectString, "Reticulating splines" ) );
            Network.Connect( IPAddress, Port );
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            // create the Open GL 2D target.
            _target = new OpenGLTarget2D();
            this.SetRenderer(_target);

            _mapView = mapLayout;
            this.SetWillNotDraw(false);

            this.MapMinZoomLevel = 10;
            this.MapMaxZoomLevel = 20;

            // create the renderer.
            _renderer = new MapRenderer<OpenGLTarget2D>(
                    new OpenGLRenderer2D());

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            _scene = new Scene2D(new WebMercator(), 16);
            _scene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Initialize implementation from IMapView.
        /// </summary>
        /// <param name="mapLayout"></param>
        void IMapViewSurface.Initialize(MapView mapLayout)
        {
            this.MapAllowPan = true;
            this.MapAllowTilt = true;
            this.MapAllowZoom = true;

            // register default invalidation trigger.
            (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this));

            _mapView = mapLayout;
            this.SetWillNotDraw(false);
            // this.SetWillNotCacheDrawing(true);

            this.MapMinZoomLevel = 0;
            this.MapMaxZoomLevel = 20;

            // gets the system density.
            _density = global::Android.Content.Res.Resources.System.DisplayMetrics.Density;
            _bufferFactor = _density; // set default scale factor relative to density.

            // create the renderer.
            _renderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D(1));

            // initialize the gesture detection.
            this.SetOnTouchListener(this);
            _scaleGestureDetector = new ScaleGestureDetector(
                this.Context, this);
            _rotateGestureDetector = new RotateGestureDetector(
                this.Context, this);
            _moveGestureDetector = new MoveGestureDetector(
                this.Context, this);
            _tagGestureDetector = new TapGestureDetector(
                this.Context, this);

            _makerLayer = new LayerPrimitives(
                new WebMercator());

            // initialize all the caching stuff.
            _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
            _cacheRenderer = new MapRenderer<global::Android.Graphics.Canvas>(
                new CanvasRenderer2D(1));
        }
 /// <summary>
 /// Creates a new rendering instance.
 /// </summary>
 /// <param name="cache">The cache.</param>
 public RenderingInstance(TileCache cache)
 {
     _targetsPerScale = new Dictionary<int, Tuple<Bitmap, Graphics>>();
     _renderer = new MapRenderer<Graphics>(new GraphicsRenderer2D());
     _map = new Map(new WebMercator());
     _cache = cache;
 }
Ejemplo n.º 43
0
        /// <summary>
        /// Initialize the specified defaultMapCenter, defaultMap, defaultMapTilt and defaultMapZoom.
        /// </summary>
        /// <param name="defaultMapCenter">Default map center.</param>
        /// <param name="defaultMap">Default map.</param>
        /// <param name="defaultMapTilt">Default map tilt.</param>
        /// <param name="defaultMapZoom">Default map zoom.</param>
        public void Initialize(GeoCoordinate defaultMapCenter, Map defaultMap, Degree defaultMapTilt, float defaultMapZoom)
        {
            // register the default listener.
            (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this));

            // enable all interactions by default.
            this.MapAllowPan = true;
            this.MapAllowTilt = true;
            this.MapAllowZoom = true;

            // set clip to bounds to prevent objects from being rendered/show outside of the mapview.
            this.ClipsToBounds = true;

            MapCenter = defaultMapCenter;
            _map = defaultMap;
            MapTilt = defaultMapTilt;
            MapZoom = defaultMapZoom;

            _map.MapChanged += MapChanged;

            _doubleTapAnimator = new MapViewAnimator(this);

            this.BackgroundColor = UIColor.White;
            this.UserInteractionEnabled = true;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                // TODO: workaround for xamarin bug, remove later!
                panGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return false;
                };
                panGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return false;
                };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                // TODO: workaround for xamarin bug, remove later!
                pinchGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return false;
                };
                pinchGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return false;
                };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                // TODO: workaround for xamarin bug, remove later!
                rotationGesture.ShouldRequireFailureOf = (a, b) =>
                {
                    return false;
                };
                rotationGesture.ShouldBeRequiredToFailBy = (a, b) =>
                {
                    return false;
                };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                // TODO: workaround for xamarin bug, remove later!
                //				singleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
                //				singleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                // TODO: workaround for xamarin bug, remove later!
                //				doubleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
                //				doubleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                //singleTapGesture.RequireGestureRecognizerToFail (doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }
            else
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) =>
                {
                    return true;
                };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                //singleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //singleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslySingle;

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                //doubleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //doubleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslyDouble;

                singleTapGesture.RequireGestureRecognizerToFail(doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }

            // set scalefactor.
            _scaleFactor = (float)this.ContentScaleFactor;

            // create the cache renderer.
            _cacheRenderer = new MapRenderer<CGContextWrapper>(
                new CGContextRenderer(_scaleFactor));
            _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
Ejemplo n.º 44
0
 void Start()
 {
     _map    = GameObject.Find("Map").GetComponent <MapRenderer>();
     _mapPin = GetComponent <MapPin>();
 }