feat: better UI

This commit is contained in:
LordDemonix 2025-09-18 20:05:01 +02:00
parent ab67ca045d
commit d29e4f9577
34 changed files with 87856 additions and 103919 deletions

File diff suppressed because it is too large Load diff

View file

@ -60,6 +60,11 @@ public static class EditorCustom
GameManager gm = (GameManager)target;
if (GUILayout.Button("Execute Turn") && gm.actions.Count > 0)
{
gm.ExecuteTurn();
}
GUILayout.Label("Generation Parameters", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
@ -163,16 +168,14 @@ public static class EditorCustom
if (GUILayout.Button("Save as new"))
gm.SaveLevelData();
GUILayout.Space(20);
if (GUILayout.Button("Execute Round End"))
gm.ExecuteRoundEnd();
}
// Custom Scene Interaction while GameManager selected
private void OnSceneGUI()
{
if (Application.isPlaying)
return;
Handles.zTest = UnityEngine.Rendering.CompareFunction.LessEqual;
GameManager gm = FindFirstObjectByType<GameManager>();

8
Assets/Materials.meta Normal file
View file

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

View file

@ -0,0 +1,138 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &7665016510188140211
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6561832683277441426}
- component: {fileID: 2619683893873293193}
- component: {fileID: 8640308073572617548}
m_Layer: 9
m_Name: ActionListItem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6561832683277441426
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7665016510188140211}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 191.44, y: 202.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2619683893873293193
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7665016510188140211}
m_CullTransparentMesh: 1
--- !u!114 &8640308073572617548
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7665016510188140211}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: aa
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_sharedMaterial: {fileID: -2723583854633709972, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4278255383
m_fontColor: {r: 0.08960724, g: 1, b: 0, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 18
m_fontSizeBase: 31
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: -26.5
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 81c4ce2b48d8a0945947e98b0805e0c2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1882714990603045140
--- !u!1 &6039747573752144155
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -8,223 +8,71 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7439290390685280375}
- component: {fileID: 7097930607199171882}
- component: {fileID: 7499881475324519762}
m_Layer: 9
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7439290390685280375
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1882714990603045140}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1.96}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7965170655419664431}
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 2.21}
m_SizeDelta: {x: 10, y: 5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!23 &7097930607199171882
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1882714990603045140}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: -2723583854633709972, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &7499881475324519762
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1882714990603045140}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_sharedMaterial: {fileID: -2723583854633709972, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 0
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 0
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
_SortingLayer: 0
_SortingLayerID: 0
_SortingOrder: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 7097930607199171882}
m_maskType: 0
--- !u!1 &2988688958532262917
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8477257823486794534}
- component: {fileID: 1183838628607877705}
- component: {fileID: 4493658626761809840}
- component: {fileID: 1163466899257774620}
- component: {fileID: 7965170655419664431}
- component: {fileID: 6619618649642168463}
- component: {fileID: 2275744724860474492}
- component: {fileID: 872194154712195731}
- component: {fileID: 8171892701294448921}
m_Layer: 0
m_Name: Sphere
m_Name: Point
m_TagString: Node
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8477257823486794534
--- !u!4 &7965170655419664431
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2988688958532262917}
m_GameObject: {fileID: 6039747573752144155}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 2, y: 2, z: 2}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 7965170655419664431}
m_Children:
- {fileID: 7439290390685280375}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1183838628607877705
--- !u!114 &6619618649642168463
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6039747573752144155}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
m_Name:
m_EditorClassIdentifier:
Owner: -1
Units: 0
id: 0
unitText: {fileID: 7499881475324519762}
materialOwnerSelf: {fileID: 2100000, guid: 06d3b3201213c004a95a21afd8cdeb93, type: 2}
materialOwnerOther: {fileID: 2100000, guid: 6fd755fe2122d2443a364b2c2a3a8291, type: 2}
materialOwnerNone: {fileID: 2100000, guid: c670d9c5cf5963b4e9ca485b3528ea58, type: 2}
materialHover: {fileID: 2100000, guid: b1674e8dbc8b67648ad5ede0c4e347a8, type: 2}
connected: []
hovered: 0
--- !u!33 &2275744724860474492
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2988688958532262917}
m_GameObject: {fileID: 6039747573752144155}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &4493658626761809840
--- !u!23 &872194154712195731
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2988688958532262917}
m_GameObject: {fileID: 6039747573752144155}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
@ -263,13 +111,13 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!135 &1163466899257774620
--- !u!135 &8171892701294448921
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2988688958532262917}
m_GameObject: {fileID: 6039747573752144155}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
@ -284,59 +132,116 @@ SphereCollider:
serializedVersion: 3
m_Radius: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &6039747573752144155
GameObject:
--- !u!1001 &4331339744264451809
PrefabInstance:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7965170655419664431}
- component: {fileID: 6619618649642168463}
m_Layer: 0
m_Name: Point
m_TagString: Node
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7965170655419664431
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6039747573752144155}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 1
m_Children:
- {fileID: 8477257823486794534}
- {fileID: 7439290390685280375}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &6619618649642168463
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 7965170655419664431}
m_Modifications:
- target: {fileID: 2755285719916969973, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_Name
value: Text (TMP)
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_AnchorMax.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_AnchorMin.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalPosition.z
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalRotation.x
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_AnchoredPosition.y
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 180
objectReference: {fileID: 0}
- target: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5d12260eabac775499459852270e99c8, type: 3}
--- !u!224 &7439290390685280375 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 6566716362904575638, guid: 5d12260eabac775499459852270e99c8, type: 3}
m_PrefabInstance: {fileID: 4331339744264451809}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6039747573752144155}
m_Enabled: 1
--- !u!114 &7499881475324519762 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 6055350264736109491, guid: 5d12260eabac775499459852270e99c8, type: 3}
m_PrefabInstance: {fileID: 4331339744264451809}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 041c65d606731c44cb794dc7d95e72dd, type: 3}
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Name:
m_EditorClassIdentifier:
Owner: -1
Units: 0
id: 0
unitText: {fileID: 7499881475324519762}
materialOwnerSelf: {fileID: 2100000, guid: 06d3b3201213c004a95a21afd8cdeb93, type: 2}
materialOwnerOther: {fileID: 2100000, guid: 6fd755fe2122d2443a364b2c2a3a8291, type: 2}
materialOwnerNone: {fileID: 2100000, guid: c670d9c5cf5963b4e9ca485b3528ea58, type: 2}
materialHover: {fileID: 2100000, guid: b1674e8dbc8b67648ad5ede0c4e347a8, type: 2}
connected: []
hovered: 0

