Improved Sector Map

Added Boss Icon
Added Home Icon
Added Legend
Placing bosses at chokepoints
Adjusted home zone placement
Added per-faction areas of influence
This commit is contained in:
Reinier Vens 2021-03-12 05:12:01 +00:00
commit 7f3f198f61
29 changed files with 2936 additions and 308 deletions

View file

@ -0,0 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Boss
m_Shader: {fileID: 203, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 66887e71b9b25b94baa1da4bf12b490d, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _TintColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2a11c63ca2fac064bbff1674f46da6e9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -76,4 +76,5 @@ Material:
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _TintColor: {r: 0.20084397, g: 0.5982815, b: 0.797, a: 1}
- _TintColor: {r: 0.79607844, g: 0.79607844, b: 0.79607844, a: 1}
m_BuildTextureStacks: []

View file

@ -86,7 +86,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Scale: 20.890537
- _Scale: 9.308572
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1

View file

@ -0,0 +1,81 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Panel Blur Sector Map
m_Shader: {fileID: 4800000, guid: 3951069d814b7174ca3bb4e8e302198b, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Size: 3
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _AdditiveColor: {r: 0.035, g: 0.035, b: 0.05, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _MultiplyColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d77aae2b18c3b68499c0781bb7e7bd9b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -57,6 +57,8 @@ Boiling Thermometer by KEN MURRAY
wifi by i cons
log in by Aya Sofya
log out by Aya Sofya
boss by Jae Deasigner
Home by Jeremy J Bristol
Other

BIN
Assets/Resources/Sprites/Icons/Circle.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 92184887b260c82429005061b0b08b3b
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Sprites/Icons/Home.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 6c9ab17a8574de140969db991b89994f
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Resources/Sprites/Icons/boss.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 66887e71b9b25b94baa1da4bf12b490d
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: -1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -65,7 +65,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 128
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
@ -77,7 +77,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 128
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1

View file

@ -65,7 +65,7 @@ TextureImporter:
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 128
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
@ -77,7 +77,7 @@ TextureImporter:
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 128
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ba9b51efccb221d4aa8c77503e173d08
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scenes/TestScene_Profiles/PP Profile.asset (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c0f0f7379aac8474d9ef1b01fa85a9c3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -41,27 +41,36 @@ public class MegaCorporation : DatabaseEntry, INamedEntry
[InspectableField, JsonProperty("name"), Key(1)]
public string Name;
[InspectableText, JsonProperty("description"), Key(2)]
[InspectableField, JsonProperty("shortName"), Key(2)]
public string ShortName;
[InspectableText, JsonProperty("description"), Key(3)]
public string Description;
[InspectableTexture, JsonProperty("logo"), Key(3)]
[InspectableTexture, JsonProperty("logo"), Key(4)]
public string Logo;
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(4)]
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(5)]
public Dictionary<Guid, float> Personality = new Dictionary<Guid, float>();
[InspectableField, JsonProperty("hostile"), Key(5)]
[InspectableField, JsonProperty("hostile"), Key(6)]
public bool PlayerHostile;
[InspectableColor, JsonProperty("primaryColor"), Key(6)]
[InspectableColor, JsonProperty("primaryColor"), Key(7)]
public float3 PrimaryColor;
[InspectableColor, JsonProperty("secondaryColor"), Key(7)]
[InspectableColor, JsonProperty("secondaryColor"), Key(8)]
public float3 SecondaryColor;
[InspectableTextAsset, JsonProperty("geonames"), Key(8)]
[InspectableTextAsset, JsonProperty("geonames"), Key(9)]
public string GeonameFile;
[InspectableDatabaseLink(typeof(HullData)), JsonProperty("bossHull"), Key(10)]
public Guid BossHull;
[InspectableField, JsonProperty("influence"), Key(11)]
public int InfluenceDistance = 4;
[IgnoreMember] public MarkovNameGenerator NameGenerator { get; set; }
[IgnoreMember] public string EntryName

View file

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using static Unity.Mathematics.math;
using Random = Unity.Mathematics.Random;
//Generates random names based on the statistical weight of letter sequences
@ -18,20 +19,40 @@ public class MarkovNameGenerator
private int _minLength;
private int _maxLength;
private Random _random;
public MarkovNameGenerator(ref Random random, string nameData, SectorGenerationSettings settings)
{
var names = new HashSet<string>();
var lines = nameData.Split('\n');
foreach (var line in lines)
{
foreach(var word in line.ToUpperInvariant().Split(' ', ',', '.', '"'))
if (word.Length >= settings.NameGeneratorMinLength && !names.Contains(word))
names.Add(word);
}
_random = random;
_order = max(1, settings.NameGeneratorOrder);
_minLength = max(1, settings.NameGeneratorMinLength);
_maxLength = settings.NameGeneratorMaxLength;
Initialize(names);
}
public MarkovNameGenerator(ref Random random, IEnumerable<string> sampleNames, int order, int minLength, int maxLength)
{
_random = random;
//fix parameter values
if (order < 1)
order = 1;
if (minLength < 1)
minLength = 1;
_order = order;
_minLength = minLength;
_order = max(1, order);
_minLength = max(1, minLength);
_maxLength = maxLength;
Initialize(sampleNames);
}
private void Initialize(IEnumerable<string> sampleNames)
{
//split comma delimited lines
foreach (string line in sampleNames)
{
@ -39,7 +60,7 @@ public class MarkovNameGenerator
foreach (string word in tokens)
{
string upper = word.Trim().ToLowerInvariant();
if (upper.Length < order + 1)
if (upper.Length < _order + 1)
continue;
_samples.Add(upper + '|'); // Add end character
}
@ -48,9 +69,9 @@ public class MarkovNameGenerator
//Build chains
foreach (string word in _samples)
{
for (int letter = 0; letter < word.Length - order; letter++)
for (int letter = 0; letter < word.Length - _order; letter++)
{
string token = word.Substring(letter, order);
string token = word.Substring(letter, _order);
List<char> entry = null;
if (_chains.ContainsKey(token))
entry = _chains[token];
@ -59,7 +80,7 @@ public class MarkovNameGenerator
entry = new List<char>();
_chains[token] = entry;
}
entry.Add(word[letter + order]);
entry.Add(word[letter + _order]);
}
}
}
@ -75,7 +96,6 @@ public class MarkovNameGenerator
{
int n = _random.NextInt(0,_samples.Count);
//int nameLength = _samples[n].Length;
//s = _samples[n].Substring(UnityEngine.Random.Range(0, _samples[n].Length - _order), _order);//get a random token somewhere in middle of sample word
s = _samples[n].Substring(0, _order);//get a random token at the start of a sample word
while (true)//(s.Length < nameLength)
{
@ -86,11 +106,11 @@ public class MarkovNameGenerator
else
break;
}
s = s.Substring(0, 1) + s.Substring(1).ToLower();
s = s.Substring(0, 1).ToUpper() + s.Substring(1);
}
while (_used.Contains(s) || s.Length < _minLength || s.Length > _maxLength);
_used.Add(s);
return s.First().ToString().ToUpper() + s.Substring(1);
return s;
}
}

