Skip to content

Commit

Permalink
[HaCreator] Start map simulator in a random spawnpoint 'sp'
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed Nov 25, 2024
1 parent 463fe11 commit 60b483f
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions HaCreator/MapSimulator/MapSimulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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..
{
Expand All @@ -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
Expand Down

0 comments on commit 60b483f

Please sign in to comment.