View file

@ -0,0 +1,178 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2755285719916969973
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6566716362904575638}
- component: {fileID: 6817579896254186443}
- component: {fileID: 6055350264736109491}
m_Layer: 9
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6566716362904575638
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2755285719916969973}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 2}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!23 &6817579896254186443
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2755285719916969973}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: -2723583854633709972, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &6055350264736109491
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2755285719916969973}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 0
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_sharedMaterial: {fileID: -2723583854633709972, guid: e01dc04fc20642041aebeaef670ef411, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 20
m_fontSizeBase: 20
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 0
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 0
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
_SortingLayer: 0
_SortingLayerID: 0
_SortingOrder: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 6817579896254186443}
m_maskType: 0

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5d12260eabac775499459852270e99c8
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -37,6 +37,21 @@ public class CameraOrbit : MonoBehaviour
{
if (target == null) return;
float scroll = Input.GetAxis("Mouse ScrollWheel");
if (scroll != 0f)
{
float fov = -1;
foreach (Camera _cam in transform.GetComponentsInChildren<Camera>())
{
if (fov < 0) // Calculate FOV for first Camera
{
fov = _cam.fieldOfView - scroll * GameManager.Instance.zoomSpeed;
fov = Mathf.Clamp(fov, GameManager.Instance.minFOV, GameManager.Instance.maxFOV);
}
_cam.fieldOfView = fov;
}
}
if (Input.GetMouseButton(1)) // Rechte Maustaste gedrückt
{
Cursor.lockState = CursorLockMode.Locked;
@ -56,45 +71,60 @@ public class CameraOrbit : MonoBehaviour
transform.rotation = rotation;
transform.position = position;
Ray ray = transform.GetChild(0).GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
Camera cam = transform.GetChild(0).GetComponent<Camera>();
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, float.MaxValue))
{
GameManager gm = FindFirstObjectByType<GameManager>();
if (hit.transform.CompareTag("Node"))
{
var obj = hit.transform.parent.GetComponent<Node>();
var obj = hit.transform.GetComponent<Node>();
obj.hovered = true;
}
else
{
GameManager gm = FindFirstObjectByType<GameManager>();
Connection closestCon = null;
float closestDist = 0.5f; // maximale Abstand in Welt-Einheiten
foreach (var con in gm.GetConnections())
// Hover-Ermittlung Connections
Vector2 mouse = Input.mousePosition;
Vector3 mousePos = new Vector3(mouse.x, mouse.y, 0);
bool cancelHover = false;
float closestDist = float.MaxValue;
int closestIdx = -1;
var connections = gm.GetConnections();
for (int i = 0; i < connections.Count; i++)
{
Vector3 a = con.nodeA.transform.position;
Vector3 b = con.nodeB.transform.position;
connections[i].hovered = false;
if (cancelHover)
continue;
var con = connections[i];
Vector3 a = cam.WorldToScreenPoint(con.nodeA.transform.position);
Vector3 b = cam.WorldToScreenPoint(con.nodeB.transform.position);
Vector3 ab = b - a;
float t = Mathf.Clamp01(Vector3.Dot(hit.point - a, ab) / ab.sqrMagnitude);
Vector3 am = mousePos - a;
float t = Mathf.Clamp01(Vector3.Dot(am, ab) / ab.sqrMagnitude);
Vector3 proj = a + t * ab;
float dist = Vector3.Distance(mousePos, proj);
float dist = Vector3.Distance(hit.point, proj);
if (dist < closestDist)
if (Vector3.Distance(a, mousePos) <= gm.hoverRadiusNode || Vector3.Distance(b, mousePos) <= gm.hoverRadiusNode)
cancelHover = true;
if (dist < closestDist && dist < gm.hoverRadiusCon)
{
closestDist = dist;
closestCon = con;
}
}
if (closestCon != null)
{
closestCon.hovered = true;
closestIdx = i;
}
}
if (closestIdx >= 0 && !cancelHover)
connections[closestIdx].hovered = true;
gm.hoverText.gameObject.transform.transform.forward = Camera.main.transform.forward;
gm.hoverText.gameObject.transform.position = hit.point + Vector3.up * 3.0f;
gm.hoverText.gameObject.transform.localPosition = gm.hoverText.gameObject.transform.localPosition.normalized * 23f;
}
}
}