View file

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DataStructures.ViliWonka.Heap;
using Unity.Mathematics;
using JM.LinqFaster;
using static Unity.Mathematics.math;
@ -7,10 +9,21 @@ using static Unity.Mathematics.math;
public class Sector
{
public List<SectorZone> Zones = new List<SectorZone>();
public Dictionary<MegaCorporation, SectorZone> OccupantSources = new Dictionary<MegaCorporation, SectorZone>();
public Dictionary<MegaCorporation, SectorZone> HomeZones = new Dictionary<MegaCorporation, SectorZone>();
public Dictionary<MegaCorporation, SectorZone> BossZones = new Dictionary<MegaCorporation, SectorZone>();
public SectorZone Entrance;
public SectorZone Exit;
private SectorZone[] _exitPath;
public SectorZone[] ExitPath
{
get
{
return _exitPath ??= FindPath(Entrance, Exit);
}
}
class DijkstraVertex
{
public float Cost;
@ -18,30 +31,29 @@ public class Sector
public SectorZone Zone;
}
public List<SectorZone> ConnectedRegion(SectorZone v, SectorZone ignoreZone = null)
{
List<SectorZone> members = new List<SectorZone>();
members.Add(v);
while (true)
{
var lastCount = members.Count;
// For each member, add all vertices that are connected to it but are not already a member
// Also, if there is a zone being ignored, do not traverse across it
foreach (SectorZone m in members.ToArray())
members.AddRange(m.AdjacentZones
.Where(z => !members.Contains(z) && !(m == v && ignoreZone == z)));
// If we have stopped finding neighbors, stop traversing
if (members.Count == lastCount)
return members;
}
}
// public HashSet<SectorZone> ConnectedRegion(SectorZone v, SectorZone ignoreZone = null)
// {
// var members = new HashSet<SectorZone> {v};
// while (true)
// {
// var lastCount = members.Count;
// // For each member, add all vertices that are connected to it but are not already a member
// // Also, if there is a zone being ignored, do not traverse across it
// foreach (var zone in members.ToArray())
// foreach(var adjacentZone in zone.AdjacentZones)
// if (!members.Contains(adjacentZone) && !(zone == v && ignoreZone == adjacentZone))
// members.Add(adjacentZone);
// // If we have stopped finding neighbors, stop traversing
// if (members.Count == lastCount)
// return members;
// }
// }
//public int TotalDistance(SectorZone v) => ConnectedRegionDistance(v).Sum(x => x.distance);
public Dictionary<SectorZone, int> ConnectedRegionDistance(SectorZone v)
{
Dictionary<SectorZone, int> members = new Dictionary<SectorZone, int>();
members.Add(v,0);
var members = new Dictionary<SectorZone, int> {{v, 0}};
int cost = 1;
while (true)
{
@ -60,31 +72,83 @@ public class Sector
cost++;
}
}
public List<SectorZone> FindPath(SectorZone source, SectorZone target, bool bestFirst = false)
public HashSet<SectorZone> ConnectedRegion(
SectorZone v,
SectorZone ignoreLink1,
SectorZone ignoreLink2,
int maxDistance = int.MaxValue)
{
SortedList<float,DijkstraVertex> members = new SortedList<float,DijkstraVertex>{{0, new DijkstraVertex{Zone = source}}};
List<DijkstraVertex> searched = new List<DijkstraVertex>();
return ConnectedRegion(v, x => x.Item1 != ignoreLink1 || x.Item2 != ignoreLink2, maxDistance);
}
public HashSet<SectorZone> ConnectedRegion(
SectorZone v,
SectorZone ignoreZone,
int maxDistance = int.MaxValue)
{
return ConnectedRegion(v, x => x.Item2 != ignoreZone, maxDistance);
}
public HashSet<SectorZone> ConnectedRegion(
SectorZone v,
int maxDistance = int.MaxValue)
{
return ConnectedRegion(v, x => true, maxDistance);
}
public HashSet<SectorZone> ConnectedRegion(
SectorZone v,
Predicate<(SectorZone,SectorZone)> linkFilter,
int maxDistance = int.MaxValue)
{
var visited = new HashSet<SectorZone> {v};
int cost = 1;
while (true)
{
var s = members.FirstOrDefault(m => !searched.Contains(m.Value)).Value; // Lowest cost unsearched node
if (s == null) return null; // No vertices left unsearched
var lastCount = visited.Count;
// For each member, add all nodes that are connected to it but have not been visited
// Also, if there is a zone being ignored, do not traverse across it
foreach (var zone in visited.ToArray())
foreach (var adjacentZone in zone.AdjacentZones)
{
if(!visited.Contains(adjacentZone) && linkFilter((zone, adjacentZone)))
visited.Add(adjacentZone);
}
// If we have stopped finding neighbors, stop traversing
if (visited.Count == lastCount || cost == maxDistance)
return visited;
cost++;
}
}
public SectorZone[] FindPath(SectorZone source, SectorZone target, bool bestFirst = false)
{
MinHeap<DijkstraVertex> unsearchedNodes = new MinHeap<DijkstraVertex>();
unsearchedNodes.PushObj(new DijkstraVertex{Zone = source}, 0);
//SortedList<float,DijkstraVertex> members = new SortedList<float,DijkstraVertex>{{0, new DijkstraVertex{Zone = source}}};
var searched = new HashSet<SectorZone>();
while (true)
{
if(unsearchedNodes.Count == 0) return null; // No nodes left unsearched
var s = unsearchedNodes.PopObj(); // Lowest cost unsearched node
if (s.Zone == target) // We found the path
{
Stack<DijkstraVertex> path = new Stack<DijkstraVertex>(); // Since we start at the end, use a LIFO collection
path.Push(s);
while(path.Peek().Parent!=null) // Keep pushing until we reach the start, which has no parent
path.Push(path.Peek().Parent);
return path.Select(dv => dv.Zone).ToList();
return path.Select(dv => dv.Zone).ToArray();
}
// For each adjacent star (filter already visited stars unless heuristic is in use)
foreach (var dijkstraStar in s.Zone.AdjacentZones
.WhereSelectF(zone => !bestFirst || members.All(m => m.Value.Zone != zone),
IEnumerable<SectorZone> zonesToSearch = s.Zone.AdjacentZones;
if (!bestFirst) zonesToSearch = zonesToSearch.Where(z => !searched.Contains(z));
foreach (var dijkstraStar in zonesToSearch
// Cost is parent cost plus distance squared
zone => new DijkstraVertex {Parent = s, Zone = zone, Cost = s.Cost + lengthsq(s.Zone.Position - zone.Position)}))
.Select(zone => new DijkstraVertex {Parent = s, Zone = zone, Cost = s.Cost + lengthsq(s.Zone.Position - zone.Position)}))
// Add new member to list, sorted by cost plus optional heuristic
members.Add(bestFirst ? dijkstraStar.Cost + lengthsq(dijkstraStar.Zone.Position - target.Position) : dijkstraStar.Cost, dijkstraStar);
searched.Add(s);
unsearchedNodes.PushObj(dijkstraStar, bestFirst ? dijkstraStar.Cost + lengthsq(dijkstraStar.Zone.Position - target.Position) : dijkstraStar.Cost);
searched.Add(s.Zone);
}
}
}
@ -96,5 +160,7 @@ public class SectorZone
public List<SectorZone> AdjacentZones = new List<SectorZone>();
public int Isolation;
public Dictionary<SectorZone, int> Distance;
public MegaCorporation[] Occupants;
public MegaCorporation[] Megas;
//public List<MegaCorporation> Megas;
public MegaCorporation Owner;
}

