private static void GenerateTrees(System.Random lr, SZoneState zs, int h, int w) { // Select 2 to 5 forest starting points // Populate them with a elliptical circle // Add random trees // Make sure to fix the z index later int forest_count = lr.Next(2, 5); for (int i = 0; i < forest_count; i++) { Vector3Int forestCenter = new Vector3Int(); forestCenter.x = lr.Next(w * 1 / 6, w * 5 / 6); forestCenter.y = lr.Next(h * 1 / 6, h * 5 / 6); int forest_xSpan = lr.Next(FOREST_MIN_RADIUS, FOREST_MAX_RADIUS); int forest_ySpan = lr.Next(FOREST_MIN_RADIUS, FOREST_MAX_RADIUS); int maxManhattan = (forest_xSpan + forest_ySpan) / 2; // Debug.Log($"{forestCenter} -- {forestRadius}"); for (int x = forestCenter.x - forest_xSpan / 2; x <= forestCenter.x + forest_xSpan / 2; x++) { for (int y = forestCenter.y - forest_ySpan / 2; y <= forestCenter.y + forest_ySpan / 2; y++) { var vPos = new Vector3Int(x, y, 0); // TODO - check if (entityGrid[x][y] || CloseToBounds(vPos, zs)) { continue; } float manhattanDistance = Math.Abs(vPos.x - forestCenter.x) + Math.Abs(vPos.y - forestCenter.y); float relativeMHD = manhattanDistance / maxManhattan; if (lr.NextDouble() > relativeMHD * 2) { entityGrid[x][y] = true; GameEntityInfo e = new GameEntityInfo(); e.entityID = AssetLoader.GetEntityID("prototypeTree"); e.pos = new SVector3Int(x, y, 0); e.entityType = EntityType.BREAKABLE; zs.entityInfo.Add(e); } } } } }
private static void AddPortalEntity(SZoneState zs, Vector3Int vPos, Vector3Int nextZone, Direction direction) { PortalInfo p = new PortalInfo(); GameEntityInfo e = new GameEntityInfo(); e.entityID = 2; e.entityType = EntityType.INTERACTABLE | EntityType.HOVERABLE; e.pos = vPos; p.entityInfo = e; p.nextZone = nextZone; p.directionToGo = direction; zs.portalInfo.Add(p); }