View file

@ -11,6 +11,7 @@ public class Connection : MonoBehaviour
public BuildState state = BuildState.EMPTY;
public bool hovered = false;
public LineRenderer lineRenderer;
public int constructingPlayerId = -1;
public void SetConnect()
{
@ -30,21 +31,12 @@ public class Connection : MonoBehaviour
// On Click
if (Input.GetMouseButtonDown(0) && hovered && allowed)
{
int player = GameManager.Instance.currentPlayer;
if (state == BuildState.BUILT && nodeA.Owner == player && nodeB.Owner == player)
GameManager.Instance.pressedCon = this;
}
if(Input.GetMouseButtonUp(0) && hovered && allowed && GameManager.Instance.pressedCon == this)
{
bool explode = Input.GetKey(KeyCode.LeftShift);
var action = new GameManager.Action { nodeToId = nodeA.id, nodeFromId = nodeB.id, player = player, type = explode ? GameManager.ActionType.EXPLODE_CON : GameManager.ActionType.DESTRUCT_CON };
GameManager.Instance.ExecuteAction(action);
GameManager.Instance.PushNewAction(nodeA.id, nodeB.id, true);
}
else if(state == BuildState.EMPTY && (nodeA.Owner == player || nodeB.Owner == player))
{
var action = new GameManager.Action { nodeToId = nodeA.id, nodeFromId = nodeB.id, player = player, type = GameManager.ActionType.MOVE_UNITS };
GameManager.Instance.ExecuteAction(action);
}
}
if (Application.isPlaying && !allowed)
lineRenderer.enabled = false;
@ -54,8 +46,8 @@ public class Connection : MonoBehaviour
Color unbuiltColor = !allowed || state == BuildState.EMPTY ? new Color(0.2f, 0.2f, 0.2f) : new Color(0.8f, 0.8f, 0f);
lineRenderer.startColor = allowed && state == BuildState.BUILT ? nodeA.transform.GetChild(0).GetComponent<Renderer>().sharedMaterial.color : unbuiltColor;
lineRenderer.endColor = allowed && state == BuildState.BUILT ? nodeB.transform.GetChild(0).GetComponent<Renderer>().sharedMaterial.color : unbuiltColor;
lineRenderer.startColor = allowed && state == BuildState.BUILT ? nodeA.GetComponent<Renderer>().sharedMaterial.color : unbuiltColor;
lineRenderer.endColor = allowed && state == BuildState.BUILT ? nodeB.GetComponent<Renderer>().sharedMaterial.color : unbuiltColor;
lineRenderer.startWidth = width;
lineRenderer.endWidth = width;

