From 2549b580d78135daa2b9e4d76dee28755b6141a9 Mon Sep 17 00:00:00 2001 From: amm266 Date: Thu, 29 Apr 2021 14:03:33 +0430 Subject: [PATCH] add phase 2 cells --- Assets/Prefabs/Ant.prefab | 3 + Assets/Prefabs/base1.prefab | 2 +- Assets/Prefabs/base2.prefab | 2 +- Assets/Scenes/MapScene.unity | 330 ++++++- Assets/Scripts/ChatManager.cs | 3 +- Assets/Scripts/LogScripts/GameLogReader.cs | 52 +- Assets/Scripts/LogScripts/Map.cs | 9 +- .../Scripts/LogScripts/dto/GameConfigDTO.cs | 2 + Assets/Scripts/Map/GameManager.cs | 135 ++- Assets/Scripts/MapMaker/CellTypeMake.cs | 18 + Assets/Scripts/MapMaker/CellTypeMakeJson.cs | 6 + Assets/Scripts/MoveCamera.cs | 17 +- Assets/Scripts/PrefabScripts/AntScript.cs | 25 +- Assets/Scripts/PrefabScripts/BaseScript.cs | 3 - Assets/Scripts/SoundManager.cs | 2 +- Assets/Scripts/UIManager.cs | 6 +- .../Sample/CanvasSampleOpenFileText.cs | 7 +- .../LiberationSans SDF - Fallback.asset | 816 +++++++++++++++++- ProjectSettings/Physics2DSettings.asset | 10 +- ProjectSettings/ProjectSettings.asset | 12 +- ProjectSettings/UnityConnectSettings.asset | 1 + 21 files changed, 1345 insertions(+), 116 deletions(-) diff --git a/Assets/Prefabs/Ant.prefab b/Assets/Prefabs/Ant.prefab index cb8d3d3..33abc13 100644 --- a/Assets/Prefabs/Ant.prefab +++ b/Assets/Prefabs/Ant.prefab @@ -177,6 +177,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7c59769e94014ac58bf0c69cadd0e2ba, type: 3} m_Name: m_EditorClassIdentifier: + MaxDis: 0.09 fighterScaleCorrection: 0.3 redFighterColorCorrection: {r: 1, g: 0.7311321, b: 0.7311321, a: 1} resource1: {fileID: 21300000, guid: 816584c73fb76d149a9a1cbcbbe6fa33, type: 3} @@ -190,6 +191,8 @@ MonoBehaviour: blackWorkerAnimator: {fileID: 9100000, guid: 2c997a4853413a847a008b75e686e58b, type: 2} blackFighterAnimator: {fileID: 9100000, guid: d5014774637179e45838c923fcbc0549, type: 2} Poison: {fileID: 8829472896410337160, guid: 28457cf08a4171746b914f6a678aae91, type: 3} + turnNumber: 1 + turnOrder: 1 --- !u!95 &889715941100147975 Animator: serializedVersion: 3 diff --git a/Assets/Prefabs/base1.prefab b/Assets/Prefabs/base1.prefab index 128315e..c9580b5 100644 --- a/Assets/Prefabs/base1.prefab +++ b/Assets/Prefabs/base1.prefab @@ -26,7 +26,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 6046186819930365855} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.48, y: 0, z: 0} + m_LocalPosition: {x: 30, y: -30, z: 1} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 7531302611914159803} diff --git a/Assets/Prefabs/base2.prefab b/Assets/Prefabs/base2.prefab index fca431e..140f959 100644 --- a/Assets/Prefabs/base2.prefab +++ b/Assets/Prefabs/base2.prefab @@ -108,7 +108,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 6046186819930365855} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.48, y: 0, z: 0} + m_LocalPosition: {x: 8, y: -8, z: 1} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 2345218041912017139} diff --git a/Assets/Scenes/MapScene.unity b/Assets/Scenes/MapScene.unity index ecfe42f..385127d 100644 --- a/Assets/Scenes/MapScene.unity +++ b/Assets/Scenes/MapScene.unity @@ -267,6 +267,137 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &141955309 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 141955310} + - component: {fileID: 141955313} + - component: {fileID: 141955312} + - component: {fileID: 141955311} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &141955310 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 141955309} + m_LocalRotation: {x: -0, y: -0, z: 0.36704317, w: 0.9302039} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.042127065, y: 0.042127065, z: 0.042127065} + m_Children: [] + m_Father: {fileID: 1654332462} + m_RootOrder: 18 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 43.067} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -272, y: 291} + m_SizeDelta: {x: 2048, y: 430} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &141955311 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 141955309} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.18431373} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 141955312} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1778195490} + m_TargetAssemblyTypeName: GameManager, Assembly-CSharp + m_MethodName: ApplyRuler + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &141955312 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 141955309} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.4339623, g: 0.4339623, b: 0.4339623, a: 0.78431374} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: ce7f65bb034e5984f9d13a73df925326, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &141955313 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 141955309} + m_CullTransparentMesh: 0 --- !u!1 &181119229 GameObject: m_ObjectHideFlags: 0 @@ -568,6 +699,18 @@ PrefabInstance: propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target value: objectReference: {fileID: 1778195490} + - target: {fileID: 123243331, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.r + value: 0.6320754 + objectReference: {fileID: 0} + - target: {fileID: 123243331, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.g + value: 0.25740176 + objectReference: {fileID: 0} + - target: {fileID: 123243331, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.b + value: 0.19975968 + objectReference: {fileID: 0} - target: {fileID: 201270614, guid: c96875b7a845a7143be803fea0004d49, type: 3} propertyPath: Mute value: 1 @@ -612,6 +755,18 @@ PrefabInstance: propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target value: objectReference: {fileID: 1778195490} + - target: {fileID: 1331234045, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.r + value: 0.31132078 + objectReference: {fileID: 0} + - target: {fileID: 1331234045, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.g + value: 0.31132078 + objectReference: {fileID: 0} + - target: {fileID: 1331234045, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.b + value: 0.31132078 + objectReference: {fileID: 0} - target: {fileID: 1503478381, guid: c96875b7a845a7143be803fea0004d49, type: 3} propertyPath: m_IsActive value: 1 @@ -632,6 +787,22 @@ PrefabInstance: propertyPath: m_ChildControlHeight value: 1 objectReference: {fileID: 0} + - target: {fileID: 1442727032139227121, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: 9f0d160b5a59e0f4ebc5414ce714be9f, type: 3} + - target: {fileID: 1442727032139227121, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.r + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1442727032139227121, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.g + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1442727032139227121, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.b + value: 1 + objectReference: {fileID: 0} - target: {fileID: 2495248660206519639, guid: c96875b7a845a7143be803fea0004d49, type: 3} propertyPath: m_RootOrder value: 0 @@ -680,10 +851,114 @@ PrefabInstance: propertyPath: m_Name value: UI objectReference: {fileID: 0} + - target: {fileID: 3328529740212703412, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: -2063937709773383588, guid: e16a3ae99fa021f49855e2fb535ab38a, type: 3} + - target: {fileID: 5350529613320527290, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: e420c4890a17c3c44aff5fd0f087f54d, type: 3} + - target: {fileID: 5350529613320527290, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.r + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 5350529613320527290, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.g + value: 0.7311321 + objectReference: {fileID: 0} + - target: {fileID: 5350529613320527290, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.b + value: 0.7311321 + objectReference: {fileID: 0} + - target: {fileID: 5350529613320527290, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.a + value: 0.5882353 + objectReference: {fileID: 0} + - target: {fileID: 6091547920659155532, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7758860864282635682, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: -9014201358933764301, guid: f49bb474e34ba5c40a2c0d9ba13515f2, type: 3} + - target: {fileID: 8402233282379174966, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8563142315059366136, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.r + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8563142315059366136, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.g + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8563142315059366136, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.b + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8563142315059366136, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: c3bcb22b241edbd47871419487cf5d82, type: 3} + - target: {fileID: 8674794667833382429, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: MessageHeight + value: 40 + objectReference: {fileID: 0} + - target: {fileID: 8674794667833382882, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: BaseTime + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 8674794668642842210, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Sprite + value: + objectReference: {fileID: 21300000, guid: dacfd2cec77ec624e818f8bf829307aa, type: 3} + - target: {fileID: 8674794668642842210, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.r + value: 0.8018868 + objectReference: {fileID: 0} + - target: {fileID: 8674794668642842210, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.g + value: 0.28838584 + objectReference: {fileID: 0} + - target: {fileID: 8674794668642842210, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_Color.b + value: 0.13995194 + objectReference: {fileID: 0} + - target: {fileID: 8674794668803218732, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8674794668803218733, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_AnchoredPosition.y + value: -211.8582 + objectReference: {fileID: 0} + - target: {fileID: 8674794668803218733, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_SizeDelta.y + value: 389.68405 + objectReference: {fileID: 0} - target: {fileID: 8674794668803218738, guid: c96875b7a845a7143be803fea0004d49, type: 3} propertyPath: m_ChildControlHeight value: 1 objectReference: {fileID: 0} + - target: {fileID: 8674794668803218738, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_ChildForceExpandHeight + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8674794668803218738, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_ChildControlWidth + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8674794668930599124, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8674794668930599124, guid: c96875b7a845a7143be803fea0004d49, type: 3} + propertyPath: m_SizeDelta.y + value: 10.371826 + objectReference: {fileID: 0} - target: {fileID: 8674794669486866726, guid: c96875b7a845a7143be803fea0004d49, type: 3} propertyPath: m_Camera value: @@ -859,7 +1134,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &1003224826 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1236,36 +1511,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1589346448 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1589346449} - m_Layer: 0 - m_Name: GameObject - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1589346449 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1589346448} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 90} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1616522161 GameObject: m_ObjectHideFlags: 0 @@ -1452,11 +1697,14 @@ MonoBehaviour: m_EditorClassIdentifier: InGame: {fileID: 2069621862} GameLogBrowser: {fileID: 1003224825} + ruler: {fileID: 141955309} winnerPanel: {fileID: 181119229} winnerText: {fileID: 403204785} antPrefab: {fileID: 4492105072940884455, guid: 8d0458e01e56e614fb48d9a31922334d, type: 3} cell_empty: {fileID: 2414748525179884939, guid: 3fb5f3165b9b0f74caa7b42352f2245f, type: 3} cell_wall: {fileID: 4228955896558502353, guid: 2e1bde7b6afb8c74cb3fc069c88ca4f8, type: 3} + cell_glue: {fileID: 7121964513574248496, guid: 6b023c5f8e4eb5b4d8af72fac2b5389e, type: 3} + cell_mud: {fileID: 6165810634924145825, guid: c02730663605f0d47bbfb7bd715bef3d, type: 3} base1: {fileID: 6046186819930365855, guid: 34b0881bc07351d4891aa0b20e93e147, type: 3} base2: {fileID: 6046186819930365855, guid: 846995bd625d60944925a487cc65d285, type: 3} rec1: {fileID: 2731621424195638712, guid: baffc5f510ab1bf438d81882e49b2dd7, type: 3} @@ -1465,16 +1713,16 @@ MonoBehaviour: y0: 0 width: 2 haight: 2 - team0_alive_workers: {fileID: 1322188073} - team0_alive_soldiers: {fileID: 116368892} - team0_total_resource0: {fileID: 464039737} - team0_total_resource1: {fileID: 1276014728} - team1_alive_workers: {fileID: 2140981958} - team1_alive_soldiers: {fileID: 310499132} - team1_total_resource0: {fileID: 1222337744} - team1_total_resource1: {fileID: 286255581} - team0_name: {fileID: 1380460256} - team1_name: {fileID: 1246264933} + team0_alive_workers: {fileID: 2140981958} + team0_alive_soldiers: {fileID: 310499132} + team0_total_resource0: {fileID: 1222337744} + team0_total_resource1: {fileID: 286255581} + team1_alive_workers: {fileID: 1322188073} + team1_alive_soldiers: {fileID: 116368892} + team1_total_resource0: {fileID: 464039737} + team1_total_resource1: {fileID: 1276014728} + team0_name: {fileID: 1246264933} + team1_name: {fileID: 1380460256} RightStats: {fileID: 1539077790} LeftStats: {fileID: 1307909027} --- !u!4 &1778195491 diff --git a/Assets/Scripts/ChatManager.cs b/Assets/Scripts/ChatManager.cs index daf40c8..cfc2353 100644 --- a/Assets/Scripts/ChatManager.cs +++ b/Assets/Scripts/ChatManager.cs @@ -14,7 +14,6 @@ public class ChatManager : MonoBehaviour [SerializeField] private TextMeshProUGUI TextPrefab; [SerializeField] private VerticalLayoutGroup PanelRight; [SerializeField] private VerticalLayoutGroup PanelLeft; - private void Awake() { Instance = this; @@ -70,7 +69,7 @@ public void SetChatMessages(Chat[] importantMessages, Chat[] trivialMessages, Ve int trivialMessagesCount = trivialMessages.Length; int total = importantMessagesCount + trivialMessagesCount; int i; - Panel.spacing = total; + // Panel.spacing = total; RectTransform rectTransform = Panel.gameObject.GetComponent(); rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, total * MessageHeight); rectTransform.Translate(0,-100,0); diff --git a/Assets/Scripts/LogScripts/GameLogReader.cs b/Assets/Scripts/LogScripts/GameLogReader.cs index 0f4c7e0..1d545f1 100644 --- a/Assets/Scripts/LogScripts/GameLogReader.cs +++ b/Assets/Scripts/LogScripts/GameLogReader.cs @@ -3,18 +3,67 @@ using System.Collections.Generic; using UnityEngine; using System.IO; +using System.Runtime.InteropServices; using TMPro; +using UnityEngine.EventSystems; using UnityEngine.Networking; public class GameLogReader : MonoBehaviour { + private string json; + + [DllImport("__Internal")] + private static extern void UploadFile(string gameObjectName, string methodName, string filter, bool multiple); + + public void OnPointerDown(PointerEventData eventData) + { + UploadFile(gameObject.name, "OnFileUpload", ".txt", false); + Debug.Log("u"); + } + + // Called from browser + public void OnFileUpload(string url) + { + Debug.Log(url); + + StartCoroutine(OutputRoutine(url)); + } + + private IEnumerator OutputRoutine(string url) + { + var loader = new WWW(url); + Debug.Log(url); + Debug.Log(Application.dataPath); + yield return loader; + GameLogReader.Instance.MakeLog(loader.text); + } + public static GameLogReader Instance; + private void Awake() { Instance = this; + // StartCoroutine(OutputRoutine(new System.Uri( Application.dataPath+"/log1.json").AbsoluteUri)); + // ReadLog("/log1.json"); + } + + public void ReadLog(string filePath) + { + StartCoroutine(OutputRoutine(new System.Uri(Application.dataPath + "/" + filePath).AbsoluteUri)); } + public void MakePartLog(string partJson) + { + json += partJson; + } + + public void MakeLogStart() + { + MakeLog(json); + } + + public GameLog GameLog { get; private set; } public void MakeLog(string jsonStr) @@ -42,7 +91,8 @@ public void MakeLog(string jsonStr) } Map map = new Map(cells, gameConfigDTO.base_health, gameConfigDTO.worker_health, - gameConfigDTO.soldier_health, gameConfigDTO.team0_name, gameConfigDTO.team1_name,gameConfigDTO.winner); + gameConfigDTO.soldier_health, gameConfigDTO.team0_name, gameConfigDTO.team1_name, gameConfigDTO.winner, + gameConfigDTO.shift_x, gameConfigDTO.shift_y); //making turns Turn[] turns = new Turn[gameDTO.turns.Length]; diff --git a/Assets/Scripts/LogScripts/Map.cs b/Assets/Scripts/LogScripts/Map.cs index 1bc957e..a62286b 100644 --- a/Assets/Scripts/LogScripts/Map.cs +++ b/Assets/Scripts/LogScripts/Map.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; -public class Map +public class Map { public int[][] cells { get; } // base0 --> 0, base1 --> 1, empty --> 2, wall --> 3 public int BaseHealth { get; set; } @@ -12,8 +12,11 @@ public class Map public string Team0Name { get; set; } public string Team1Name { get; set; } public int WinnerTeam { get; set; } + public int ShiftX { get; set; } + public int ShiftY { get; set; } - public Map(int[][] cells, int baseHealth, int workerHealth, int soldierHealth, string team0Name, string team1Name, int winnerTeam) + public Map(int[][] cells, int baseHealth, int workerHealth, int soldierHealth, string team0Name, string team1Name, + int winnerTeam,int shiftX,int shiftY) { this.cells = cells; this.BaseHealth = baseHealth; @@ -22,5 +25,7 @@ public Map(int[][] cells, int baseHealth, int workerHealth, int soldierHealth, s this.Team0Name = team0Name; this.Team1Name = team1Name; this.WinnerTeam = winnerTeam; + this.ShiftX = shiftX; + this.ShiftY = shiftY; } } \ No newline at end of file diff --git a/Assets/Scripts/LogScripts/dto/GameConfigDTO.cs b/Assets/Scripts/LogScripts/dto/GameConfigDTO.cs index ec46572..6fe4574 100644 --- a/Assets/Scripts/LogScripts/dto/GameConfigDTO.cs +++ b/Assets/Scripts/LogScripts/dto/GameConfigDTO.cs @@ -10,4 +10,6 @@ public class GameConfigDTO public string team0_name; public string team1_name; public int winner; + public int shift_x; + public int shift_y; } diff --git a/Assets/Scripts/Map/GameManager.cs b/Assets/Scripts/Map/GameManager.cs index 00b563b..8207408 100644 --- a/Assets/Scripts/Map/GameManager.cs +++ b/Assets/Scripts/Map/GameManager.cs @@ -4,22 +4,32 @@ using TMPro; using UnityEngine; using UnityEngine.SceneManagement; +using UnityEngine.UI; using Object = System.Object; public class GameManager : MonoBehaviour { public GameObject InGame; public GameObject GameLogBrowser; + private int shift_x; + private int shift_y; + [SerializeField] private GameObject ruler; + private bool isRuler = true; + private bool skipAnim = false; [SerializeField] private GameObject winnerPanel; [SerializeField] private TextMeshProUGUI winnerText; [SerializeField] private GameObject antPrefab; [SerializeField] private GameObject cell_empty; [SerializeField] private GameObject cell_wall; + [SerializeField] private GameObject cell_glue; + [SerializeField] private GameObject cell_mud; [SerializeField] private GameObject base1; [SerializeField] private GameObject base2; [SerializeField] private GameObject rec1; [SerializeField] private GameObject rec2; private GameLog gameLog; + private int mapWidth; + private int mapHeight; private int currTurn; public int x0; public int y0; @@ -47,23 +57,29 @@ public class GameManager : MonoBehaviour private void Awake() { + Application.targetFrameRate = 50; Instance = this; } public void StartGameManager(GameLog gameLog) { + shift_x = gameLog.Map.ShiftX; + shift_y = gameLog.Map.ShiftY; GameLogBrowser.SetActive(false); InGame.SetActive(true); - + mapHeight = gameLog.Map.cells.Length; + mapWidth = gameLog.Map.cells[0].Length; winnerPanel.SetActive(false); baseTime = UIManager.Instance.BaseTime; this.gameLog = gameLog; base1.GetComponent().SetMaxHealth(gameLog.Map.BaseHealth); base2.GetComponent().SetMaxHealth(gameLog.Map.BaseHealth); + base1 = InstansiateCell(base1, 0, 0); + base2 = InstansiateCell(base2, 0, 0); ShowMap(); FindObjectOfType().setMaid(gameLog.Map.cells.Length * width, gameLog.Map.cells[0].Length * haight); MaxTurns = gameLog.Turns.Length; - if (gameLog.Map.WinnerTeam==0) + if (gameLog.Map.WinnerTeam == 0) { winnerText.text = gameLog.Map.Team0Name; } @@ -78,13 +94,21 @@ public void ApplyLog(int turn, bool isAnim) Debug.Log(currTurn + " " + turn); if (currTurn == turn - 1 && isAnim) { - playAnime = true; - StartCoroutine(ApplyTurnAnim(gameLog.Turns[turn - 1],turn == MaxTurns)); + if (skipAnim) + { + ApplyTurnUnAnim(gameLog.Turns[turn - 1], turn == MaxTurns); + skipAnim = false; + } + else + { + playAnime = true; + StartCoroutine(ApplyTurnAnim(gameLog.Turns[turn - 1], turn == MaxTurns)); + } } else { playAnime = false; - ApplyTurnUnAnim(gameLog.Turns[turn - 1],turn == MaxTurns); + ApplyTurnUnAnim(gameLog.Turns[turn - 1], turn == MaxTurns); } currTurn = turn; @@ -109,6 +133,8 @@ private void ApplyTurnUnAnim(Turn turn, bool lastTurn) Destroy(temp); } + ShowMap(); + base1.GetComponent().setHealth(turn.Base0Health); base2.GetComponent().setHealth(turn.Base1Health); ApplyResources(turn.Resources0, rec1); @@ -140,7 +166,7 @@ private void ApplyTurnUnAnim(Turn turn, bool lastTurn) } } - private IEnumerator ApplyTurnAnim(Turn turn,bool lastTurn) + private IEnumerator ApplyTurnAnim(Turn turn, bool lastTurn) { team0_alive_workers.text = turn.team0_alive_workers.ToString(); team0_alive_soldiers.text = turn.team0_alive_soldiers.ToString(); @@ -159,10 +185,10 @@ private IEnumerator ApplyTurnAnim(Turn turn,bool lastTurn) Destroy(temp); } + ShowMap(); + base1.GetComponent().setHealth(turn.Base0Health); base2.GetComponent().setHealth(turn.Base1Health); - ApplyResources(turn.Resources0, rec1); - ApplyResources(turn.Resources1, rec2); Hashtable cloneAntTable = (Hashtable) AntsTable.Clone(); Hashtable MovingAnts = new Hashtable(); Hashtable NewAnts = new Hashtable(); @@ -213,18 +239,25 @@ private IEnumerator ApplyTurnAnim(Turn turn,bool lastTurn) if (attack.AttackerId == -1) { base1.GetComponent().Attack(attack.SrcRow, attack.SrcCol, attack.DstRow, attack.DstCol, - baseTime / 2); + baseTime / 3); } if (attack.AttackerId == -2) { - base1.GetComponent().Attack(attack.SrcRow, attack.SrcCol, attack.DstRow, attack.DstCol, - baseTime / 2); + base2.GetComponent().Attack(attack.SrcRow, attack.SrcCol, attack.DstRow, attack.DstCol, + baseTime / 3); } else { GameObject attacker = (GameObject) AntsTable[attack.AttackerId]; - attacker.GetComponent().Attack(attack.DstRow, attack.DstCol, baseTime / 2); + try + { + attacker.GetComponent().Attack(attack.DstRow, attack.DstCol, baseTime / 3); + } + catch (Exception e) + { + Debug.Log(attack.AttackerId + " " + attack.DefenderId); + } } } @@ -236,9 +269,12 @@ private IEnumerator ApplyTurnAnim(Turn turn,bool lastTurn) StartCoroutine(antScript.GetComponent().die(baseTime / 4, baseTime / 4)); } - + // Debug.Log("end phase1"); - yield return new WaitForSecondsRealtime((baseTime / 2) * UIManager.Instance.Speed); + ApplyResources(turn.Resources0, rec1); + ApplyResources(turn.Resources1, rec2); + yield return new WaitForSecondsRealtime((baseTime / 3) * UIManager.Instance.Speed); + // yield return null; if (lastTurn) { winnerPanel.SetActive(true); @@ -247,8 +283,10 @@ private IEnumerator ApplyTurnAnim(Turn turn,bool lastTurn) { winnerPanel.SetActive(false); } + if (playAnime) { + Debug.Log("move ant"); //move ants time // Debug.Log("start phase2"); foreach (DictionaryEntry antDE in MovingAnts) @@ -259,7 +297,7 @@ private IEnumerator ApplyTurnAnim(Turn turn,bool lastTurn) int n = turn.CellAnts[ant.Row][ant.Col].IndexOf(ant.Id) + 1; GameObject antScript = (GameObject) antDE.Key; StartCoroutine(antScript.GetComponent() - .Go(ant.Row, ant.Col, ant.Health, ant.Resource, baseTime / 2, numbers, n)); + .Go(ant.Row, ant.Col, ant.Health, ant.Resource, baseTime*2 / 3, numbers, n)); } // Debug.Log("end phase2"); @@ -294,16 +332,38 @@ private void ShowMap() switch (gameLog.Map.cells[i][j]) { case 2: - InstansiateCell(cell_empty, i, j); + Temps.Add(InstansiateCell(cell_empty, i, j)); break; case 3: - InstansiateCell(cell_wall, i, j); + Temps.Add(InstansiateCell(cell_wall, i, j)); + break; + case 4: + Temps.Add(InstansiateCell(cell_glue, i, j)); + break; + case 5: + Temps.Add(InstansiateCell(cell_mud, i, j)); break; case 0: - base1 = InstansiateCell(base1, i, j); + if (base1 == null) + { + base1 = InstansiateCell(base1, i, j); + } + else + { + base1.transform.position = ConvertPosition(i, j); + } + break; case 1: - base2 = InstansiateCell(base2, i, j); + if (base2 == null) + { + base2 = InstansiateCell(base2, i, j); + } + else + { + base2.transform.position = ConvertPosition(i, j); + } + break; } } @@ -319,16 +379,23 @@ private GameObject InstansiateCell(GameObject instance, int i, int j) public Vector3 ConvertPosition(int x, int y) { - return new Vector3(x0 + x * width, y0 - y * haight, 1); + if (isRuler) + { + return new Vector3(x0 + ((x + shift_x) % mapHeight) * width, y0 - ((y + shift_y) % mapWidth) * haight, 1); + } + else + { + return new Vector3(x0 + ((x) % mapHeight) * width, y0 - ((y) % mapWidth) * haight, 1); + } } public void Close() { - #if UNITY_EDITOR - UnityEditor.EditorApplication.isPlaying = false; - #else +#if UNITY_EDITOR + UnityEditor.EditorApplication.isPlaying = false; +#else Application.Quit(); - #endif +#endif } public void Return() @@ -340,9 +407,27 @@ public void RightStatsClicked() { RightStats.SetActive(!RightStats.activeSelf); } + public void LeftStatsClicked() { LeftStats.SetActive(!LeftStats.activeSelf); } - + + public void ApplyRuler() + { + if (isRuler) + { + skipAnim = true; + isRuler = false; + var color = ruler.GetComponent().color; + ruler.GetComponent().color = new Color(color.r,color.g,color.b,50); + } + else + { + skipAnim = true; + isRuler = true; + var color = ruler.GetComponent().color; + color.a = 200; + } + } } \ No newline at end of file diff --git a/Assets/Scripts/MapMaker/CellTypeMake.cs b/Assets/Scripts/MapMaker/CellTypeMake.cs index 02023af..f45f863 100644 --- a/Assets/Scripts/MapMaker/CellTypeMake.cs +++ b/Assets/Scripts/MapMaker/CellTypeMake.cs @@ -41,6 +41,24 @@ int rec2 this.rec1 = rec1; this.rec2 = rec2; transform.position = new Vector3(col * 2, -row * 2, 1); + switch (cell_type) + { + case 0: + Sprite.sprite = base1; + break; + case 1: + Sprite.sprite = base2; + break; + case 2: + Sprite.sprite = empty; + break; + case 3: + Sprite.sprite = wall; + break; + } + + res1Text.text = rec1.ToString(); + res2Text.text = rec2.ToString(); } public void OnClick() diff --git a/Assets/Scripts/MapMaker/CellTypeMakeJson.cs b/Assets/Scripts/MapMaker/CellTypeMakeJson.cs index cda1d17..3fab770 100644 --- a/Assets/Scripts/MapMaker/CellTypeMakeJson.cs +++ b/Assets/Scripts/MapMaker/CellTypeMakeJson.cs @@ -24,4 +24,10 @@ int rec2 this.rec1 = rec1; this.rec2 = rec2; } + + public override bool Equals(object obj) + { + CellTypeMakeJson ce = (CellTypeMakeJson) obj; + return this.row == ce.row && this.col == ce.col; + } } \ No newline at end of file diff --git a/Assets/Scripts/MoveCamera.cs b/Assets/Scripts/MoveCamera.cs index 05f7096..5ecf4ea 100644 --- a/Assets/Scripts/MoveCamera.cs +++ b/Assets/Scripts/MoveCamera.cs @@ -24,6 +24,8 @@ public void setMaid(int maxX, int maxY) void Update() { + float deltatime; + deltatime = Time.fixedDeltaTime; lastZoom = myCamera.orthographicSize; if (Input.GetAxis("Mouse ScrollWheel") < 0) { @@ -45,28 +47,28 @@ void Update() if (Input.GetAxis("Vertical") < 0) { pos = Vector3.up; - move = new Vector3(-pos.x * ArrowMoveSpeed * Time.deltaTime, -pos.y * ArrowMoveSpeed * Time.deltaTime, 0); + move = new Vector3(-pos.x * ArrowMoveSpeed * deltatime, -pos.y * ArrowMoveSpeed * deltatime, 0); MovingCamera(move); } if (Input.GetAxis("Vertical") > 0) { pos = Vector3.down; - move = new Vector3(-pos.x * ArrowMoveSpeed * Time.deltaTime, -pos.y * ArrowMoveSpeed * Time.deltaTime, 0); + move = new Vector3(-pos.x * ArrowMoveSpeed * deltatime, -pos.y * ArrowMoveSpeed * deltatime, 0); MovingCamera(move); } if (Input.GetAxis("Horizontal") < 0) { pos = Vector3.right; - move = new Vector3(-pos.x * ArrowMoveSpeed * Time.deltaTime, -pos.y * ArrowMoveSpeed * Time.deltaTime, 0); + move = new Vector3(-pos.x * ArrowMoveSpeed * deltatime, -pos.y * ArrowMoveSpeed * deltatime, 0); MovingCamera(move); } if (Input.GetAxis("Horizontal") > 0) { pos = Vector3.left; - move = new Vector3(-pos.x * ArrowMoveSpeed * Time.deltaTime, -pos.y * ArrowMoveSpeed * Time.deltaTime, 0); + move = new Vector3(-pos.x * ArrowMoveSpeed * deltatime, -pos.y * ArrowMoveSpeed * deltatime, 0); MovingCamera(move); } @@ -79,7 +81,7 @@ void Update() if (!Input.GetMouseButton(0)) return; pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin); - move = new Vector3(-pos.x * dragSpeed * Time.deltaTime, -pos.y * dragSpeed * Time.deltaTime, 0); + move = new Vector3(-pos.x * dragSpeed * deltatime, -pos.y * dragSpeed * deltatime, 0); MovingCamera(move); } @@ -88,11 +90,12 @@ private void MovingCamera(Vector3 move) { if (crossCameraSize) { - transform.Translate(move * myCamera.orthographicSize, Space.World); + // transform.Translate(move * myCamera.orthographicSize, Space.World); + transform.position += move; } else { - transform.Translate(move, Space.World); + transform.position += move; } } diff --git a/Assets/Scripts/PrefabScripts/AntScript.cs b/Assets/Scripts/PrefabScripts/AntScript.cs index 3105193..40aa55b 100644 --- a/Assets/Scripts/PrefabScripts/AntScript.cs +++ b/Assets/Scripts/PrefabScripts/AntScript.cs @@ -7,6 +7,7 @@ public class AntScript : MonoBehaviour { + [SerializeField] private float MaxDis; [SerializeField] private float fighterScaleCorrection; [SerializeField] private Color redFighterColorCorrection; [SerializeField] private Sprite resource1; @@ -36,7 +37,9 @@ public class AntScript : MonoBehaviour private float reachTime; private Animator mainAnimator; private Vector3 baseScale; - + [SerializeField] private int turnNumber; + [SerializeField] private int turnOrder; + private int turnI = 0; private void Awake() { @@ -111,7 +114,7 @@ public IEnumerator Go(int x, int y, int health, int recource, float time, int nu yield return null; } - private void Update() + private void LateUpdate() { if (readTemp) { @@ -123,8 +126,24 @@ private void Update() } else { + if (reachTime - Time.time < 0 ) + { + Debug.Log("error "+id+" "+reachTime+" "+Time.time); + } + + float deltaTime = reachTime - Time.time; + if (deltaTime < 0) + { + deltaTime = 0.0001f; + } + float maxDistanceDelta; + maxDistanceDelta = (d / deltaTime) * Time.deltaTime * turnOrder/turnNumber; + Debug.Log("id: " + id + "current: " + transform.position + " goal: " + temp + " delta " + d + + " max dis: " + maxDistanceDelta); + maxDistanceDelta = Mathf.Min(MaxDis, maxDistanceDelta); + Debug.Log("id: "+id+" max dis: "+maxDistanceDelta); transform.position = Vector3.MoveTowards(transform.position, temp, - (d / (reachTime - Time.time)) * Time.deltaTime); + maxDistanceDelta); Vector3 dir = temp - transform.position; LookTo(dir); } diff --git a/Assets/Scripts/PrefabScripts/BaseScript.cs b/Assets/Scripts/PrefabScripts/BaseScript.cs index 98d9ca0..1840643 100644 --- a/Assets/Scripts/PrefabScripts/BaseScript.cs +++ b/Assets/Scripts/PrefabScripts/BaseScript.cs @@ -28,9 +28,6 @@ public void Attack(int sx, int sy, int tar_x, int tar_y, float time) { GameObject poison = Instantiate(Poison); poison.GetComponent().Fire(sx, sy, tar_x, tar_y, time); - //todo base animation attack - // mainAnimator.Play("Attack"); - // LookTo(GameManager.Instance.ConvertPosition(x, y) - transform.position); } public void SetMaxHealth(int maxHealth) diff --git a/Assets/Scripts/SoundManager.cs b/Assets/Scripts/SoundManager.cs index b1e442a..ca8efbe 100644 --- a/Assets/Scripts/SoundManager.cs +++ b/Assets/Scripts/SoundManager.cs @@ -6,7 +6,7 @@ public class SoundManager : MonoBehaviour { - private bool isMute; + [SerializeField]private bool isMute; private AudioSource _audioSource; [SerializeField] private Image on; [SerializeField] private Image off; diff --git a/Assets/Scripts/UIManager.cs b/Assets/Scripts/UIManager.cs index 6d95f50..bb9ef10 100644 --- a/Assets/Scripts/UIManager.cs +++ b/Assets/Scripts/UIManager.cs @@ -95,19 +95,17 @@ public void OnPreviousTurnButtonClick() public void OnChangeSpeedButtonClicked(float factor) { Speed *= factor; - if (Speed > 4) - Speed = 4; + if (Speed > 2) + Speed = 2; if (Speed < 0.25) Speed = (float) 0.25; if (Time.timeScale > 0) Time.timeScale = Speed; SpeedText.text = Speed.ToString("F2"); - //call function from GameManager } public void OnLeftToggleChatButtonClicked() { - Debug.Log("lc pressed"); LeftChatMessagesCanvas.SetActive(!LeftChatMessagesCanvas.activeSelf); } diff --git a/Assets/StandaloneFileBrowser/Sample/CanvasSampleOpenFileText.cs b/Assets/StandaloneFileBrowser/Sample/CanvasSampleOpenFileText.cs index 180b021..d6ba6c0 100644 --- a/Assets/StandaloneFileBrowser/Sample/CanvasSampleOpenFileText.cs +++ b/Assets/StandaloneFileBrowser/Sample/CanvasSampleOpenFileText.cs @@ -24,6 +24,7 @@ public void OnPointerDown(PointerEventData eventData) { // Called from browser public void OnFileUpload(string url) { + Debug.Log(url); StartCoroutine(OutputRoutine(url)); } #else @@ -34,9 +35,6 @@ public void OnPointerDown(PointerEventData eventData) { } void Start() { - float a = Mathf.Ceil(Mathf.Pow(2, 0.5f)) +1; - Debug.Log(a); - Debug.Log(Mathf.Pow(a,2)); var button = GetComponent