Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/snowflake_searocks.js
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
const clLand = g_Map.createTileClass(); | const clLand = g_Map.createTileClass(); | ||||
const playerIslandRadius = scaleByMapSize(15, 30); | const playerIslandRadius = scaleByMapSize(15, 30); | ||||
const islandBetweenPlayerAndCenterDist = 0.16; | const islandBetweenPlayerAndCenterDist = 0.16; | ||||
const islandBetweenPlayerAndCenterRadius = 0.81; | const islandBetweenPlayerAndCenterRadius = 0.81; | ||||
const centralIslandRadius = 0.36; | const centralIslandRadius = 0.36; | ||||
var [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); | const [playerIDs, playerPosition, playerAngle, startAngle] = playerPlacementCircle(fractionToTiles(0.35)); | ||||
var numIslands = 0; | let numIslands = 0; | ||||
var isConnected = []; | const isConnected = []; | ||||
var islandPos = []; | const islandPos = []; | ||||
function initIsConnected() | function initIsConnected() | ||||
{ | { | ||||
for (let m = 0; m < numIslands; ++m) | for (let m = 0; m < numIslands; ++m) | ||||
{ | { | ||||
isConnected[m] = []; | isConnected[m] = []; | ||||
for (let n = 0; n < numIslands; ++n) | for (let n = 0; n < numIslands; ++n) | ||||
isConnected[m][n] = 0; | isConnected[m][n] = 0; | ||||
Show All 13 Lines | |||||
function createIslandAtRadialLocation(playerID, islandID, playerIDOffset, distFromCenter, islandRadius) | function createIslandAtRadialLocation(playerID, islandID, playerIDOffset, distFromCenter, islandRadius) | ||||
{ | { | ||||
const angle = startAngle + (playerID * 2 + playerIDOffset) * Math.PI / numPlayers; | const angle = startAngle + (playerID * 2 + playerIDOffset) * Math.PI / numPlayers; | ||||
islandPos[islandID] = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(distFromCenter), 0).rotate(-angle)).round(); | islandPos[islandID] = Vector2D.add(mapCenter, new Vector2D(fractionToTiles(distFromCenter), 0).rotate(-angle)).round(); | ||||
createIsland(islandID, islandRadius, clLand); | createIsland(islandID, islandRadius, clLand); | ||||
} | } | ||||
function createSnowflakeSearockWithCenter(sizeID) | function createSnowflakeSearockWithCenter([tertiaryIslandDist, tertiaryIslandRadius, | ||||
islandBetweenPlayersDist, islandBetweenPlayersRadius]) | |||||
{ | { | ||||
const [tertiaryIslandDist, tertiaryIslandRadius, islandBetweenPlayersDist, islandBetweenPlayersRadius] = islandSizes[sizeID]; | |||||
const islandID_center = 4 * numPlayers; | const islandID_center = 4 * numPlayers; | ||||
numIslands = islandID_center + 1; | numIslands = islandID_center + 1; | ||||
initIsConnected(); | initIsConnected(); | ||||
g_Map.log("Creating central island"); | g_Map.log("Creating central island"); | ||||
islandPos[islandID_center] = mapCenter; | islandPos[islandID_center] = mapCenter; | ||||
createIsland(islandID_center, centralIslandRadius, clLand); | createIsland(islandID_center, centralIslandRadius, clLand); | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
else if (mapSize <= 192) | else if (mapSize <= 192) | ||||
{ | { | ||||
createSnowflakeSearockWithoutCenter(); | createSnowflakeSearockWithoutCenter(); | ||||
} | } | ||||
else if (mapSize <= 256) | else if (mapSize <= 256) | ||||
{ | { | ||||
if (numPlayers < 6) | if (numPlayers < 6) | ||||
createSnowflakeSearockWithCenter("medium"); | createSnowflakeSearockWithCenter(islandSizes.medium); | ||||
else | else | ||||
createSnowflakeSearockWithoutCenter(); | createSnowflakeSearockWithoutCenter(); | ||||
} | } | ||||
else if (mapSize <= 320) | else if (mapSize <= 320) | ||||
{ | { | ||||
if (numPlayers < 8) | if (numPlayers < 8) | ||||
createSnowflakeSearockWithCenter("medium"); | createSnowflakeSearockWithCenter(islandSizes.medium); | ||||
else | else | ||||
createSnowflakeSearockWithoutCenter(); | createSnowflakeSearockWithoutCenter(); | ||||
} | } | ||||
else | else | ||||
createSnowflakeSearockWithCenter(numPlayers < 6 ? "large1" : "large2"); | createSnowflakeSearockWithCenter(islandSizes["large" + (numPlayers < 6 ? "1" : "2")]); | ||||
g_Map.log("Creating player islands"); | g_Map.log("Creating player islands"); | ||||
for (let i = 0; i < numPlayers; ++i) | for (let i = 0; i < numPlayers; ++i) | ||||
{ | { | ||||
islandPos[i] = playerPosition[i]; | islandPos[i] = playerPosition[i]; | ||||
createIsland(i, 1, isNomad() ? clLand : clPlayer); | createIsland(i, 1, isNomad() ? clLand : clPlayer); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator