From 60b483f1b21639f8d017e73c557c14494a14e8f2 Mon Sep 17 00:00:00 2001 From: lastbattle <4586194+lastbattle@users.noreply.github.com> Date: Mon, 25 Nov 2024 19:03:59 +0800 Subject: [PATCH] [HaCreator] Start map simulator in a random spawnpoint 'sp' --- HaCreator/MapSimulator/MapSimulator.cs | 27 ++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/HaCreator/MapSimulator/MapSimulator.cs b/HaCreator/MapSimulator/MapSimulator.cs index 3d3ffa0d..39e14120 100644 --- a/HaCreator/MapSimulator/MapSimulator.cs +++ b/HaCreator/MapSimulator/MapSimulator.cs @@ -460,11 +460,29 @@ protected override void LoadContent() // spriteBatch = new SpriteBatch(GraphicsDevice); - // default positioning for character - SetCameraMoveX(true, true, 0); - SetCameraMoveY(true, true, 0); + /////////////////////////////////////////////// + ////// Default positioning for character ////// + /////////////////////////////////////////////// + // Get a random portal if any exists for spawnpoint + var startPortals = mapBoard.BoardItems.Portals.Where(portal => portal.pt == PortalType.PORTALTYPE_STARTPOINT).ToList(); + if (startPortals.Any()) + { + Random random = new Random(); + PortalInstance randomStartPortal = startPortals[random.Next(startPortals.Count)]; + this.mapShiftX = randomStartPortal.X; + this.mapShiftY = randomStartPortal.Y; + } + + SetCameraMoveX(true, false, 0); // true true to center it, in case its out of the boundary + SetCameraMoveX(false, true, 0); + + SetCameraMoveY(true, false, 0); + SetCameraMoveY(false, true, 0); + /////////////////////////////////////////////// - ///////////// Border + /////////////////////////////////////////////// + ///////////// Border ////////////////////////// + /////////////////////////////////////////////// int leftRightVRDifference = (int)((vr_fieldBoundary.Right - vr_fieldBoundary.Left) * RenderObjectScaling); if (leftRightVRDifference < RenderWidth) // viewing range is smaller than the render width.. { @@ -475,6 +493,7 @@ protected override void LoadContent() this.texture_vrBoundaryRectTop = CreateVRBorder(vr_fieldBoundary.Width * 2, VR_BORDER_WIDTHHEIGHT, _DxDeviceManager.GraphicsDevice); this.texture_vrBoundaryRectBottom = CreateVRBorder(vr_fieldBoundary.Width * 2, VR_BORDER_WIDTHHEIGHT, _DxDeviceManager.GraphicsDevice); } + /////////////////////////////////////////////// // mirror bottom boundaries //rect_mirrorBottom