diff --git a/Assets/Editor/TimerLock.cs b/Assets/Editor/TimerLock.cs new file mode 100644 index 0000000..a7482a9 --- /dev/null +++ b/Assets/Editor/TimerLock.cs @@ -0,0 +1,11 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu(fileName = "时间锁", menuName = "创建时间锁/配置文件")] +public class TimerLock : ScriptableObject +{ + [Header("软件有效期")] + public string time; + +} diff --git a/Assets/Editor/TimerLock.cs.meta b/Assets/Editor/TimerLock.cs.meta new file mode 100644 index 0000000..2c653f7 --- /dev/null +++ b/Assets/Editor/TimerLock.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c5b8343931d7c9a49a1ff9597f3ba0c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Tools.cs b/Assets/Editor/Tools.cs new file mode 100644 index 0000000..fa854c1 --- /dev/null +++ b/Assets/Editor/Tools.cs @@ -0,0 +1,51 @@ +using System; +using System.IO; +using UnityEditor; +using UnityEngine; + +#if UNITY_EDITOR +public class Tools +{ + [MenuItem("Tools/创建时间锁")] + private static void TimerLock() + { + //创建数据资源文件 + //泛型是继承自ScriptableObject的类 + TimerLock asset = ScriptableObject.CreateInstance(); + //前一步创建的资源只是存在内存中,现在要把它保存到本地 + //通过编辑器API,创建一个数据资源文件,第二个参数为资源文件在Assets目录下的路径 + AssetDatabase.CreateAsset(asset, "Assets/TimerLock.asset"); + //保存创建的资源 + AssetDatabase.SaveAssets(); + //刷新界面 + AssetDatabase.Refresh(); + } + + [MenuItem("Tools/生成Timer文件")] + private static void GeneratorTimer() + { + if (File.Exists(Application.dataPath + "/TimerLock.asset")) + { + string path = "Assets/TimerLock.asset"; + var asset = AssetDatabase.LoadAssetAtPath(path); + if (asset != null) + { + if (string.IsNullOrEmpty(asset.time) == false) + { + //第一次获取获取系统时间 + DateTime currentDateTime = DateTime.Now; + string RecordData = currentDateTime.ToString("yyyy-MM-dd HH:mm:ss"); + string strMerge = asset.time + "|" + RecordData; + EncryptFileCreator.EncryptAndSaveData(strMerge, "Timer.txt"); + } + } + } + //刷新界面 + AssetDatabase.Refresh(); + } + + + + +} +#endif \ No newline at end of file diff --git a/Assets/Editor/Tools.cs.meta b/Assets/Editor/Tools.cs.meta new file mode 100644 index 0000000..08a17ec --- /dev/null +++ b/Assets/Editor/Tools.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0772e5557591b3a4997bc2f77ef34f50 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/UIPrefabs/TimerCheckPanel.prefab b/Assets/Resources/UIPrefabs/TimerCheckPanel.prefab new file mode 100644 index 0000000..890a676 --- /dev/null +++ b/Assets/Resources/UIPrefabs/TimerCheckPanel.prefab @@ -0,0 +1,630 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &603515846068347574 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2973387460174964899} + - component: {fileID: 4046774654178239024} + - component: {fileID: 6775752147316619189} + m_Layer: 5 + m_Name: Other2_N + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2973387460174964899 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 603515846068347574} + 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: 9133111343023862921} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.12200001, y: 0.5231482} + m_AnchorMax: {x: 0.874, y: 0.8561482} + m_AnchoredPosition: {x: 1.5, y: 1} + m_SizeDelta: {x: 7, y: -4} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &4046774654178239024 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 603515846068347574} + m_CullTransparentMesh: 1 +--- !u!114 &6775752147316619189 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 603515846068347574} + 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: 1} + 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: 7ace1598f8a7c3d47b2c127e89fe6a21, 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!1 &1146598296151246231 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4750655449581826011} + - component: {fileID: 4966594276472824005} + - component: {fileID: 1823834173995265821} + - component: {fileID: 1798522582073850381} + m_Layer: 5 + m_Name: Train_N + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4750655449581826011 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1146598296151246231} + 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: 2888913759714920061} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: 1.3491, y: 330} + m_SizeDelta: {x: 284, y: 76} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &4966594276472824005 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1146598296151246231} + m_CullTransparentMesh: 1 +--- !u!114 &1823834173995265821 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1146598296151246231} + 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: 1} + 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: 97d5d667b4207cd4198d9accb49a2e1c, 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!114 &1798522582073850381 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1146598296151246231} + 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: 2 + 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.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 21300000, guid: 0e1346da76c650844ac909b4fc2c6d49, + type: 3} + 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: 1823834173995265821} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!1 &2888913759714920062 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2888913759714920061} + - component: {fileID: 2888913759714920060} + m_Layer: 5 + m_Name: TrainModelPanel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2888913759714920061 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2888913759714920062} + 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: + - {fileID: 2888913760214439239} + - {fileID: 4750655449581826011} + m_Father: {fileID: 4130714088394774955} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2888913759714920060 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2888913759714920062} + m_CullTransparentMesh: 1 +--- !u!1 &2888913760214439352 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2888913760214439239} + - component: {fileID: 2888913760214439237} + - component: {fileID: 2888913760214439238} + - component: {fileID: 8166912465334887831} + m_Layer: 5 + m_Name: Teach_N + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2888913760214439239 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2888913760214439352} + 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: 2888913759714920061} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: 1.3491, y: 415.5491} + m_SizeDelta: {x: 284, y: 76} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2888913760214439237 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2888913760214439352} + m_CullTransparentMesh: 1 +--- !u!114 &2888913760214439238 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2888913760214439352} + 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: 1} + 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: e52ed5e3cd6db80459c9520802557f8f, 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!114 &8166912465334887831 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2888913760214439352} + 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: 2 + 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.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 21300000, guid: ef43cff673d43ef48badac85cfd8b156, + type: 3} + 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: 2888913760214439238} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!1 &2901388735067139032 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 78317203956937394} + - component: {fileID: 2943517008154441021} + - component: {fileID: 3672005570292551768} + m_Layer: 5 + m_Name: Other1_N + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &78317203956937394 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2901388735067139032} + 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: 9133111343023862921} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.100375, y: 0.20066665} + m_AnchorMax: {x: 0.89500004, y: 0.545} + m_AnchoredPosition: {x: 4.5, y: -0.5} + m_SizeDelta: {x: 11, y: 2} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2943517008154441021 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2901388735067139032} + m_CullTransparentMesh: 1 +--- !u!114 &3672005570292551768 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2901388735067139032} + 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: 1} + 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: 4b3ac25c5ebd0ab41b0c5e3744d70e0e, 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!1 &6683858983085824027 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8762010044699360691} + - component: {fileID: 2698470933306118203} + - component: {fileID: 7593153994056117987} + m_Layer: 5 + m_Name: BiaoTi_N + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8762010044699360691 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6683858983085824027} + 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: 9133111343023862921} + 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: 0, y: 274} + m_SizeDelta: {x: 1851, y: 112} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2698470933306118203 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6683858983085824027} + m_CullTransparentMesh: 1 +--- !u!114 &7593153994056117987 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6683858983085824027} + 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: 1} + 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: a8ceb856dc4f19c49b678813dc40f9d2, 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!1 &8912481142875709138 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4130714088394774955} + m_Layer: 5 + m_Name: TimerCheckPanel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4130714088394774955 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8912481142875709138} + 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: + - {fileID: 9133111343023862921} + - {fileID: 2888913759714920061} + m_Father: {fileID: 0} + 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: 0, y: 0} + m_SizeDelta: {x: 1920, y: 1080} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &9133111343023862922 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 9133111343023862921} + - component: {fileID: 9133111343023862919} + - component: {fileID: 9133111343023862920} + m_Layer: 5 + m_Name: TrainBGPanel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &9133111343023862921 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9133111343023862922} + 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: + - {fileID: 78317203956937394} + - {fileID: 2973387460174964899} + - {fileID: 8762010044699360691} + m_Father: {fileID: 4130714088394774955} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &9133111343023862919 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9133111343023862922} + m_CullTransparentMesh: 1 +--- !u!114 &9133111343023862920 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9133111343023862922} + 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: 1} + 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: 9e4be6af4716004489f80f843948fa4a, 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 diff --git a/Assets/Resources/UIPrefabs/TimerCheckPanel.prefab.meta b/Assets/Resources/UIPrefabs/TimerCheckPanel.prefab.meta new file mode 100644 index 0000000..5bdc35d --- /dev/null +++ b/Assets/Resources/UIPrefabs/TimerCheckPanel.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2339bd97a05734748b4394b9b5415761 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/StreamingAssets/Timer.txt b/Assets/StreamingAssets/Timer.txt new file mode 100644 index 0000000..ca338a4 --- /dev/null +++ b/Assets/StreamingAssets/Timer.txt @@ -0,0 +1 @@ +ILBJ纤外05 喣l羾痱芮j@{梧鋨轕j叆鑑猜P+Z}劼> \ No newline at end of file diff --git a/Assets/StreamingAssets/Timer.txt.meta b/Assets/StreamingAssets/Timer.txt.meta new file mode 100644 index 0000000..3caaee2 --- /dev/null +++ b/Assets/StreamingAssets/Timer.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: aa0c91508fecffb4fb68596a0a07da40 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TimerLock.asset b/Assets/TimerLock.asset new file mode 100644 index 0000000..b7b6bb4 --- /dev/null +++ b/Assets/TimerLock.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c5b8343931d7c9a49a1ff9597f3ba0c2, type: 3} + m_Name: TimerLock + m_EditorClassIdentifier: + time: 2025-07-06 00:00:00 diff --git a/Assets/TimerLock.asset.meta b/Assets/TimerLock.asset.meta new file mode 100644 index 0000000..ecf186f --- /dev/null +++ b/Assets/TimerLock.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f30da0ad8d81325448a5006790548dd4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/Application/States/HomeState.cs b/Assets/_Scripts/Application/States/HomeState.cs index bf49111..9dcd462 100644 --- a/Assets/_Scripts/Application/States/HomeState.cs +++ b/Assets/_Scripts/Application/States/HomeState.cs @@ -1,5 +1,7 @@ using CG.Framework; +using CG.UTility; using System; +using UnityEngine; /******************************************************************************** *Create By CG *Function 主页状态 @@ -15,6 +17,16 @@ namespace ZXK.LouDiXvMuNiu public override void EnterState() { UI_Manage.Instance.ShowPanel("HomePanel", Type.GetType("ZXK.LouDiXvMuNiu.HomePanel"), UIGroup.Main); + DateManager.UpdateTime(Tip, Tip, success: () => + { + }); + } + public void Tip(string str) + { + PopUpMng.PopAlert("", str, "确定", () => + { + Application.Quit(); + }); } } } diff --git a/Assets/_Scripts/Application/States/TimerCheckState.cs b/Assets/_Scripts/Application/States/TimerCheckState.cs new file mode 100644 index 0000000..f5a92c6 --- /dev/null +++ b/Assets/_Scripts/Application/States/TimerCheckState.cs @@ -0,0 +1,24 @@ +using CG.Framework; +using CG.UTility; +using System; +using UnityEngine; +/******************************************************************************** +*Create By CG +*Function 主页状态 +*********************************************************************************/ +namespace ZXK.LouDiXvMuNiu +{ + public class TimerCheckState : State + { + public override string _SceneName => "TimerCheck"; + public TimerCheckState(StateContext stateContext) : base(stateContext) + { + } + public override void EnterState() + { + + + } + + } +} diff --git a/Assets/_Scripts/Application/States/TimerCheckState.cs.meta b/Assets/_Scripts/Application/States/TimerCheckState.cs.meta new file mode 100644 index 0000000..83d5ca7 --- /dev/null +++ b/Assets/_Scripts/Application/States/TimerCheckState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ab0e00d8e8cede74982f2b8e93253470 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/Application/UI/TimerCheckPanel.cs b/Assets/_Scripts/Application/UI/TimerCheckPanel.cs new file mode 100644 index 0000000..ef7a7eb --- /dev/null +++ b/Assets/_Scripts/Application/UI/TimerCheckPanel.cs @@ -0,0 +1,31 @@ +using CG.Framework; +using CG.UTility; +using System; +/******************************************************************************* +*Create By CG +*Function +*******************************************************************************/ +namespace ZXK.LouDiXvMuNiu +{ + public class TimerCheckPanel : UIBase + { + protected override void Awake() + { + base.Awake(); + + + PopUpMng.PopAlert("提示", "当前模块已完成", "确认", () => { + if (GameManager.Instance._StateContext.GetState().Name.Equals("ExamState")) + { + PopUpMng._TriAble = false; + UI_Manage.Instance.ShowPanel("ScoreDataPanel", Type.GetType("ZXK.LouDiXvMuNiu.ScoreDataPanel"), UIGroup.Tip); + } + }); + + + + + + } + } +} \ No newline at end of file diff --git a/Assets/_Scripts/Application/UI/TimerCheckPanel.cs.meta b/Assets/_Scripts/Application/UI/TimerCheckPanel.cs.meta new file mode 100644 index 0000000..453a2a8 --- /dev/null +++ b/Assets/_Scripts/Application/UI/TimerCheckPanel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fd50c7322bfdad14d8f7cf2a9e33e0c1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork.meta b/Assets/_Scripts/NetWork.meta new file mode 100644 index 0000000..00d442c --- /dev/null +++ b/Assets/_Scripts/NetWork.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 212a0a4f9a45b9740af050a33918ac7b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/Encryption.meta b/Assets/_Scripts/NetWork/Encryption.meta new file mode 100644 index 0000000..65aade6 --- /dev/null +++ b/Assets/_Scripts/NetWork/Encryption.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb335401f53d3c94490f449b410da1ba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/Encryption/DateManager.cs b/Assets/_Scripts/NetWork/Encryption/DateManager.cs new file mode 100644 index 0000000..daeff58 --- /dev/null +++ b/Assets/_Scripts/NetWork/Encryption/DateManager.cs @@ -0,0 +1,91 @@ +using System; +using System.IO; +using UnityEngine; +using UnityEngine.Events; + +public class DateManager +{ + + public static string EndTimer = "2025-07-06 00:00:00";//缁撴潫鏃堕棿 + private static string RecordData; + private void Start() + { + // CreatTimer(); + } + + /// + /// 鏇存柊绯荤粺鏃堕棿 + /// + public static void UpdateTime(UnityAction error = null, UnityAction timeOut = null, UnityAction update = null, UnityAction success = null) + { + try + { + string datas = DecryptFileReader.ReadAndDecryptData("Timer.txt"); + EndTimer = datas.Split('|')[0]; + RecordData = datas.Split('|')[1]; + //绗竴娆¤幏鍙栬幏鍙栫郴缁熸椂闂 + DateTime currentDateTime = DateTime.Now; + string Data = currentDateTime.ToString("yyyy-MM-dd HH:mm:ss"); + if (DateTime.TryParse(RecordData, out DateTime recordDateTime) && DateTime.TryParse(Data, out DateTime nowDateTime)) + { + if (recordDateTime > nowDateTime) + { + Debug.Log("浠跨湡鏂囦欢琚崯鍧忥紝璇疯仈绯荤鐞嗗憳杩涜淇"); + error?.Invoke("浠跨湡鏂囦欢琚崯鍧忥紝璇疯仈绯荤鐞嗗憳杩涜淇"); + } + else + { + //鎶婁笂涓娆″瓨鍌ㄥ緱绯荤粺鏃堕棿鏇存柊鍒版渶鏂 + string timer = "Timer.txt"; + RecordData = Data; + string strMerge = EndTimer + "|" + RecordData; + EncryptFileCreator.EncryptAndSaveData(strMerge, timer); + update?.Invoke(); + } + } + } + catch (Exception e) + { + Debug.LogError($"鏁版嵁鍑洪敊: {e.Message}"); + error?.Invoke($"鏁版嵁鍑洪敊: {e.Message}"); + } + + if (JudgeExpire()) + { + Debug.Log("璇疯仈绯荤鐞嗗憳杩涜鍗囩骇"); + timeOut?.Invoke("璇疯仈绯荤鐞嗗憳杩涜鍗囩骇"); + return; + } + success?.Invoke(); + } + + /// + /// 鍒ゆ柇鏄惁鍒版湡 + /// + /// + public static bool JudgeExpire() + { + if (DateTime.TryParse(EndTimer, out DateTime endDataTime) && DateTime.TryParse(RecordData, out DateTime recordDateTime)) + { + //缁撴潫鏃ユ湡灏忎簬鐩墠鏃ユ湡浠h〃鍒版湡 + if (endDataTime < recordDateTime) + { + return true; + } + } + return false; + } + + + /// + /// 缁欏鎴锋墦鍖呯殑鏃跺,闇瑕佽缃瓻ndTimer,鐒跺悗杩愯涓娆$敓鎴愭枃浠跺苟娉ㄩ噴鎺 + /// + public static void CreatTimer() + { + //绗竴娆¤幏鍙栬幏鍙栫郴缁熸椂闂 + DateTime currentDateTime = DateTime.Now; + RecordData = currentDateTime.ToString("yyyy-MM-dd HH:mm:ss"); + string strMerge = EndTimer + "|" + RecordData; + EncryptFileCreator.EncryptAndSaveData(strMerge, "Timer.txt"); + } +} diff --git a/Assets/_Scripts/NetWork/Encryption/DateManager.cs.meta b/Assets/_Scripts/NetWork/Encryption/DateManager.cs.meta new file mode 100644 index 0000000..8246b5b --- /dev/null +++ b/Assets/_Scripts/NetWork/Encryption/DateManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 989d94de1a3619e4ea11eebacb08d0f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/Encryption/DecryptFileReader.cs b/Assets/_Scripts/NetWork/Encryption/DecryptFileReader.cs new file mode 100644 index 0000000..1c6d60f --- /dev/null +++ b/Assets/_Scripts/NetWork/Encryption/DecryptFileReader.cs @@ -0,0 +1,41 @@ +using System.IO; +using System.Security.Cryptography; +using System.Text; +using UnityEngine; + +public class DecryptFileReader +{ + private static byte[] key = Encoding.UTF8.GetBytes("Sixteen byte key"); // 鍔犲瘑瀵嗛挜锛岄渶涓庡姞瀵嗘椂涓鑷 + private static byte[] iv = Encoding.UTF8.GetBytes("InitializationVe"); // 纭繚IV闀垮害涓16瀛楄妭 + + public static string ReadAndDecryptData(string filePath) + { + string fullPath = Path.Combine(Application.streamingAssetsPath, filePath); + if (File.Exists(filePath)) return ""; + // 璇诲彇鍔犲瘑鏂囦欢 + byte[] encryptedData = File.ReadAllBytes(fullPath); + + // 鍒涘缓AES瑙e瘑鍣 + using (Aes aesAlg = Aes.Create()) + { + aesAlg.Key = key; + aesAlg.IV = iv; + + ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV); + + // 鍒涘缓鍐呭瓨娴佸拰鍔犲瘑娴 + using (MemoryStream msDecrypt = new MemoryStream(encryptedData)) + { + using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) + { + byte[] decryptedBytes = new byte[encryptedData.Length]; + int decryptedByteCount = csDecrypt.Read(decryptedBytes, 0, decryptedBytes.Length); + + // 灏嗚В瀵嗗悗鐨勬暟鎹浆鎹负瀛楃涓 + string decryptedData = Encoding.UTF8.GetString(decryptedBytes, 0, decryptedByteCount); + return decryptedData; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/_Scripts/NetWork/Encryption/DecryptFileReader.cs.meta b/Assets/_Scripts/NetWork/Encryption/DecryptFileReader.cs.meta new file mode 100644 index 0000000..a4452c9 --- /dev/null +++ b/Assets/_Scripts/NetWork/Encryption/DecryptFileReader.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 354bc54210a77764ebad2d49b5e927ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/Encryption/EncryptFileCreator.cs b/Assets/_Scripts/NetWork/Encryption/EncryptFileCreator.cs new file mode 100644 index 0000000..e19b7f2 --- /dev/null +++ b/Assets/_Scripts/NetWork/Encryption/EncryptFileCreator.cs @@ -0,0 +1,56 @@ +using System.IO; +using System.Security.Cryptography; +using System.Text; +using UnityEngine; + +public class EncryptFileCreator +{ + private static byte[] key = Encoding.UTF8.GetBytes("Sixteen byte key"); // 鍔犲瘑瀵嗛挜锛岄渶16瀛楄妭 + private static byte[] iv = Encoding.UTF8.GetBytes("InitializationVe"); // 纭繚IV闀垮害涓16瀛楄妭 + + public static void EncryptAndSaveData(string data,string path) + { + string filePath = Path.Combine(Application.streamingAssetsPath, path); + if (!File.Exists(filePath)) + { + try + { + // 鍒涘缓鏂囦欢 + File.WriteAllText(filePath, ""); + Debug.Log("鏂囦欢宸插垱寤"); + } + catch (IOException e) + { + Debug.LogError($"鍒涘缓鏂囦欢鏃跺嚭閿: {e.Message}"); + } + } + // 灏嗘暟鎹浆鎹负瀛楄妭鏁扮粍 + byte[] plainText = Encoding.UTF8.GetBytes(data); + + // 鍒涘缓AES鍔犲瘑鍣 + using (Aes aesAlg = Aes.Create()) + { + aesAlg.Key = key; + aesAlg.IV = iv; + + ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); + + // 鍒涘缓鍐呭瓨娴佸拰鍔犲瘑娴 + using (MemoryStream msEncrypt = new MemoryStream()) + { + using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) + { + csEncrypt.Write(plainText, 0, plainText.Length); + csEncrypt.FlushFinalBlock(); + + // 鑾峰彇鍔犲瘑鍚庣殑鏁版嵁 + byte[] encryptedData = msEncrypt.ToArray(); + + // 淇濆瓨鍔犲瘑鏂囦欢鍒癝treamingAssets鏂囦欢澶 + string fullPath = Path.Combine(Application.streamingAssetsPath, filePath); + File.WriteAllBytes(fullPath, encryptedData); + } + } + } + } +} \ No newline at end of file diff --git a/Assets/_Scripts/NetWork/Encryption/EncryptFileCreator.cs.meta b/Assets/_Scripts/NetWork/Encryption/EncryptFileCreator.cs.meta new file mode 100644 index 0000000..77d8e4b --- /dev/null +++ b/Assets/_Scripts/NetWork/Encryption/EncryptFileCreator.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 22f7660ba2e708d4eb33622fe324499b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/HttpRestful.cs b/Assets/_Scripts/NetWork/HttpRestful.cs new file mode 100644 index 0000000..8079d5a --- /dev/null +++ b/Assets/_Scripts/NetWork/HttpRestful.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections; +using UnityEngine; +using UnityEngine.Networking; +using ZXKFramework; + +public class HttpRestful : SingletonDdol +{ + public void Get(string url, Action actionResult = null) + { + StartCoroutine(_Get(url, actionResult)); + } + + private IEnumerator _Get(string url, Action action) + { + using (UnityWebRequest request = UnityWebRequest.Get(url)) + { + yield return request.SendWebRequest(); + + string resstr = ""; + if (request.isNetworkError || request.isHttpError) + { + resstr = request.error; + } + else + { + resstr = request.downloadHandler.text; + } + + if (action != null) + { + action(request.isHttpError, resstr); + } + } + } + public void Post(string url, string form, Action callBack, string Header = null, string HeaderValue = null, int timeOut = 3) + { + + StartCoroutine(_Post(url, form, callBack, Header, HeaderValue, timeOut)); + } + + public IEnumerator _Post(string url, string form, Action callBack, string Header = null, string HeaderValue = null, int timeOut = 3) + { + //璇锋眰閾炬帴锛屽苟灏唂orm瀵硅薄鍙戦佸埌杩滅▼鏈嶅姟鍣 + using (UnityWebRequest webRequest = UnityWebRequest.Post(url, form, "application/json"))//;charset=utf-8 + { + if (!string.IsNullOrEmpty(Header) && !string.IsNullOrEmpty(HeaderValue)) + { + webRequest.SetRequestHeader(Header, HeaderValue); + } + webRequest.timeout = timeOut * 1000; + yield return webRequest.SendWebRequest(); + if (webRequest.result!= UnityWebRequest.Result.Success) + { + Debug.Log(webRequest.error); + callBack?.Invoke(false, webRequest.downloadHandler); + } + else + { + callBack?.Invoke(true, webRequest.downloadHandler); + } + //if (webRequest.isHttpError || webRequest.isNetworkError) + //{ + // //Debug.LogError("==========="); + // callBack?.Invoke(false, null); + //} + //else + //{ + // callBack?.Invoke(true, webRequest.downloadHandler); + //} + }; + } +} \ No newline at end of file diff --git a/Assets/_Scripts/NetWork/HttpRestful.cs.meta b/Assets/_Scripts/NetWork/HttpRestful.cs.meta new file mode 100644 index 0000000..2fa9020 --- /dev/null +++ b/Assets/_Scripts/NetWork/HttpRestful.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cca16177d7a134a43a4fb3320d5b8fc7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/Licence.meta b/Assets/_Scripts/NetWork/Licence.meta new file mode 100644 index 0000000..a4c0b9c --- /dev/null +++ b/Assets/_Scripts/NetWork/Licence.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 32677377141e60248a7a2484825ce1d4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/Licence/LicenceData.cs b/Assets/_Scripts/NetWork/Licence/LicenceData.cs new file mode 100644 index 0000000..d84ee2c --- /dev/null +++ b/Assets/_Scripts/NetWork/Licence/LicenceData.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class LicenceData +{ + public string project_id; + public string user_name; + public string license_code; + public string host_id; + public string duration; //浣跨敤鏃堕暱 + public string sign; +} +public class Datas +{ + public static string Project_id = "7"; + public static string secretKey = "pZNwkYoMRp7MG_O7aGtmA"; + public static string UserName; + public static string Licensecode; + public static string Hostid; + public static int Duration;//鎸佺画鏃堕棿 +} +[Serializable] +public class License +{ + public int id; + public string user_name; + public string license_code; + public int is_authorized; + public string host_id; + public string authorization_at; + public string authorization_end_at; + public string created_at; + public int login_count; + public int duration; + public string last_login; +} + +[Serializable] +public class LicenseValidationResponse +{ + public string status; + public string message; + public License license; +} \ No newline at end of file diff --git a/Assets/_Scripts/NetWork/Licence/LicenceData.cs.meta b/Assets/_Scripts/NetWork/Licence/LicenceData.cs.meta new file mode 100644 index 0000000..de5c59a --- /dev/null +++ b/Assets/_Scripts/NetWork/Licence/LicenceData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8f40d10c2dcbad941ac179b38fde96bd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/_Scripts/NetWork/Licence/LicenseManager.cs b/Assets/_Scripts/NetWork/Licence/LicenseManager.cs new file mode 100644 index 0000000..06c24c2 --- /dev/null +++ b/Assets/_Scripts/NetWork/Licence/LicenseManager.cs @@ -0,0 +1,179 @@ +using LitJson; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Net.NetworkInformation; +using System.Security.Cryptography; +using System.Text; +using UnityEngine; + +public class LicenseManager : MonoBehaviour +{ + private Dictionary Data = new(); + private LicenseValidationResponse LicenseRes = new LicenseValidationResponse(); + private string Hostid = ""; + + public void Init() + { + Hostid = GetPhysicalAddress(); + Datas.Hostid = Hostid; + } + public LicenceData GetLicenceData(string projectid, string userName, string licensecode, string hostid, int duration) + { + Data.Clear(); + LicenceData licence = new LicenceData(); + licence.project_id = projectid; + licence.user_name = userName; + licence.license_code = licensecode; + licence.host_id = hostid; + licence.duration = duration.ToString(); + if (!Data.ContainsKey("project_id")) + { + Data.Add("project_id", licence.project_id); + } + if (!Data.ContainsKey("user_name")) + { + Data.Add("user_name", licence.user_name); + } + if (!Data.ContainsKey("license_code")) + { + Data.Add("license_code", licence.license_code); + } + if (!Data.ContainsKey("host_id")) + { + Data.Add("host_id", licence.host_id); + } + if (!Data.ContainsKey("duration")) + { + Data.Add("duration", licence.duration); + } + licence.sign = GenerateSignature(Datas.secretKey, Data); + return licence; + } + /// + /// 璇锋眰 + /// + /// + /// + public void LicensePost(Action callBack = null) + { + LicenceData licence = GetLicenceData(Datas.Project_id, Datas.UserName, Datas.Licensecode, Datas.Hostid, Datas.Duration); + string json = JsonMapper.ToJson(licence); + HttpRestful.Instance.Post("https://locallicense.zxkedu.com/api/license/validate/", json, (m, n) => + { + LicenseRes = JsonMapper.ToObject(n.text); + if (LicenseRes.status == "success") + { + EncryptedFile(); + } + callBack.Invoke(m); + }); + } + + /// + /// 鐢熸垚瀵嗗寵 + /// + /// + /// + /// + public string GenerateSignature(string secretKey, Dictionary data) + { + // 娣诲姞褰撳墠鏃堕棿鎴 + //string timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); + //鑾峰彇褰撳墠鏃堕棿鎴冲苟鍥涜垗浜斿叆鍒版渶杩戠殑鍒嗛挓 + long timestamp = (long)(DateTimeOffset.UtcNow.ToUnixTimeSeconds() / 60) * 60; + //long timestamp = (long)(GetTimestamp() / 60) * 60; + if (!data.ContainsKey("timestamp")) + { + data.Add("timestamp", timestamp.ToString()); + } + else + { + data["timestamp"] = timestamp.ToString(); + } + // 瀵归敭鍊煎杩涜鎺掑簭 + var sortedData = data.OrderBy(kvp => kvp.Key); + Debug.Log("sortedData瀵归敭鍊煎杩涜鎺掑簭:" + sortedData); + + // 鏋勫缓鏌ヨ瀛楃涓 + string queryString = string.Join("&", sortedData.Select(kvp => $"{kvp.Key}={kvp.Value}")); + Debug.Log("queryString鏋勫缓鏌ヨ瀛楃涓:" + queryString); + // 浣跨敤HMAC-SHA256鐢熸垚绛惧悕 + using (var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(secretKey))) + { + byte[] hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(queryString)); + Debug.Log("鐢熸垚绛惧悕:" + BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant()); + return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); + } + } + + public void StartSetDuration() + { + if (gameObject.activeSelf) + { + StartCoroutine(SetDuration(60f)); + } + } + + IEnumerator SetDuration(float times) + { + while (true) + { + yield return new WaitForSeconds(times); + Datas.Duration++; + LicensePost(); + Datas.Duration = 0; + } + } + public string GetMachineGuid() + { + if (string.IsNullOrEmpty(Hostid)) + { + NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces(); + foreach (NetworkInterface ni in nis) + { + if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || + ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) + { + Hostid = ni.GetPhysicalAddress().ToString(); + break; + } + } + } + return Hostid; + } + + string GetPhysicalAddress() + { + //string physicalAddress = ""; + //NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces(); + //foreach (NetworkInterface ni in nis) + //{ + // if (ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet && ni.OperationalStatus == OperationalStatus.Up) + // { + // physicalAddress = ni.GetPhysicalAddress().ToString(); + // break; + // } + //} + return SystemInfo.deviceUniqueIdentifier; + } + + /// + /// 鏈湴瀛樺偍Hostid + /// + public void EncryptedFile() + { + string dataToEncrypt = Datas.UserName + "|" + Datas.Licensecode + "|"; + EncryptFileCreator.EncryptAndSaveData(dataToEncrypt, "encryptedData.txt"); + } + /// + /// 璇诲彇Hostid + /// + /// + public string ReadDecryptedFile() + { + string decryptedData = DecryptFileReader.ReadAndDecryptData("encryptedData.txt"); + return decryptedData; + } +} diff --git a/Assets/_Scripts/NetWork/Licence/LicenseManager.cs.meta b/Assets/_Scripts/NetWork/Licence/LicenseManager.cs.meta new file mode 100644 index 0000000..b85899a --- /dev/null +++ b/Assets/_Scripts/NetWork/Licence/LicenseManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 13a2f840c2d90a44b8473ca7cf9adef1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: