From 07697c1d208ec34d504bf8f919278ae583c08b00 Mon Sep 17 00:00:00 2001 From: Playmaker1210 Date: Tue, 7 Mar 2023 21:06:25 +0100 Subject: [PATCH] new movement --- ...rePack_HDRP_2018.4_v1.22.unitypackage.meta | 7 - ...rePack_LWRP_2018.4_v1.22.unitypackage.meta | 7 - ...urePack_URP_2019.3_v1.22.unitypackage.meta | 7 - Assets/Scenes/EndlessRunnerTest.unity | 380 +++++++++++++++++- Assets/Scripts/CoinCounter.cs | 9 + Assets/Scripts/Network/DatabaseData.cs | 31 +- Assets/Scripts/PlayerController.cs | 94 +++-- Assets/Scripts/SetButtonSize.cs | 21 + Assets/Scripts/SetButtonSize.cs.meta | 11 + Assets/Scripts/fps.cs | 4 +- UserSettings/Layouts/default-2021.dwlt | 148 +++---- 11 files changed, 587 insertions(+), 132 deletions(-) delete mode 100644 Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_HDRP_2018.4_v1.22.unitypackage.meta delete mode 100644 Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_LWRP_2018.4_v1.22.unitypackage.meta delete mode 100644 Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_URP_2019.3_v1.22.unitypackage.meta create mode 100644 Assets/Scripts/SetButtonSize.cs create mode 100644 Assets/Scripts/SetButtonSize.cs.meta diff --git a/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_HDRP_2018.4_v1.22.unitypackage.meta b/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_HDRP_2018.4_v1.22.unitypackage.meta deleted file mode 100644 index 9a23bc2..0000000 --- a/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_HDRP_2018.4_v1.22.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 3b4dc5f685f8edc4bbba6fb0c8ea39ba -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_LWRP_2018.4_v1.22.unitypackage.meta b/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_LWRP_2018.4_v1.22.unitypackage.meta deleted file mode 100644 index 552dc86..0000000 --- a/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_LWRP_2018.4_v1.22.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 8851c5995be5f704babebf752d60b4e2 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_URP_2019.3_v1.22.unitypackage.meta b/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_URP_2019.3_v1.22.unitypackage.meta deleted file mode 100644 index f481ade..0000000 --- a/Assets/Asset Store/SimpleNaturePack/SimpleNaturePack_URP_2019.3_v1.22.unitypackage.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 88c6da05db186cb44a4453fd624b31b2 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scenes/EndlessRunnerTest.unity b/Assets/Scenes/EndlessRunnerTest.unity index 67dc18d..5c723f8 100644 --- a/Assets/Scenes/EndlessRunnerTest.unity +++ b/Assets/Scenes/EndlessRunnerTest.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.56158954, g: 0.7218083, b: 0.8178571, a: 1} + m_IndirectSpecularColor: {r: 0.5615895, g: 0.72180885, b: 0.81785697, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -157,6 +157,127 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} +--- !u!1 &284201298 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 284201299} + - component: {fileID: 284201302} + - component: {fileID: 284201301} + - component: {fileID: 284201300} + m_Layer: 5 + m_Name: Jump + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &284201299 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 284201298} + 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: 871711471} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 12.5, y: -7} + m_SizeDelta: {x: 275, y: 1731.3} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &284201300 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 284201298} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + 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: 0} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 0} + m_PressedColor: {r: 1, g: 1, b: 1, a: 0} + m_SelectedColor: {r: 1, g: 1, b: 1, a: 0} + m_DisabledColor: {r: 1, g: 1, b: 1, a: 0} + 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: 2129484389} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &284201301 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 284201298} + 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: 1, g: 1, b: 1, a: 0} + 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: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + 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 &284201302 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 284201298} + m_CullTransparentMesh: 1 --- !u!1 &481417097 GameObject: m_ObjectHideFlags: 0 @@ -281,6 +402,9 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1572233530} + - {fileID: 2129484387} + - {fileID: 284201299} + - {fileID: 2069815690} m_Father: {fileID: 0} m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -425,8 +549,12 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: rb: {fileID: 7917514869596290073} - jumpforce: 350 - holdTime: 0.15 + jumpforce: 10 + holdTime: 0.2 + activeControllType: 0 + leftButton: {fileID: 2129484388} + jumpButton: {fileID: 284201300} + rightButton: {fileID: 2069815691} --- !u!114 &1201779185 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1174,6 +1302,248 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &2069815689 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2069815690} + - component: {fileID: 2069815693} + - component: {fileID: 2069815692} + - component: {fileID: 2069815691} + m_Layer: 5 + m_Name: GoRight + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2069815690 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2069815689} + 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: 871711471} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 275, y: 0.0089758} + m_SizeDelta: {x: 250, y: 1731.3} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2069815691 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2069815689} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + 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: 0} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 0} + m_PressedColor: {r: 1, g: 1, b: 1, a: 0} + m_SelectedColor: {r: 1, g: 1, b: 1, a: 0} + m_DisabledColor: {r: 1, g: 1, b: 1, a: 0} + 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: 2129484389} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &2069815692 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2069815689} + 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: 1, g: 1, b: 1, a: 0} + 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: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + 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 &2069815693 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2069815689} + m_CullTransparentMesh: 1 +--- !u!1 &2129484386 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2129484387} + - component: {fileID: 2129484390} + - component: {fileID: 2129484389} + - component: {fileID: 2129484388} + m_Layer: 5 + m_Name: GoLeft + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2129484387 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2129484386} + 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: 871711471} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -262.5, y: -0.0089696} + m_SizeDelta: {x: 275, y: 1731.3} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2129484388 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2129484386} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + 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: 0} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 0} + m_PressedColor: {r: 1, g: 1, b: 1, a: 0} + m_SelectedColor: {r: 1, g: 1, b: 1, a: 0} + m_DisabledColor: {r: 1, g: 1, b: 1, a: 0} + 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: 2129484389} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &2129484389 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2129484386} + 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: 1, g: 1, b: 1, a: 0} + 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: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + 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 &2129484390 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2129484386} + m_CullTransparentMesh: 1 --- !u!1 &30613582022879756 GameObject: m_ObjectHideFlags: 0 @@ -10397,7 +10767,7 @@ Rigidbody: m_Mass: 1 m_Drag: 0 m_AngularDrag: 0 - m_UseGravity: 1 + m_UseGravity: 0 m_IsKinematic: 0 m_Interpolate: 0 m_Constraints: 112 @@ -10411,7 +10781,7 @@ CapsuleCollider: m_GameObject: {fileID: 7398140401948337837} m_Material: {fileID: 0} m_IsTrigger: 0 - m_Enabled: 1 + m_Enabled: 0 m_Radius: 1.7212968 m_Height: 6.3698125 m_Direction: 1 diff --git a/Assets/Scripts/CoinCounter.cs b/Assets/Scripts/CoinCounter.cs index ec998e2..56bb99c 100644 --- a/Assets/Scripts/CoinCounter.cs +++ b/Assets/Scripts/CoinCounter.cs @@ -6,6 +6,15 @@ public class CoinCounter : MonoBehaviour { public ulong coin = 0; //szedje le db-bol a playerhez a coint + private DatabaseData dd; + + //get player coin at startup based on username + private void Awake() { + dd = FindObjectOfType(); + + //dd.GetCoinData("Playmaker1210"); + } + public void AddCoin(ulong number){ coin += number; } diff --git a/Assets/Scripts/Network/DatabaseData.cs b/Assets/Scripts/Network/DatabaseData.cs index 9583a19..89856e5 100644 --- a/Assets/Scripts/Network/DatabaseData.cs +++ b/Assets/Scripts/Network/DatabaseData.cs @@ -12,10 +12,13 @@ public class DatabaseData : MonoBehaviour public HighScoreTable hst; //high score table ui public string jsondata; //json szoveg + private CoinCounter coinc; + private void Awake() { hst = FindObjectOfType(); //High Score Table referencia htdc = new HighScoreTableDataContainer(); //High Score Table Container objektum players = new PlayerList(); //jatekos lista osztaly + coinc = FindObjectOfType(); } private void Start() { @@ -37,6 +40,8 @@ public class DatabaseData : MonoBehaviour public void PostNewScoreData() => StartCoroutine(IPostNewScoreData()); public void PostNewPalyaData() => StartCoroutine(IPostNewPalyaData()); + public void GetCoinData(string username) => StartCoroutine(IGetPlayerCoins(username)); + private IEnumerator IGetPlayerData() { input.text = "Loading..."; //ideiglenes szoveg amig nem jelenik meg az adat szoveg @@ -66,6 +71,30 @@ public class DatabaseData : MonoBehaviour } + private IEnumerator IGetCurretPlayer(int userid){ + string uri = "http://localhost:3000/currentplayer"; + + var uwr = new UnityWebRequest(uri, "POST"); + byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes("{\"bevitel1\":"+userid+"}"); //palya id megadasa + uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend); //felkuldi a palya id-t + uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); + uwr.SetRequestHeader("Content-Type", "application/json"); + + yield return uwr.SendWebRequest(); + + if (uwr.isNetworkError) { + Debug.Log(uwr.error); + } else { + jsondata = uwr.downloadHandler.text; //json szoveg eltarolasa + Debug.Log("current player json: " + jsondata); + jsonParser(jsondata); //json adat atalakitasa + foreach(var p in players.player) { + p.ConvertDate(); //datum eltarolasa es atalakitasa datum tipussa + Debug.Log("p_id: " + p.player_id + " username: " + p.player_name + " join date: " + p.joindate.printDate() + "\n"); + } + } + } + private IEnumerator IGetHighScoreData(int palya_id){ string uri = "http://localhost:3000/toplist"; @@ -104,7 +133,7 @@ public class DatabaseData : MonoBehaviour Debug.Log(uwr.error); } else { Debug.Log(uwr.downloadHandler.text); - + coinc.coin = ulong.Parse(uwr.downloadHandler.text); } } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 32360ac..2db08f5 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.UI; public class PlayerController : MonoBehaviour { @@ -16,49 +17,78 @@ public class PlayerController : MonoBehaviour private Vector2 startTouchPosition; //erintes kezdo pozicio private Vector2 endTouchPosition; //erintes vegpozicio + public ControllType activeControllType; + + public Button leftButton; + public Button jumpButton; + public Button rightButton; + + public enum ControllType + { + Swipe, + Button + } + private void Awake() { cc = FindObjectOfType(); //kamera vezerlo referencia + activeControllType = ControllType.Button; + } + + public void setControllType(ControllType controlltype){ + activeControllType = controlltype; } private void Update(){ - //jumping - if(Input.touchCount > 0){ - Touch touch = Input.GetTouch(0); //elso erintes lekerese + + if(activeControllType == ControllType.Swipe){ + leftButton.gameObject.SetActive(false); + jumpButton.gameObject.SetActive(false); + rightButton.gameObject.SetActive(false); - if(touch.phase == TouchPhase.Began){ //ha az erintes elkezdotott - isTapped = true; - timeSinceLastTap = Time.time; - } + //jumping + if(Input.touchCount > 0){ + Touch touch = Input.GetTouch(0); //elso erintes lekerese - if(touch.phase == TouchPhase.Ended){ //ha az erintes befejezodott - isTapped = false; - timeSinceLastTap = 0f; - } + if(touch.phase == TouchPhase.Began){ //ha az erintes elkezdotott + isTapped = true; + timeSinceLastTap = Time.time; + } - if(isTapped && rb.transform.position.y <= 0.16f){ - if(Time.time - timeSinceLastTap >= holdTime){ //ha nyomva tartotta a beallitott ideig - Debug.Log("Long tapped"); - rb.AddForce(new Vector3(0, jumpforce, 0)); //ugras + if(touch.phase == TouchPhase.Ended){ //ha az erintes befejezodott isTapped = false; + timeSinceLastTap = 0f; + } + + if(isTapped && rb.transform.position.y <= 0.16f){ + if(Time.time - timeSinceLastTap >= holdTime){ //ha nyomva tartotta a beallitott ideig + Debug.Log("Long tapped"); + jump(); + isTapped = false; + } } } - } - //new character controller with swipe lane changing - if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){ //elso erintes elkezdodott - startTouchPosition = Input.GetTouch(0).position; - } - if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended){ //elso erintes befejezodott - endTouchPosition = Input.GetTouch(0).position; - - if(endTouchPosition.x < startTouchPosition.x){ //balra huzott - //left - goLeft(); - - }else if(endTouchPosition.x > startTouchPosition.x){ //jobbra huzott - //right - goRight(); + //new character controller with swipe lane changing + if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){ //elso erintes elkezdodott + startTouchPosition = Input.GetTouch(0).position; } + if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended){ //elso erintes befejezodott + endTouchPosition = Input.GetTouch(0).position; + + if(endTouchPosition.x < startTouchPosition.x){ //balra huzott + //left + goLeft(); + + }else if(endTouchPosition.x > startTouchPosition.x){ //jobbra huzott + //right + goRight(); + } + } + }else if(activeControllType == ControllType.Button){ + jumpforce = 2; + leftButton.onClick.AddListener(goRight); + jumpButton.onClick.AddListener(jump); + rightButton.onClick.AddListener(goLeft); } } @@ -73,4 +103,8 @@ public class PlayerController : MonoBehaviour cc.xPostion = 3; //kamera xPozicioja rb.transform.position = new Vector3(rb.transform.position.x - sideMovement, rb.transform.position.y, rb.transform.position.z); } + + private void jump(){ + rb.AddForce(new Vector3(0, jumpforce, 0)); //ugras + } } \ No newline at end of file diff --git a/Assets/Scripts/SetButtonSize.cs b/Assets/Scripts/SetButtonSize.cs new file mode 100644 index 0000000..4fb1e6f --- /dev/null +++ b/Assets/Scripts/SetButtonSize.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using TMPro; + +public class SetButtonSize : MonoBehaviour +{ + public Canvas canvas; + public Button leftButton; + public Button jumpButton; + public Button rightButton; + + private Vector2 canvasSize; + + private void Awake() { + canvasSize = new Vector2(canvas.GetComponent().rect.width, canvas.GetComponent().rect.height); + + ///leftButton + } +} diff --git a/Assets/Scripts/SetButtonSize.cs.meta b/Assets/Scripts/SetButtonSize.cs.meta new file mode 100644 index 0000000..614680f --- /dev/null +++ b/Assets/Scripts/SetButtonSize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e84dc5ac17504204da8ccd1fb2c9bbfe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/fps.cs b/Assets/Scripts/fps.cs index ad2b97c..68e2a65 100644 --- a/Assets/Scripts/fps.cs +++ b/Assets/Scripts/fps.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; -using System.Threading; +using UnityEditor; public class fps : MonoBehaviour { @@ -13,10 +13,12 @@ public class fps : MonoBehaviour // Update is called once per frame void Update() { + #if UNITY_EDITOR if (Time.unscaledTime > _timer) { int fps = (int)(1f / Time.unscaledDeltaTime); fpsText.text = "FPS: " + fps; _timer = Time.unscaledTime + _hudRefreshRate; } + #endif } } diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index 88bc245..774d9ab 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -15,15 +15,15 @@ MonoBehaviour: m_PixelRect: serializedVersion: 2 x: 0 - y: 28 - width: 1366 - height: 673 + y: 43 + width: 1920 + height: 997 m_ShowMode: 4 m_Title: Hierarchy m_RootView: {fileID: 3} m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} - m_Maximized: 0 + m_Maximized: 1 --- !u!114 &2 MonoBehaviour: m_ObjectHideFlags: 52 @@ -39,10 +39,10 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 681 + x: 957 y: 0 - width: 339 - height: 354 + width: 477 + height: 550 m_MinSize: {x: 202, y: 221} m_MaxSize: {x: 4002, y: 4021} m_ActualView: {fileID: 18} @@ -70,8 +70,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1366 - height: 673 + width: 1920 + height: 997 m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} m_UseTopView: 1 @@ -95,7 +95,7 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1366 + width: 1920 height: 30 m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} @@ -116,8 +116,8 @@ MonoBehaviour: m_Position: serializedVersion: 2 x: 0 - y: 653 - width: 1366 + y: 977 + width: 1920 height: 20 m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} @@ -140,12 +140,12 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 30 - width: 1366 - height: 623 + width: 1920 + height: 947 m_MinSize: {x: 400, y: 200} m_MaxSize: {x: 32384, y: 16192} vertical: 0 - controlID: 173 + controlID: 108 --- !u!114 &7 MonoBehaviour: m_ObjectHideFlags: 52 @@ -165,12 +165,12 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1020 - height: 623 + width: 1434 + height: 947 m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 1 - controlID: 174 + controlID: 109 --- !u!114 &8 MonoBehaviour: m_ObjectHideFlags: 52 @@ -191,12 +191,12 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 1020 - height: 354 + width: 1434 + height: 550 m_MinSize: {x: 300, y: 100} m_MaxSize: {x: 24288, y: 8096} vertical: 0 - controlID: 175 + controlID: 110 --- !u!114 &9 MonoBehaviour: m_ObjectHideFlags: 52 @@ -214,8 +214,8 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 0 - width: 173 - height: 354 + width: 243 + height: 550 m_MinSize: {x: 201, y: 221} m_MaxSize: {x: 4001, y: 4021} m_ActualView: {fileID: 13} @@ -238,10 +238,10 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 173 + x: 243 y: 0 - width: 508 - height: 354 + width: 714 + height: 550 m_MinSize: {x: 202, y: 221} m_MaxSize: {x: 4002, y: 4021} m_ActualView: {fileID: 14} @@ -265,9 +265,9 @@ MonoBehaviour: m_Position: serializedVersion: 2 x: 0 - y: 354 - width: 1020 - height: 269 + y: 550 + width: 1434 + height: 397 m_MinSize: {x: 101, y: 121} m_MaxSize: {x: 4001, y: 4021} m_ActualView: {fileID: 16} @@ -291,12 +291,12 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 1020 + x: 1434 y: 0 - width: 346 - height: 623 - m_MinSize: {x: 276, y: 71} - m_MaxSize: {x: 4001, y: 4021} + width: 486 + height: 947 + m_MinSize: {x: 275, y: 50} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 17} m_Panes: - {fileID: 17} @@ -323,9 +323,9 @@ MonoBehaviour: m_Pos: serializedVersion: 2 x: 0 - y: 86 - width: 172 - height: 333 + y: 73 + width: 242 + height: 529 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -333,9 +333,9 @@ MonoBehaviour: m_SceneHierarchy: m_TreeViewState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: - m_LastClickedID: 0 - m_ExpandedIDs: b8faffff + m_SelectedIDs: e2f4ffff + m_LastClickedID: -2846 + m_ExpandedIDs: 9af4ffffe2f4ffff34fbffff425a0000a05a0000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -351,7 +351,7 @@ MonoBehaviour: m_IsRenaming: 0 m_OriginalEventType: 11 m_IsRenamingFilename: 0 - m_ClientGUIView: {fileID: 0} + m_ClientGUIView: {fileID: 9} m_SearchString: m_ExpandedScenes: [] m_CurrenRootInstanceID: 0 @@ -379,10 +379,10 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 173 - y: 86 - width: 506 - height: 333 + x: 243 + y: 73 + width: 712 + height: 529 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -617,9 +617,9 @@ MonoBehaviour: m_PlayAudio: 0 m_AudioPlay: 0 m_Position: - m_Target: {x: 5.276126, y: 3.061911, z: -6.65707} + m_Target: {x: -0.70529556, y: 8.58622, z: -58.736225} speed: 2 - m_Value: {x: 5.276126, y: 3.061911, z: -6.65707} + m_Value: {x: -0.70529556, y: 8.58622, z: -58.736225} m_RenderMode: 0 m_CameraMode: drawMode: 0 @@ -666,13 +666,13 @@ MonoBehaviour: m_GridAxis: 1 m_gridOpacity: 0.5 m_Rotation: - m_Target: {x: -0.20257631, y: 0.2837753, z: -0.061466984, w: -0.9352343} + m_Target: {x: -0.24836192, y: 0.22615214, z: -0.059745934, w: -0.94} speed: 2 - m_Value: {x: -0.20257631, y: 0.2837753, z: -0.06146699, w: -0.93523437} + m_Value: {x: -0.24836217, y: 0.22615236, z: -0.059745993, w: -0.94000095} m_Size: - m_Target: 11.961957 + m_Target: 30.205072 speed: 2 - m_Value: 11.961957 + m_Value: 30.205072 m_Ortho: m_Target: 0 speed: 2 @@ -718,9 +718,9 @@ MonoBehaviour: m_Pos: serializedVersion: 2 x: 0 - y: 440 - width: 1019 - height: 248 + y: 623 + width: 1433 + height: 376 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -738,22 +738,22 @@ MonoBehaviour: m_SkipHidden: 0 m_SearchArea: 1 m_Folders: - - Assets/Scripts/Network + - Assets/Scripts m_Globs: [] m_OriginalText: m_ViewMode: 1 m_StartGridSize: 64 m_LastFolders: - - Assets/Scripts/Network + - Assets/Scripts m_LastFoldersGridSize: -1 - m_LastProjectPath: /home/tom/Documents/dev/zarodolgozat/ColorRunner + m_LastProjectPath: C:\dev\zarodolgozat\ColorBall m_LockTracker: m_IsLocked: 0 m_FolderTreeState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: 80670000 - m_LastClickedID: 26496 - m_ExpandedIDs: 000000004c59000000ca9a3b + m_SelectedIDs: 54650000 + m_LastClickedID: 25940 + m_ExpandedIDs: 0000000046650000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -781,7 +781,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 000000004c59000000ca9a3b + m_ExpandedIDs: 0000000046650000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -825,7 +825,7 @@ MonoBehaviour: m_IsRenaming: 0 m_OriginalEventType: 11 m_IsRenamingFilename: 1 - m_ClientGUIView: {fileID: 0} + m_ClientGUIView: {fileID: 11} m_CreateAssetUtility: m_EndAction: {fileID: 0} m_InstanceID: 0 @@ -858,9 +858,9 @@ MonoBehaviour: m_Pos: serializedVersion: 2 x: 0 - y: 440 - width: 1019 - height: 248 + y: 623 + width: 1433 + height: 376 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -885,10 +885,10 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1020 - y: 86 - width: 345 - height: 602 + x: 1434 + y: 73 + width: 485 + height: 926 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -926,10 +926,10 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 681 - y: 86 - width: 337 - height: 333 + x: 957 + y: 73 + width: 475 + height: 529 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -958,7 +958,7 @@ MonoBehaviour: - UnityEditor.DeviceSimulation.ApplicationSettingsPlugin pluginStates: - '{}' - scale: 11 + scale: 19 fitToScreenEnabled: 1 rotationDegree: 0 highlightSafeAreaEnabled: 0