View file

@ -5,12 +5,13 @@ using DataStructures.ViliWonka.Heap;
using MIConvexHull;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using Random = Unity.Mathematics.Random;
public static class SectorGenerator
{
public static Sector GenerateSector(SectorGenerationSettings settings, MegaCorporation[] megas, int zoneCount = 32, float linkDensity = .5f, float minLineSeparation = .01f)
public static Sector GenerateSector(SectorGenerationSettings settings, MegaCorporation[] megas, ref Random random, float minLineSeparation = .01f)
{
var outputSamples = WeightedSampleElimination.GeneratePoints(zoneCount,
var outputSamples = WeightedSampleElimination.GeneratePoints(settings.ZoneCount,
settings.CloudDensity,
v => (.2f - lengthsq(v - float2(.5f))) * 4);
var sector = new Sector();
@ -60,10 +61,10 @@ public static class SectorGenerator
var heap = new MaxHeap<(SectorZone, SectorZone)>(links.Count);
foreach(var link in links) heap.PushObj(link, LinkWeight(link));
while (heap.Count > linkDensity * links.Count)
while (heap.Count > settings.LinkDensity * links.Count)
{
var link = heap.PopObj();
if(sector.ConnectedRegion(link.Item1, link.Item2).Contains(link.Item2))
if(sector.ConnectedRegion(link.Item1, link.Item1, link.Item2).Contains(link.Item2))
{
link.Item1.AdjacentZones.Remove(link.Item2);
link.Item2.AdjacentZones.Remove(link.Item1);
@ -83,60 +84,80 @@ public static class SectorGenerator
#endregion
// Cache distance set and calculate isolation for every zone (used extensively for placing stuff)
foreach (var zone in sector.Zones)
{
zone.Distance = sector.ConnectedRegionDistance(zone);
zone.Isolation = zone.Distance.Sum(x => x.Value);
}
// Exit is the most isolated zone (highest total distance to all other zones
sector.Exit = sector.Zones.MaxBy(z => z.Isolation);
// Entrance is the zone furthest from the exit
sector.Entrance = sector.Zones.MaxBy(z => sector.Exit.Distance[z]);
foreach (var mega in megas)
// Store exit path in hash set for querying
var exitPathSet = new HashSet<SectorZone>(sector.ExitPath);
// Find all zones on the exit path where removing that zone would disconnect the entrance from the exit
// Disregard "corridor" zones with only two adjacent zones
var chokePoints = sector.ExitPath
.Where(z => z.AdjacentZones.Count > 2 && !sector.ConnectedRegion(sector.Entrance, z).Contains(sector.Exit));
// Choose some megas to have bosses placed based on whether a boss hull is assigned
var bossMegas = megas
.Where(m => m.BossHull != Guid.Empty)
.Take(settings.BossCount)
.ToArray();
// Place boss zones along the critical path as far apart from each other as possible
foreach (var mega in bossMegas)
{
sector.OccupantSources[mega] = sector.Zones.MaxBy(z =>
sector.BossZones[mega] = chokePoints.MaxBy(z =>
sector.Exit.Distance[z] * sector.Entrance.Distance[z] *
sector.OccupantSources.Values.Aggregate(1, (i, os) => i * os.Distance[z]));
sector.BossZones.Values.Aggregate(1, (i, os) => i * os.Distance[z]));
}
foreach (var zone in sector.Zones)
// Place boss mega headquarters such that their sphere of influence encompasses their boss zone
// While occupying as much territory as possible
foreach (var mega in bossMegas)
{
var sourceDistances = new int[megas.Length];
var minSourceDistance = int.MaxValue;
var occupants = 0;
for (var i = 0; i < megas.Length; i++)
{
sourceDistances[i] = sector.OccupantSources[megas[i]].Distance[zone];
if (sourceDistances[i] == minSourceDistance)
{
occupants++;
}
if (sourceDistances[i] < minSourceDistance)
{
minSourceDistance = sourceDistances[i];
occupants = 1;
}
}
zone.Occupants = new MegaCorporation[occupants];
var occupantIndex = 0;
for (var i = 0; i < megas.Length; i++)
{
if (sourceDistances[i] == minSourceDistance)
{
zone.Occupants[occupantIndex++] = megas[i];
}
}
}
sector.Zones[0].Name = "Hello World!";
foreach (var zone in sector.Zones)
{
zone.Name = zone.Occupants[0].NameGenerator.NextName; // TODO: Merge Naming
sector.HomeZones[mega] = sector
.ConnectedRegion(sector.BossZones[mega], mega.InfluenceDistance)
.MaxBy(z =>
sector.ConnectedRegion(z, mega.InfluenceDistance).Count *
sector.HomeZones.Values.Aggregate(1f, (i, os) => i * sqrt(os.Distance[z])));
}
// Place remaining headquarters away from existing megas while also maximizing territory
foreach (var mega in megas.Where(m=>!bossMegas.Contains(m)))
{
sector.HomeZones[mega] = sector.Zones.MaxBy(z =>
pow(sector.ConnectedRegion(z, mega.InfluenceDistance).Count, sector.HomeZones.Count) *
sector.Exit.Distance[z] * sector.Entrance.Distance[z] *
sector.HomeZones.Values.Aggregate(1f, (i, os) => i * sqrt(os.Distance[z])) *
sector.BossZones.Values.Aggregate(1f, (i, os) => i * sqrt(os.Distance[z])));
}
// Assign faction presence
foreach (var zone in sector.Zones)
{
// All megas for are present in zones within their sphere of influence
zone.Megas = megas
.Where(m => zone.Distance[sector.HomeZones[m]] <= m.InfluenceDistance)
.ToArray();
// Owner of a zone is the one with the nearest headquarters
var nearestMega = megas.MinBy(m => zone.Distance[sector.HomeZones[m]]);
if (zone.Distance[sector.HomeZones[nearestMega]] <= nearestMega.InfluenceDistance)
zone.Owner = nearestMega;
}
// Generate zone name using the owner's name generator, otherwise assign catalogue ID
foreach (var zone in sector.Zones)
zone.Name = zone.Owner?.NameGenerator.NextName ?? $"EAC-{random.NextInt(99999).ToString()}";
return sector;
}
}

View file

@ -46,6 +46,13 @@ public class GalaxyShapeSettings
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
public class SectorGenerationSettings
{
public float LinkDensity = .5f;
public int ZoneCount = 128;
public int NameGeneratorMinLength = 5;
public int NameGeneratorMaxLength = 10;
public int NameGeneratorOrder = 4;
public int MegaCount;
public int BossCount;
public float NoisePosition;
public float CloudExponent;
public float CloudAmplitude;

View file

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class LegendElement : MonoBehaviour
{
public Image Icon;
public TextMeshProUGUI Label;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d3cdb62043eacb24b87bab4e3584c17c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -17,18 +17,17 @@ public class SectorMap : MonoBehaviour
public SectorGenerationSettings Settings;
public Prototype ZonePrototype;
public Prototype LinkPrototype;
public Prototype EntrancePrototype;
public Prototype ExitPrototype;
public float ExitDistance = 1;
public Prototype IconPrototype;
public Texture2D EntranceIcon;
public Texture2D ExitIcon;
public Texture2D BossIcon;
public Texture2D HomeIcon;
public Prototype LegendPrototype;
public float IconDistance = 1;
public float MegaColorBoost = 2.5f;
public int ZoneCount = 64;
public int MegaCount = 2;
public float LinkDensity = .5f;
public float LabelDistance = .4f;
[Header("Name Generation")]
public int NameGeneratorMinLength = 5;
public int NameGeneratorMaxLength = 10;
public int NameGeneratorOrder = 4;
// Start is called before the first frame update
void Start()
{
@ -38,33 +37,28 @@ public class SectorMap : MonoBehaviour
var megas = cache.GetAll<MegaCorporation>();
var sectorMegas = megas.OrderBy(x => Random.value).Take(MegaCount).ToArray();
var random = new Unity.Mathematics.Random((uint) (DateTime.Now.Ticks % uint.MaxValue));
var sectorMegas = megas.OrderBy(x => Random.value).Take(Settings.MegaCount).ToArray();
foreach (var mega in sectorMegas)
{
var nameFile = UnityHelpers.LoadAsset<TextAsset>(mega.GeonameFile);
var names = new HashSet<string>();
var lines = nameFile.text.Split('\n');
foreach (var line in lines)
{
foreach(var word in line.ToUpperInvariant().Split(' ', ',', '.', '"'))
if (word.Length >= NameGeneratorMinLength && !names.Contains(word))
names.Add(word);
}
var random = new Unity.Mathematics.Random((uint) (DateTime.Now.Ticks % uint.MaxValue));
mega.NameGenerator = new MarkovNameGenerator(ref random, names, NameGeneratorOrder, NameGeneratorMinLength, NameGeneratorMaxLength);
mega.NameGenerator = new MarkovNameGenerator(ref random, UnityHelpers.LoadAsset<TextAsset>(mega.GeonameFile).text, Settings);
var legendElement = LegendPrototype.Instantiate<LegendElement>();
legendElement.Icon.color = mega.PrimaryColor.ToColor();
legendElement.Label.text = mega.ShortName;
}
Settings.NoisePosition = Random.value * 100;
var sector = SectorGenerator.GenerateSector(Settings, sectorMegas, ZoneCount, LinkDensity);
var sector = SectorGenerator.GenerateSector(Settings, sectorMegas, ref random);
var visitedZones = new HashSet<SectorZone>();
Debug.Log($"Found {sector.Zones.Count(z=>!z.AdjacentZones.Any())} orphaned zones!");
foreach (var zone in sector.Zones)
{
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
zoneInstance.transform.localPosition = new Vector3(zone.Position.x, zone.Position.y);
zoneInstance.Background.material.SetColor("_TintColor", zone.Occupants[0].PrimaryColor.ToColor());
zoneInstance.Background.transform.localScale = Vector3.one * (sector.OccupantSources.Values.Any(os=>os==zone) ? 4 : 2);
var zoneInstanceTransform = zoneInstance.transform;
zoneInstanceTransform.localPosition = new Vector3(zone.Position.x, zone.Position.y);
if(zone.Owner != null)
zoneInstance.Background.material.SetColor("_TintColor", zone.Owner.PrimaryColor.ToColor() * MegaColorBoost);
//zoneInstance.Background.transform.localScale = Vector3.one * (sector.HomeZones.Values.Any(os=>os==zone) ? 4 : 2);
var linkDirection = float2.zero;
foreach (var link in zone.AdjacentZones)
{
@ -74,9 +68,9 @@ public class SectorMap : MonoBehaviour
var linkInstance = LinkPrototype.Instantiate<Transform>();
var pos = (zone.Position + link.Position) / 2;
linkInstance.localPosition = new Vector3(pos.x, pos.y);
if (zone.Occupants.Length == 1 && link.Occupants.Length == 1 && zone.Occupants[0] == link.Occupants[0])
if (zone.Owner != null && zone.Owner == link.Owner)
{
linkInstance.GetComponent<MeshRenderer>().material.SetColor("_TintColor", zone.Occupants[0].PrimaryColor.ToColor());
linkInstance.GetComponent<MeshRenderer>().material.SetColor("_TintColor", zone.Owner.PrimaryColor.ToColor());
}
var localScale = linkInstance.localScale;
@ -98,18 +92,46 @@ public class SectorMap : MonoBehaviour
if (zone == sector.Entrance)
{
var entranceInstance = EntrancePrototype.Instantiate<Transform>();
entranceInstance.localPosition = new Vector3(
zone.Position.x - linkDirection.x * ExitDistance,
zone.Position.y - linkDirection.y * ExitDistance);
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
iconInstance.material.mainTexture = EntranceIcon;
var iconTransform = iconInstance.transform;
iconTransform.SetParent(zoneInstanceTransform);
iconTransform.localScale = Vector3.one;
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
if (zone == sector.Exit)
{
var entranceInstance = ExitPrototype.Instantiate<Transform>();
entranceInstance.localPosition = new Vector3(
zone.Position.x - linkDirection.x * ExitDistance,
zone.Position.y - linkDirection.y * ExitDistance);
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
iconInstance.material.mainTexture = ExitIcon;
var iconTransform = iconInstance.transform;
iconTransform.SetParent(zoneInstanceTransform);
iconTransform.localScale = Vector3.one;
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
var bossMega = sector.BossZones.Keys.FirstOrDefault(m => sector.BossZones[m] == zone);
if (bossMega != null)
{
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
iconInstance.material.mainTexture = BossIcon;
iconInstance.material.SetColor("_TintColor", bossMega.PrimaryColor.ToColor());
var iconTransform = iconInstance.transform;
iconTransform.SetParent(zoneInstanceTransform);
iconTransform.localScale = Vector3.one;
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
var homeMega = sector.HomeZones.Keys.FirstOrDefault(m => sector.HomeZones[m] == zone);
if (homeMega != null)
{
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
iconInstance.material.mainTexture = HomeIcon;
iconInstance.material.SetColor("_TintColor", homeMega.PrimaryColor.ToColor());
var iconTransform = iconInstance.transform;
iconTransform.SetParent(zoneInstanceTransform);
iconTransform.localScale = Vector3.one;
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
}
}
}

View file

@ -23,10 +23,10 @@ Shader "Unlit/GalaxyMap"
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Tags { "RenderType"="Opaque" }
LOD 100
Blend One One
Cull Off Lighting Off ZWrite Off
//Blend One One
Lighting Off ZWrite Off
Pass
{

Binary file not shown.