View file

@ -2,13 +2,11 @@
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using TMPro;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
using static UnityEngine.GraphicsBuffer;
using static UnityEngine.UI.GridLayoutGroup;
using UnityEngine.UI;
[ExecuteAlways]
@ -19,14 +17,32 @@ public class GameManager : MonoBehaviour
public Transform NodeParent;
public GameObject NodePrefab;
public TMP_Text hoverText;
public TMP_Text energyText;
public TMP_Text currentPlayerText;
public GameObject actionListItemPrefab;
public Transform actionListParent;
public Button finishTurnBtn;
[SerializeField]
public List<Player> players;
public int currentPlayer = -1;
public Node pressedNode = null;
public Connection pressedCon = null;
public KeyCode altActionKey = KeyCode.LeftShift;
public float zoomSpeed = 20f;
public float minFOV = 20f;
public float maxFOV = 80f;
public static GameManager Instance { get; private set; }
public bool regenerateOnChange = false;
[SerializeField]
public List<Action> actions;
[HideInInspector] public float minConnectionLength = 6;
[HideInInspector] public float maxConnectionLength = 6;
[HideInInspector] public int nodeCount = 100;
@ -36,11 +52,43 @@ public class GameManager : MonoBehaviour
[SerializeField] [HideInInspector] public List<LevelData> levels = new List<LevelData>();
public enum ActionType { MOVE_UNITS, DESTRUCT_CON, EXPLODE_CON };
public enum ActionType { NONE, MOVE_HALF_UNITS, MOVE_ALL_UNITS, ATTACK_NODE_WITH_HALF, ATTACK_NODE_WITH_ALL, ATTACK_CON_WITH_HALF, ATTACK_CON_WITH_ALL, CONSTRUCT_CON, DESTRUCT_CON, EXPLODE_CON };
public Dictionary<ActionType, string> ActionTypeText = new Dictionary<ActionType, string>
{
{ ActionType.NONE, "" },
{ ActionType.MOVE_HALF_UNITS, "Move troops (1/2)" },
{ ActionType.MOVE_ALL_UNITS, "Move troops" },
{ ActionType.ATTACK_NODE_WITH_HALF, "Attack (1/2)" },
{ ActionType.ATTACK_NODE_WITH_ALL, "Attack" },
{ ActionType.ATTACK_CON_WITH_HALF, "Interrupt Construction (1/2)" },
{ ActionType.ATTACK_CON_WITH_ALL, "Interrupt Construction" },
{ ActionType.CONSTRUCT_CON, "Construct" },
{ ActionType.DESTRUCT_CON, "Destruct" },
{ ActionType.EXPLODE_CON, "Explode (immediately)" }
};
public Dictionary<ActionType, int> ActionTypeEnergyUsage = new Dictionary<ActionType, int>
{
{ ActionType.NONE, 0},
{ ActionType.MOVE_HALF_UNITS, 1},
{ ActionType.MOVE_ALL_UNITS, 1},
{ ActionType.ATTACK_NODE_WITH_HALF, 1},
{ ActionType.ATTACK_NODE_WITH_ALL, 1},
{ ActionType.ATTACK_CON_WITH_HALF, 1},
{ ActionType.ATTACK_CON_WITH_ALL, 1},
{ ActionType.CONSTRUCT_CON, 1},
{ ActionType.DESTRUCT_CON, 1},
{ ActionType.EXPLODE_CON, 2 }
};
[Serializable]
public struct Action
{
public ActionType type;
public ActionType intendedAction;
public bool onConnection;
public bool altAction;
public int nodeFromId;
public int nodeToId;
public int amount;
@ -55,6 +103,7 @@ public class GameManager : MonoBehaviour
{
public Vector3 position;
public int owner;
public int units;
}
[Serializable]
@ -90,12 +139,55 @@ public class GameManager : MonoBehaviour
}
private void Start()
{
LoadLevelData(selectedLevel);
}
private void Update()
{
hoverText.enabled = false;
Player player = players.Find(p => p.id == currentPlayer);
int totalEnergyCost = 0;
actions.ForEach(a => totalEnergyCost += ActionTypeEnergyUsage[a.intendedAction]);
if (player != null && Application.isPlaying)
{
energyText.text = "Energy: [" + string.Concat(Enumerable.Repeat("□", player.energy - totalEnergyCost)) + string.Concat(Enumerable.Repeat("-", totalEnergyCost)) + "]";
currentPlayerText.text = "[ Player " + currentPlayer + " ]";
foreach (TMP_Text item in actionListParent.GetComponentsInChildren<TMP_Text>())
Destroy(item.gameObject);
actions.ForEach(a => Instantiate(actionListItemPrefab, actionListParent).GetComponentInChildren<TMP_Text>().text = ActionTypeText[a.intendedAction] + " (" + a.nodeFromId + ">" + a.nodeToId + ")");
}
if (Input.GetMouseButtonDown(0))
{
pressedNode = GetNodes().Find(n => n.hovered && n.Owner == currentPlayer);
}
if (Input.GetMouseButton(0))
{
if(pressedNode != null)
{
Node node = GetNodes().Find(n => n.hovered && n != pressedNode);
if (node)
{
Connection con = GetConnections().Find(c => (c.nodeA == pressedNode && c.nodeB == node) || (c.nodeB == pressedNode && c.nodeA == node)) ?? null;
ActionType possibleAction = CalcActionBetweenNodes(currentPlayer, pressedNode.id, node.id, Input.GetKey(altActionKey));
hoverText.text = ActionTypeText[possibleAction];
hoverText.enabled = true;
if (con != null && con.allowed)
con.hovered = true;
}
}
}
if (Input.GetMouseButtonUp(0))
{
if (pressedNode != null)
@ -104,31 +196,181 @@ public class GameManager : MonoBehaviour
if (toNode)
{
Connection con = Instance.GetConnections().Find(c => (c.nodeA == pressedNode && c.nodeB == toNode) || (c.nodeB == pressedNode && c.nodeA == toNode));
if (con)
Connection con = GetConnections().Find(c => (c.nodeA == pressedNode && c.nodeB == toNode) || (c.nodeB == pressedNode && c.nodeA == toNode)) ?? null;
if (con != null && con.allowed)
PushNewAction(pressedNode.id, toNode.id);
}
}
}
if (!hoverText.enabled)
{
var action = new Action { nodeFromId = pressedNode.id, nodeToId = toNode.id, type = ActionType.MOVE_UNITS, player = Instance.currentPlayer };
Instance.ExecuteAction(action);
}
Connection hoveredCon = GetConnections().Find(c => c.hovered);
if (hoveredCon != null)
{
ActionType possibleAction = CalcActionBetweenNodes(currentPlayer, hoveredCon.nodeA.id, hoveredCon.nodeB.id, Input.GetKey(altActionKey), true);
hoverText.text = ActionTypeText[possibleAction];
hoverText.enabled = true;
}
}
}
public ActionType CalcActionBetweenNodes(int player, int nodeFromId, int nodeToId, bool altAction = false, bool onConnection = false)
{
Node nodeTo = GetNodes().Find(n => n.id == nodeToId);
Node nodeFrom = GetNodes().Find(n => n.id == nodeFromId);
Connection con = GetConnections().Find(c => (c.nodeA == nodeTo && c.nodeB == nodeFrom) || (c.nodeA == nodeFrom && c.nodeB == nodeTo));
if (con == null || con.allowed == false)
return ActionType.NONE;
// Clicked on connection
if (onConnection)
{
if (con.state == Connection.BuildState.BUILT && nodeFrom.Owner == player && nodeTo.Owner == player)
{
return altAction ? ActionType.EXPLODE_CON : ActionType.DESTRUCT_CON;
}
else if (con.state == Connection.BuildState.EMPTY && (nodeFrom.Owner == player || nodeTo.Owner == player))
{
return ActionType.CONSTRUCT_CON;
}
}
// Dragged owned nodeFrom to nodeTo
else if (nodeFrom.Owner == player)
{
// To Owned
if (nodeTo.Owner == player)
{
switch (con.state)
{
case Connection.BuildState.EMPTY:
return ActionType.CONSTRUCT_CON;
case Connection.BuildState.CONSTRUCTING:
case Connection.BuildState.DECONSTRUCTING:
return ActionType.NONE;
case Connection.BuildState.BUILT:
return altAction ? ActionType.MOVE_HALF_UNITS : ActionType.MOVE_ALL_UNITS;
}
}
// To Hostile
else if (nodeTo.Owner >= 0)
{
switch (con.state)
{
case Connection.BuildState.EMPTY:
return ActionType.CONSTRUCT_CON;
case Connection.BuildState.CONSTRUCTING:
return altAction ? ActionType.ATTACK_CON_WITH_HALF : ActionType.ATTACK_CON_WITH_ALL;
case Connection.BuildState.DECONSTRUCTING:
return ActionType.NONE;
case Connection.BuildState.BUILT:
return altAction ? ActionType.ATTACK_NODE_WITH_HALF : ActionType.ATTACK_NODE_WITH_ALL;
}
}
// To Unclaimed
else
{
switch (con.state)
{
case Connection.BuildState.EMPTY:
return ActionType.CONSTRUCT_CON;
case Connection.BuildState.CONSTRUCTING:
case Connection.BuildState.DECONSTRUCTING:
return ActionType.NONE;
case Connection.BuildState.BUILT:
return altAction ? ActionType.MOVE_HALF_UNITS : ActionType.MOVE_ALL_UNITS;
}
}
}
return ActionType.NONE;
}
public List<Node> GetNodes() => NodeParent.GetComponentsInChildren<Node>().ToList();
public List<Connection> GetConnections() => ConnectionParent != null ? ConnectionParent.GetComponentsInChildren<Connection>()?.ToList() ?? new() : new();
public void ExecuteRoundEnd()
public void UpdateConstructions()
{
foreach(Connection con in GetConnections())
{
if (con.constructingPlayerId == currentPlayer)
{
if (con.state == Connection.BuildState.CONSTRUCTING)
con.state = Connection.BuildState.BUILT;
else if (con.state == Connection.BuildState.DECONSTRUCTING)
con.state = Connection.BuildState.EMPTY;
con.constructingPlayerId = -1;
}
}
}
public void ExecuteTurn()
{
Player player = players.Find(p => p.id == currentPlayer);
if (player == null)
{
Debug.LogWarning("Player " + currentPlayer + " not found!");
return;
}
int totalEnergyCost = 0;
actions.ForEach(a => totalEnergyCost += ActionTypeEnergyUsage[a.intendedAction]);
if (totalEnergyCost > player.energy)
{
Debug.Log("Insuficcient Energy for Turn! (needs " + totalEnergyCost + " has " + player.energy + ")");
return;
}
actions.ForEach(a => ExecuteAction(a));
actions.Clear();
// Select next player
currentPlayer++;
Player nextPlayer = players.Find(p => p.id == currentPlayer);
// Executed turn of last Player => Round ended
if(nextPlayer == null)
currentPlayer = 0;
UpdateConstructions();
// Refill energy
players.Find(p => p.id == currentPlayer).energy = 3;
}
public void PushAction(Action action) => actions.Add(action);
public Action PushNewAction(int nodeFromId, int nodeToId, bool onConnection = false, int? player = null, bool ? altAction = null)
{
int _player = player != null ? (int)player : currentPlayer;
bool _altAction = altAction != null ? (bool)altAction : Input.GetKey(altActionKey);
ActionType type = CalcActionBetweenNodes(_player, nodeFromId, nodeToId, _altAction, onConnection);
Action action = new Action
{
intendedAction = type,
nodeFromId = nodeFromId,
nodeToId = nodeToId,
player = _player,
altAction = _altAction,
onConnection = onConnection
};
if(type != ActionType.NONE)
PushAction(action);
return action;
}
public void ExecuteAction(Action action)
{
@ -137,94 +379,79 @@ public class GameManager : MonoBehaviour
Connection con = GetConnections().Find(c => (c.nodeA == nodeTo && c.nodeB == nodeFrom) || (c.nodeA == nodeFrom && c.nodeB == nodeTo));
Player p = players.Find(p => (p.id == action.player));
bool hostile = nodeTo.Owner != action.player;
switch (action.type)
if (p == null)
{
case ActionType.MOVE_UNITS:
if (p.energy < 1)
{
Debug.Log("Not enough energy");
Debug.LogWarning("Player " + action.player + " not found!");
return;
}
p.energy -= 1;
switch (con.state)
{
case Connection.BuildState.EMPTY:
// Build Connection
con.state = Connection.BuildState.CONSTRUCTING;
Debug.Log("Starting construction from " + nodeTo.id + " to " + nodeFrom.id);
ActionType possibleAction = CalcActionBetweenNodes(action.player, action.nodeFromId, action.nodeToId, action.altAction, action.onConnection);
if (possibleAction != action.intendedAction)
{
Debug.LogWarning("Intended action not possible (TODO: execute counter action)");
return;
}
case Connection.BuildState.CONSTRUCTING:
if (hostile)
if (p.energy < ActionTypeEnergyUsage[action.intendedAction])
{
Debug.Log("Attacking hostile construction from " + nodeTo.id + " to " + nodeFrom.id);
}
else
{
Debug.Log("This should not be possible O_o");
}
Debug.Log("Insuficcient Energy! (needs " + ActionTypeEnergyUsage[action.intendedAction] + " has " + p.energy + ")");
return;
}
case Connection.BuildState.DECONSTRUCTING:
if (hostile)
switch (action.intendedAction)
{
Debug.Log("Attacking hostile construction from " + nodeTo.id + " to " + nodeFrom.id);
}
else
{
Debug.Log("This should not be possible O_o");
}
return;
case ActionType.NONE:
break;
case Connection.BuildState.BUILT:
if (hostile)
{
Debug.Log("Attacking hostile units at " + nodeFrom.id);
int actualAmount = action.amount + Math.Min(0, nodeFrom.Units - action.amount);
nodeFrom.Units -= actualAmount;
var unitDiff = actualAmount - nodeFrom.Units;
nodeTo.Units -= actualAmount;
if (unitDiff == 0)
{
nodeTo.Owner = -1;
} else if (unitDiff > 0)
{
nodeTo.Owner = p.id;
}
}
else
{
case ActionType.MOVE_HALF_UNITS:
case ActionType.MOVE_ALL_UNITS:
Debug.Log("Moving units from " + nodeTo.id + " to " + nodeFrom.id);
int actualAmount = action.amount + Math.Min(0, nodeFrom.Units - action.amount);
nodeFrom.Units -= actualAmount;
nodeTo.Units += actualAmount;
}
return;
default:
return;
if (action.intendedAction == ActionType.MOVE_ALL_UNITS)
{
nodeTo.Units += nodeFrom.Units;
nodeFrom.Units = 0;
}
else if (action.intendedAction == ActionType.MOVE_HALF_UNITS)
{
int diff = Mathf.CeilToInt(nodeFrom.Units / 2);
nodeTo.Units += diff;
nodeFrom.Units -= diff;
}
if (nodeFrom.Units <= 0)
nodeFrom.Owner = -1;
if (nodeTo.Units > 0)
nodeTo.Owner = currentPlayer;
break;
case ActionType.ATTACK_NODE_WITH_HALF:
Debug.Log("Attacking hostile units with half from " + nodeTo.id + " to " + nodeFrom.id);
break;
case ActionType.ATTACK_NODE_WITH_ALL:
Debug.Log("Attacking hostile units with all from " + nodeTo.id + " to " + nodeFrom.id);
break;
case ActionType.ATTACK_CON_WITH_HALF:
Debug.Log("Attacking hostile construction with half from " + nodeTo.id + " to " + nodeFrom.id);
break;
case ActionType.ATTACK_CON_WITH_ALL:
Debug.Log("Attacking hostile construction with all from " + nodeTo.id + " to " + nodeFrom.id);
break;
case ActionType.CONSTRUCT_CON:
Debug.Log("Starting construction from " + nodeTo.id + " to " + nodeFrom.id);
con.state = Connection.BuildState.CONSTRUCTING;
con.constructingPlayerId = action.player;
break;
case ActionType.DESTRUCT_CON:
if (!hostile)
{
if (p.energy < 1)
{
Debug.Log("Not enough energy");
return;
}
p.energy -= 1;
Debug.Log("Starten deconstruction from " + nodeTo.id + " to " + nodeFrom.id);
con.state = Connection.BuildState.DECONSTRUCTING;
}
else
{
Debug.Log("This should not be possible O_o");
}
return;
con.constructingPlayerId = action.player;
break;
case ActionType.EXPLODE_CON:
if (p.energy < 2)
@ -235,7 +462,7 @@ public class GameManager : MonoBehaviour
p.energy -= 2;
Debug.Log("Exploding connection from " + nodeTo.id + " to " + nodeFrom.id);
con.state = Connection.BuildState.EMPTY;
return;
break;
}
}
public void GenerateAlongSphere()
@ -328,8 +555,11 @@ public class GameManager : MonoBehaviour
var nodeData = levels[index].nodes[i];
var auto = PrefabUtility.InstantiatePrefab(NodePrefab, NodeParent) as GameObject;
auto.transform.localPosition = nodeData.position;
auto.GetComponent<Node>().Owner = nodeData.owner;
auto.GetComponent<Node>().id = i;
Node node = auto.GetComponent<Node>();
node.Owner = nodeData.owner;
node.Units = nodeData.units;
node.id = i;
}
var currentNodes = GetNodes();
@ -342,10 +572,8 @@ public class GameManager : MonoBehaviour
foreach (LevelData.ConnectionData conData in levels[index].connections)
{
AddConnection(currentNodes[conData.nodeAIndex], currentNodes[conData.nodeBIndex], conData.allowed);
Debug.Log(conData.nodeAIndex + " - " + conData.nodeBIndex);
}
selectedLevel = index;
minConnectionLength = levels[index].minConnectionLength;
maxConnectionLength = levels[index].maxConnectionLength;
@ -365,7 +593,8 @@ public class GameManager : MonoBehaviour
data.nodes.Add(new LevelData.NodeData
{
position = node.transform.localPosition,
owner = node.Owner
owner = node.Owner,
units = node.Units
});
}

View file

@ -76,7 +76,7 @@ public class Node : MonoBehaviour
public void UpdateTransform()
{
transform.localPosition = transform.localPosition.normalized * 20f;
transform.localPosition = transform.localPosition.normalized * 21f;
if (transform.position != Vector3.zero)
transform.forward = transform.position;
}
@ -95,7 +95,7 @@ public class Node : MonoBehaviour
else
material = materialOwnerOther;
transform.GetChild(0).GetComponent<Renderer>().sharedMaterial = material;
transform.GetComponent<Renderer>().sharedMaterial = material;
hovered = false;
}

View file

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class Player
{
/** Possible Moves:

File diff suppressed because one or more lines are too long