Browse Source

添加预案加密

develop
曹衍涛 5 years ago
parent
commit
4e5f06cf21
  1. 213
      Assets/Editor/SceneToolFloor.cs
  2. 11
      Assets/Editor/SceneToolFloor.cs.meta
  3. BIN
      Assets/Plugins/SmartX1AppX64.dll
  4. 27
      Assets/Plugins/SmartX1AppX64.dll.meta
  5. BIN
      Assets/Plugins/System.Security.dll
  6. 33
      Assets/Plugins/System.Security.dll.meta
  7. 8
      Assets/Plugins/x86_64.meta
  8. BIN
      Assets/Plugins/x86_64/SmartX1App.dll
  9. 136
      Assets/Plugins/x86_64/SmartX1App.dll.meta
  10. 43
      Assets/Prefabs/Common/DisasterLibrary/DissaterSetting.prefab
  11. 194
      Assets/Scenes/DummyScene.unity
  12. 8
      Assets/Scripts/SmartX1.meta
  13. 275
      Assets/Scripts/SmartX1/SmartApp.cs
  14. 11
      Assets/Scripts/SmartX1/SmartApp.cs.meta
  15. 280
      Assets/Scripts/SmartX1/SmartController.cs
  16. 11
      Assets/Scripts/SmartX1/SmartController.cs.meta
  17. 214
      Assets/Scripts/SmartX1/SmartX1Api.cs
  18. 11
      Assets/Scripts/SmartX1/SmartX1Api.cs.meta
  19. 8
      Assets/StreamingAssets/xml.meta
  20. 2
      Assets/StreamingAssets/xml/enSmartXProject.xml
  21. 7
      Assets/StreamingAssets/xml/enSmartXProject.xml.meta

213
Assets/Editor/SceneToolFloor.cs

@ -0,0 +1,213 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.AI;
using System.IO;
using System.Text;
using System;
public class SceneToolFloor
{
//[MenuItem("SceneTool/SetFloorMessage")]//添加FloorMessage脚本绑定楼层信息
//public static void SetFloorMessage()
//{
// Transform neiParent = GameObject.Find("shinei").transform.GetChild(0);
// for (int i = 0; i < neiParent.childCount; i++)
// {
// //Debug.Log(neiParent.GetChild(i).name);
// if (!neiParent.GetChild(i).GetComponent<FloorMessage>())
// {
// neiParent.GetChild(i).gameObject.AddComponent<FloorMessage>();
// }
// FloorMessage msg = neiParent.GetChild(i).GetComponent<FloorMessage>();
// msg.targetTrans = GetTarget(neiParent.GetChild(i));
// msg.buildNum = neiParent.name;
// if (!neiParent.GetChild(i).name.ToLower().Contains("m"))
// {
// string floornum = neiParent.GetChild(i).name.Substring
// (neiParent.GetChild(i).name.ToLower().IndexOf("nei") + 3/*, neiParent.GetChild(i).name.Length - 4*/);
// msg.floorNum = int.Parse(floornum);
// msg.interlayerNum = 0;
// }
// else
// {
// msg.floorNum = int.Parse(neiParent.GetChild(i).name.Substring
// (neiParent.GetChild(i).name.ToLower().IndexOf("nei") + 3, neiParent.GetChild(i).name.ToLower().IndexOf("m")
// - neiParent.GetChild(i).name.ToLower().IndexOf("nei") - 4));
// msg.interlayerNum = int.Parse(neiParent.GetChild(i).name.Substring
// (neiParent.GetChild(i).name.ToLower().IndexOf("m") + 1, neiParent.GetChild(i).name.Length -
// neiParent.GetChild(i).name.ToLower().IndexOf("m") - 1));
// }
// }
// Transform waiParent = GameObject.Find("shiwai").transform.GetChild(0);
// for (int i = 0; i < waiParent.childCount; i++)
// {
// //Debug.Log(waiParent.GetChild(i).name);
// if (!waiParent.GetChild(i).GetComponent<FloorMessage>())
// {
// waiParent.GetChild(i).gameObject.AddComponent<FloorMessage>();
// }
// FloorMessage msg = waiParent.GetChild(i).GetComponent<FloorMessage>();
// msg.buildNum = waiParent.name;
// if (!waiParent.GetChild(i).name.ToLower().Contains("m"))
// {
// string floornum = waiParent.GetChild(i).name.Substring
// (waiParent.GetChild(i).name.ToLower().IndexOf("wai") + 3/*, waiParent.GetChild(i).name.Length - 4*/);
// msg.floorNum = int.Parse(floornum);
// msg.interlayerNum = 0;
// }
// else
// {
// msg.floorNum = int.Parse(waiParent.GetChild(i).name.Substring
// (waiParent.GetChild(i).name.ToLower().IndexOf("wai") + 4, waiParent.GetChild(i).name.ToLower().IndexOf("m")
// - waiParent.GetChild(i).name.ToLower().IndexOf("wai") - 4));
// msg.interlayerNum = int.Parse(waiParent.GetChild(i).name.Substring
// (waiParent.GetChild(i).name.ToLower().IndexOf("m") + 1, waiParent.GetChild(i).name.Length -
// waiParent.GetChild(i).name.ToLower().IndexOf("m") - 1));
// }
// }
//}
//static Transform GetTarget(Transform parent)
//{
// for (int i = 0; i < parent.childCount; i++)
// {
// if (parent.GetChild(i).name.ToLower().Contains("_floor")
// || parent.GetChild(i).name.ToLower().Contains("-floor")
// )
// {
// return parent.GetChild(i);
// }
// }
// return parent;
//}
//[MenuItem("SceneTool/SetNavLayershinei")]//添加寻路层(选中shinei对象设置,注:扶梯情况特殊没有包含)
//public static void SetNavLayer()
//{
// Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
// for (int i = 0; i < obj.Length; i++)
// {
// if (obj[i].name.ToLower().Contains("_floor") ||//地面
// obj[i].name.ToLower().Contains("_floor"))
// {
// Debug.Log(obj[i].name);
// // obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad");
// // if (!obj[i].gameObject.GetComponent<MeshCollider>())
// // {
// // obj[i].gameObject.AddComponent<MeshCollider>();
// // }
// // if (!obj[i].gameObject.GetComponent<PathFindable>())
// // {
// // obj[i].gameObject.AddComponent<PathFindable>();
// // }
// // if (!obj[i].gameObject.GetComponent<CloneGameObjInfo>())
// // {
// // obj[i].gameObject.AddComponent<CloneGameObjInfo>();
// obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType=CloneObjType.staticGameObject;
// // }
// // if (!obj[i].gameObject.GetComponent<CloneableEnums>())
// // {
// // obj[i].gameObject.AddComponent<CloneableEnums>();
// // }
// // CloneableEnums enumParent = obj[i].gameObject.GetComponent<CloneableEnums>();
// // GameObject CarRoad = GameObject.Find("FloorNei");
// // var CloneableEnums = CarRoad.GetComponent<CloneableEnums>();
// // enumParent.CloneableTypes = CloneableEnums.CloneableTypes;
// // if (obj[i].parent.GetComponent<FloorMessage>())
// // {
// // FloorMessage fmg = obj[i].parent.GetComponent<FloorMessage>();
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject;
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum;
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum;
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum;
// // }
// // if (obj[i].parent.parent.GetComponent<FloorMessage>())
// // {
// // FloorMessage fmg = obj[i].parent.parent.GetComponent<FloorMessage>();
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().gameObjType = CloneObjType.StaticGameObject;
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().buildNum = fmg.buildNum;
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().floorNum = fmg.floorNum;
// // obj[i].gameObject.GetComponent<CloneGameObjInfo>().interlayerNum = fmg.interlayerNum;
// // }
// //}
// //if (obj[i].name.ToLower().Contains("_wall") ||//墙面
// // obj[i].name.ToLower().Contains("_wall"))
// //{
// // obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad");
// // if (!obj[i].gameObject.GetComponent<NavMeshModifier>())
// // {
// // obj[i].gameObject.AddComponent<NavMeshModifier>();
// // }
// // NavMeshModifier mod = obj[i].gameObject.GetComponent<NavMeshModifier>();
// // mod.overrideArea = true;
// // mod.area = 1;
// // if (!obj[i].gameObject.GetComponent<MeshCollider>())
// // {
// // obj[i].gameObject.AddComponent<MeshCollider>();
// // }
// //}
// //if (obj[i].name.ToLower().Contains("lt"))//楼梯
// //{
// // obj[i].gameObject.layer = LayerMask.NameToLayer("SoldierRoad");
// // if (!obj[i].gameObject.GetComponent<MeshCollider>())
// // {
// // obj[i].gameObject.AddComponent<MeshCollider>();
// // }
// // if (!obj[i].gameObject.GetComponent<PathFindable>())
// // {
// // obj[i].gameObject.AddComponent<PathFindable>();
// // }
// }
// }
//}
//[MenuItem("SceneTool/GetNavLayerCarRoad")]
//public static void GetNavLayerCarRoad()
//{
// Transform[] obj = Selection.GetTransforms(SelectionMode.Deep);
// {
// for (int i = 0; i < obj.Length; i++)
// {
// if (obj[i].gameObject.layer == LayerMask.NameToLayer("CarRoad"))
// {
// // if (!obj[i].gameObject.GetComponent<NavMeshModifier>())
// {
// Debug.Log(obj[i].name);
// }
// }
// }
// }
//}
//[MenuItem("SceneTool/ReadCloneTypes")]
//static void ReadCloneTypes()
//{
// string path = Application.dataPath + "/Floors.txt";
// string str = File.ReadAllText(path, Encoding.UTF8);
// string[] EnumStrList = str.Split(',');
// //List<CloneObjType> EnmuList = new List<CloneObjType>();
// //foreach (var item in EnumStrList)
// //{
// // if (!string.IsNullOrEmpty(item))
// // {
// // CloneObjType type = (CloneObjType)Enum.Parse(typeof(CloneObjType), item);
// // EnmuList.Add(type);
// // }
// //}
// //GameObject CarRoad = GameObject.Find("FloorNei");
// //if (!CarRoad.GetComponent<CloneableEnums>())
// //{
// // CarRoad.AddComponent<CloneableEnums>();
// //}
// //var CloneableEnums = CarRoad.GetComponent<CloneableEnums>();
// //CloneableEnums.CloneableTypes = EnmuList;
//}
//[MenuItem("SceneTool/AddColider")]
//static void AddColider()
//{
// Transform[] obj = Selection.GetTransforms(SelectionMode.Unfiltered);
// {
// Debug.Log(obj[0].name);
// }
//}
}

11
Assets/Editor/SceneToolFloor.cs.meta

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

BIN
Assets/Plugins/SmartX1AppX64.dll

Binary file not shown.

27
Assets/Plugins/SmartX1AppX64.dll.meta

@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 5ca7162f4ce085947800aa96363b3551
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Plugins/System.Security.dll

Binary file not shown.

33
Assets/Plugins/System.Security.dll.meta

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 42d3b95abd582bc42afe2646828af763
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Plugins/x86_64.meta

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

BIN
Assets/Plugins/x86_64/SmartX1App.dll

Binary file not shown.

136
Assets/Plugins/x86_64/SmartX1App.dll.meta

@ -0,0 +1,136 @@
fileFormatVersion: 2
guid: b4224153725ef6e468efeab33ad7e553
timeCreated: 1515718354
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 0
Exclude Win: 1
Exclude Win64: 1
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: Windows
data:
first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 1
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 1
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: None
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:

43
Assets/Prefabs/Common/DisasterLibrary/DissaterSetting.prefab

@ -1498,7 +1498,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &224479387984022046
RectTransform:
m_ObjectHideFlags: 0
@ -2557,8 +2557,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 320}
m_AnchoredPosition: {x: 0.00006380459, y: 0.00003049684}
m_SizeDelta: {x: 0, y: 240}
m_Pivot: {x: 0, y: 1}
--- !u!114 &114792364379617722
MonoBehaviour:
@ -7425,7 +7425,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 180, y: 0, z: 180}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 265, y: -200}
m_AnchoredPosition: {x: 53, y: -200}
m_SizeDelta: {x: 106, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &114077331183161620
@ -8106,7 +8106,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &224453689643152912
RectTransform:
m_ObjectHideFlags: 0
@ -11604,7 +11604,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 180, y: 0, z: 180}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 159, y: -200}
m_AnchoredPosition: {x: 265, y: -120}
m_SizeDelta: {x: 106, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &114828467249771398
@ -15825,7 +15825,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 180, y: 0, z: 180}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 53, y: -200}
m_AnchoredPosition: {x: 159, y: -120}
m_SizeDelta: {x: 106, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &114666889020222772
@ -18188,7 +18188,7 @@ RectTransform:
m_Father: {fileID: 224146768237282860}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.9999999}
m_AnchorMin: {x: 0, y: 0.99999946}
m_AnchorMax: {x: 1, y: 0.9999999}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 20}
@ -19439,7 +19439,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 180, y: 0, z: 180}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 53, y: -280}
m_AnchoredPosition: {x: 159, y: -200}
m_SizeDelta: {x: 106, y: 80}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &114620266658905952
@ -25426,6 +25426,31 @@ PrefabInstance:
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 8509549370938670763, guid: f35e203b6f844c3458c5337e1bbc09c7,
type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 8509549370938670763, guid: f35e203b6f844c3458c5337e1bbc09c7,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8508462630750896635, guid: f35e203b6f844c3458c5337e1bbc09c7,
type: 3}
propertyPath: m_AnchorMin.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 8508462630750896635, guid: f35e203b6f844c3458c5337e1bbc09c7,
type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 8508462630750896635, guid: f35e203b6f844c3458c5337e1bbc09c7,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f35e203b6f844c3458c5337e1bbc09c7, type: 3}
--- !u!224 &224104126818797746 stripped

194
Assets/Scenes/DummyScene.unity

@ -13,7 +13,7 @@ OcclusionCullingSettings:
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 8
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
@ -39,26 +39,25 @@ RenderSettings:
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 8
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
@ -71,23 +70,26 @@ LightmapSettings:
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 3
m_MixedBakeMode: 2
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 0}
m_ShadowMaskMode: 2
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
@ -107,13 +109,16 @@ NavMeshSettings:
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &340961646
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 340961648}
- component: {fileID: 340961647}
@ -127,8 +132,9 @@ GameObject:
--- !u!114 &340961647
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 340961646}
m_Enabled: 1
m_EditorHideFlags: 0
@ -138,8 +144,9 @@ MonoBehaviour:
--- !u!4 &340961648
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 340961646}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
@ -148,12 +155,56 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &546100755
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 546100757}
- component: {fileID: 546100756}
m_Layer: 0
m_Name: SmartX1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &546100756
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 546100755}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae7ba88dc2eb0ac428673f57e7adae5e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &546100757
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 546100755}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -94.06678, y: 0.23535156, z: 32.006668}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1100379995
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1100379997}
- component: {fileID: 1100379996}
@ -167,8 +218,9 @@ GameObject:
--- !u!108 &1100379996
Light:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1100379995}
m_Enabled: 1
serializedVersion: 8
@ -194,6 +246,7 @@ Light:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
@ -203,8 +256,9 @@ Light:
--- !u!4 &1100379997
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1100379995}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
@ -216,9 +270,10 @@ Transform:
--- !u!1 &1480189306
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1480189307}
- component: {fileID: 1480189308}
@ -234,8 +289,9 @@ GameObject:
--- !u!4 &1480189307
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480189306}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 564.5, y: 379.28125, z: 0}
@ -247,8 +303,9 @@ Transform:
--- !u!114 &1480189308
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480189306}
m_Enabled: 1
m_EditorHideFlags: 0
@ -258,8 +315,9 @@ MonoBehaviour:
--- !u!114 &1480189309
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480189306}
m_Enabled: 1
m_EditorHideFlags: 0
@ -269,8 +327,9 @@ MonoBehaviour:
--- !u!114 &1480189310
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1480189306}
m_Enabled: 1
m_EditorHideFlags: 0
@ -280,9 +339,10 @@ MonoBehaviour:
--- !u!1 &1699723576
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1699723578}
- component: {fileID: 1699723577}
@ -296,8 +356,9 @@ GameObject:
--- !u!114 &1699723577
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1699723576}
m_Enabled: 1
m_EditorHideFlags: 0
@ -307,8 +368,9 @@ MonoBehaviour:
--- !u!4 &1699723578
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1699723576}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 564.5, y: 379.28125, z: 0}
@ -320,9 +382,10 @@ Transform:
--- !u!1 &1970330119
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1970330124}
- component: {fileID: 1970330123}
@ -340,34 +403,43 @@ GameObject:
--- !u!81 &1970330120
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1970330119}
m_Enabled: 1
--- !u!124 &1970330121
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1970330119}
m_Enabled: 1
--- !u!92 &1970330122
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1970330119}
m_Enabled: 1
--- !u!20 &1970330123
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1970330119}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
@ -389,16 +461,17 @@ Camera:
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!4 &1970330124
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1970330119}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
@ -410,8 +483,9 @@ Transform:
--- !u!114 &1970330125
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1970330119}
m_Enabled: 1
m_EditorHideFlags: 0

8
Assets/Scripts/SmartX1.meta

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

275
Assets/Scripts/SmartX1/SmartApp.cs

@ -0,0 +1,275 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SmartX1Demo
{
public class SmartApp
{
bool _is64ibt = false;
public SmartApp()
{
if (IntPtr.Size == 4)
_is64ibt = true;
}
public int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1Find(appID, keyHandles, keyNumber);
}
else
{
return SmartX1_X64.SmartX1Find(appID, keyHandles, keyNumber);
}
}
//open
public int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4);
}
else
{
return SmartX1_X64.SmartX1Open(keyHandle, uPin1, uPin2, uPin3, uPin4);
}
}
//close
public int SmartX1Close(int keyHandle)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1Close(keyHandle);
}
else
{
return SmartX1_X64.SmartX1Close(keyHandle);
}
}
//checkExist
public int SmartX1CheckExist(int keyHandle)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1CheckExist(keyHandle);
}
else
{
return SmartX1_X64.SmartX1CheckExist(keyHandle);
}
}
//getUid
public int SmartX1GetUid(int keyHandle, StringBuilder uid)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1GetUid(keyHandle, uid);
}
else
{
return SmartX1_X64.SmartX1GetUid(keyHandle, uid);
}
}
//ReadStorage
public int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1ReadStorage(keyHandle, startAddr, length, pBuffer);
}
else
{
return SmartX1_X64.SmartX1ReadStorage(keyHandle, startAddr, length, pBuffer);
}
}
//WriteStorage
public int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1WriteStorage(keyHandle, startAddr, length, pBuffer);
}
else
{
return SmartX1_X64.SmartX1WriteStorage(keyHandle, startAddr, length, pBuffer);
}
}
//PageLogin
public int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1PageLogin(keyHandle, pageNo, password, length);
}
else
{
return SmartX1_X64.SmartX1PageLogin(keyHandle, pageNo, password, length);
}
}
//PageLogout
public int SmartX1PageLogout(int keyHandle, int pageNo)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1PageLogout(keyHandle, pageNo);
}
else
{
return SmartX1_X64.SmartX1PageLogout(keyHandle, pageNo);
}
}
//ReadPage
public int SmartX1ReadPage(int keyHandle, int pageNo, int startAddr, ref int length, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1ReadPage(keyHandle, pageNo, startAddr, ref length, pBuffer);
}
else
{
return SmartX1_X64.SmartX1ReadPage(keyHandle, pageNo, startAddr, ref length, pBuffer);
}
}
//WritePage
public int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1WritePage(keyHandle, pageNo, startAddr, length, pBuffer);
}
else
{
return SmartX1_X64.SmartX1WritePage(keyHandle, pageNo, startAddr, length, pBuffer);
}
}
//ReadMem
public int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1ReadMem(keyHandle, start, length, pBuffer);
}
else
{
return SmartX1_X64.SmartX1ReadMem(keyHandle, start, length, pBuffer);
}
}
//WriteMem
public int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1WriteMem( keyHandle, start, length, pBuffer);
}
else
{
return SmartX1_X64.SmartX1WriteMem(keyHandle, start, length, pBuffer);
}
}
//encrypt
public int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1TriDesEncrypt(keyHandle, buffSize, pBuffer);
}
else
{
return SmartX1_X64.SmartX1TriDesEncrypt(keyHandle, buffSize, pBuffer);
}
}
//desDecrypt
public int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1TriDesDecrypt(keyHandle, buffSize, pBuffer);
}
else
{
return SmartX1_X64.SmartX1TriDesDecrypt(keyHandle, buffSize, pBuffer);
}
}
//led
public int SmartX1Led(int keyHandle, int state)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1Led(keyHandle, state);
}
else
{
return SmartX1_X64.SmartX1Led(keyHandle, state);
}
}
public int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1PageGetProperty(keyHandle, pageNo, propId, propValue);
}
else
{
return SmartX1_X64.SmartX1PageGetProperty(keyHandle, pageNo, propId, propValue);
}
}
public int SmartX1GetSoftVersion(int keyHandle, int[] version)
{
if (_is64ibt)
{
return SmartX1_X86.SmartX1GetSoftVersion(keyHandle, version);
}
else
{
return SmartX1_X64.SmartX1GetSoftVersion(keyHandle, version);
}
}
public string TridesEncrypt(string data, string key, Encoding encoding)
{
if (_is64ibt)
{
return SmartX1_X86.TridesEncrypt(data, key, encoding);
}
else
{
return SmartX1_X64.TridesEncrypt(data, key, encoding);
}
}
public string TridesDecEncrypt(byte[] data, string key, Encoding encoding)
{
if (_is64ibt)
{
return SmartX1_X86.TridesDecEncrypt(data, key, encoding);
}
else
{
return SmartX1_X64.TridesDecEncrypt(data, key, encoding);
}
}
}
}

11
Assets/Scripts/SmartX1/SmartApp.cs.meta

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

280
Assets/Scripts/SmartX1/SmartController.cs

@ -0,0 +1,280 @@
using UnityEngine;
using System;
using System.Xml;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.Xml;
using System.Collections;
using SmartX1Demo;
public class SmartController : MonoBehaviour
{
int[] keyHandles = new int[8];
int[] keyNumber = new int[8];
private int Rtn = 0;
SmartApp smart = new SmartApp();
private bool IsQuit = false;
private DateTime t1, t2, t11;
void Start()
{
t2 = DateTime.Now;
t1 = DateTime.Now;
DontDestroyOnLoad(GameObject.Find("SmartX1"));
tipStyle = new GUIStyle();
tipStyle.fontSize = 40;
tipStyle.normal.textColor = Color.red;
original_filepath = Application.streamingAssetsPath + @"/xml/SmartXProject.xml";
encode_filepath = Application.streamingAssetsPath + @"/xml/enSmartXProject.xml";
decode_filepath = Application.streamingAssetsPath + @"/xml/deSmartXProject.xml";
original_filepath2 = Application.streamingAssetsPath + @"/xml/SmartXProject2.xml";
encode_filepath2 = Application.streamingAssetsPath + @"/xml/enSmartXProject2.xml";
decode_filepath2 = Application.streamingAssetsPath + @"/xml/deSmartXProject2.xml";
appid = ControlXML(original_filepath, encode_filepath, decode_filepath);
appid2 = ControlXML(original_filepath2, encode_filepath2, decode_filepath2);
//appid = GetAppID(original_filepath);
//检测加密狗是否存在
FindSmartX1();
}
string appid = "AXKC";
string appid2 = "YuAnguanli";
public string GetAppID(string filepath)
{
//filepath = Application.dataPath + @"/xml/SmartXProject.xml";
if (File.Exists(filepath))
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filepath);
XmlNode root = xmlDoc.SelectSingleNode("SmartX1");
XmlNodeList nodeList = root.ChildNodes;
foreach (XmlElement elem in nodeList)
{
if (elem.Name == "BaseInfo")
{
foreach (XmlElement zq in elem.ChildNodes)
{
if (zq.Name == "AppID")
{
return zq.InnerText;
}
}
}
}
}
return "";
}
void FindSmartX1()
{
try
{
Rtn = smart.SmartX1Find(appid, keyHandles, keyNumber);
if (Rtn == 0)
{
return;
}
Rtn = smart.SmartX1Find(appid2, keyHandles, keyNumber);
if (Rtn == 0)
{
return;
}
IsQuit = true;
t1 = DateTime.Now;
t2 = DateTime.Now;
t11 = DateTime.Now;
}
catch (Exception ex)
{
Debug.Log("异常" + ex.Message);
Application.Quit();
}
}
void CheckExist()
{
try
{
Rtn = smart.SmartX1CheckExist(keyHandles[0]);
if (Rtn != 0)
{
IsQuit = true;
}
if (IsQuit)
{
t1 = DateTime.Now;
t2 = DateTime.Now;
t11 = DateTime.Now;
}
}
catch (Exception ex)
{
Debug.Log("异常" + ex.Message);
Application.Quit();
}
}
private GUIStyle tipStyle;
private int timer = 5;
void OnGUI()
{
if (IsQuit)
{
t2 = DateTime.Now;
if (t2 - t11 > new TimeSpan(0, 0, 1))
{
if (timer > 0)
timer--;
t11 = t2;
}
GUI.Label(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 75, 300, 150), "密钥验证失败,程序将在" + timer + "秒后退出!", tipStyle);
if (t2 - t1 > new TimeSpan(0, 0, 5))
{
Debug.Log("程序退出!");
Application.Quit();
}
}
}
// Update is called once per frame
void Update()
{
if (IsQuit)
return;
t2 = DateTime.Now;
if (t2 - t1 > new TimeSpan(0, 0, 0, 10, 0))
{
t1 = t2;
CheckExist();
}
}
//xml文件加密解密
string ControlXML(string originalFile, string encodeFile, string decodeFile)
{
var id = "";
if (File.Exists(originalFile))//证明这次是第一次运行该程序,获取当前配置文件
{
id = GetAppID(originalFile);
fileEncryption(originalFile, encodeFile);
if (File.Exists(encodeFile))
{
File.Delete(originalFile);
}
}
else
{
if (File.Exists(encodeFile))
{
fileDcryption(encodeFile, decodeFile);
if (File.Exists(decodeFile))
{
id = GetAppID(decodeFile);
File.Delete(decodeFile);
}
}
}
//Debug.Log("--------->" + id);
return id;
}
//加密xml文件
private void Encrypt(XmlDocument doc, string ElementName, SymmetricAlgorithm key)
{
XmlElement elementEncrypt = doc.GetElementsByTagName(ElementName)[0] as XmlElement;
EncryptedXml eXml = new EncryptedXml();
byte[] encryptElement = eXml.EncryptData(elementEncrypt, key, false);//
EncryptedData edElement = new EncryptedData();
edElement.Type = EncryptedXml.XmlEncElementUrl;
string encryptionMethod = null;
if (key is TripleDES)
{
encryptionMethod = EncryptedXml.XmlEncTripleDESUrl;
}
else if (key is DES)
{
encryptionMethod = EncryptedXml.XmlEncDESUrl;
}
if (key is Rijndael)
{
switch (key.KeySize)
{
case 128:
encryptionMethod = EncryptedXml.XmlEncAES128Url;
break;
case 192:
encryptionMethod = EncryptedXml.XmlEncAES192Url;
break;
case 256:
encryptionMethod = EncryptedXml.XmlEncAES256Url;
break;
}
}
edElement.EncryptionMethod = new EncryptionMethod(encryptionMethod);
edElement.CipherData.CipherValue = encryptElement;
EncryptedXml.ReplaceElement(elementEncrypt, edElement, false);
}
//XML文件解密
private void Decrypt(XmlDocument doc, SymmetricAlgorithm Alg)
{
XmlElement encryptedElement = doc.GetElementsByTagName("EncryptedData")[0] as XmlElement;
EncryptedData edElement = new EncryptedData();
edElement.LoadXml(encryptedElement);
EncryptedXml exml = new EncryptedXml();
byte[] rgbOutput = exml.DecryptData(edElement, Alg);
exml.ReplaceData(encryptedElement, rgbOutput);
}
string original_filepath = "";
string encode_filepath = "";
string decode_filepath = "";
string original_filepath2 = "";
string encode_filepath2 = "";
string decode_filepath2 = "";
//举例,对某个XML文件加密
private void fileEncryption(string originalFile, string encodeFile)
{
RijndaelManaged key = new RijndaelManaged();
//设置密钥:key为32位=数字或字母16个=汉子8个
byte[] byteKey = Encoding.Unicode.GetBytes("1111111111111111");
key.Key = byteKey;
XmlDocument xmldoc = new XmlDocument();
xmldoc.PreserveWhitespace = true;
xmldoc.Load(originalFile);//想要加密的xml文件
Encrypt(xmldoc, "SmartX1", key);//需要加密的节点
if (key != null)
{
key.Clear();
}
xmldoc.Save(encodeFile);//生成加密后的xml文件
}
//举例,对某个xml文件解密
private void fileDcryption(string encodeFile, string decodeFile)
{
RijndaelManaged key = new RijndaelManaged();
byte[] byteKey = Encoding.Unicode.GetBytes("1111111111111111");
key.Key = byteKey;
XmlDocument xmldoc = new XmlDocument();
xmldoc.PreserveWhitespace = true;
xmldoc.Load(encodeFile);//加载要解密的xml文件
Decrypt(xmldoc, key);
if (key != null)
{
key.Clear();
}
xmldoc.Save(decodeFile);//生成解密后的文件
}
}

11
Assets/Scripts/SmartX1/SmartController.cs.meta

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

214
Assets/Scripts/SmartX1/SmartX1Api.cs

@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
namespace SmartX1Demo
{
public class SmartX1_X86
{
//注意不要添加.dll后缀
// Find
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber);
//open
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4);
//close
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Close(int keyHandle);
//checkExist
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1CheckExist(int keyHandle);
//getUid
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1GetUid(int keyHandle, StringBuilder uid);
//ReadStorage
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
//WriteStorage
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
//PageLogin
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length);
//PageLogout
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageLogout(int keyHandle, int pageNo);
//ReadPage
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadPage(int keyHandle, int pageNo, int startAddr, ref int length, byte[] pBuffer);
//WritePage
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer);
//ReadMem
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer);
//WriteMem
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer);
//encrypt
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer);
//desDecrypt
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer);
//led
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Led(int keyHandle, int state);
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue);
[DllImport("SmartX1App", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1GetSoftVersion(int keyHandle, int[] version);
public static string TridesEncrypt(string data, string key, Encoding encoding)
{
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
des.Key = Encoding.Default.GetBytes(key);
des.Mode = CipherMode.ECB;
des.Padding = PaddingMode.PKCS7;
ICryptoTransform DesEncrypt = des.CreateEncryptor();
byte[] dataBytes = encoding.GetBytes(data);
byte[] outPut = DesEncrypt.TransformFinalBlock(dataBytes, 0, dataBytes.Length);
return Convert.ToBase64String(outPut);
}
public static string TridesDecEncrypt(byte[] data, string key, Encoding encoding)
{
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
des.Key = Encoding.Default.GetBytes(key);
des.Padding = PaddingMode.PKCS7;
des.Mode = CipherMode.ECB;
ICryptoTransform DesDecEncrypt = des.CreateDecryptor();
byte[] outValue = DesDecEncrypt.TransformFinalBlock(data, 0, data.Length);
return encoding.GetString(outValue);
}
}
class SmartX1_X64
{
// Find
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Find(string appID, int[] keyHandles, int[] keyNumber);
//open
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Open(int keyHandle, int uPin1, int uPin2, int uPin3, int uPin4);
//close
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Close(int keyHandle);
//checkExist
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1CheckExist(int keyHandle);
//getUid
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1GetUid(int keyHandle, StringBuilder uid);
//ReadStorage
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
//WriteStorage
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WriteStorage(int keyHandle, int startAddr, int length, byte[] pBuffer);
//PageLogin
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageLogin(int keyHandle, int pageNo, byte[] password, int length);
//PageLogout
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageLogout(int keyHandle, int pageNo);
//ReadPage
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadPage(int keyHandle, int pageNo, int startAddr, ref int length, byte[] pBuffer);
//WritePage
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WritePage(int keyHandle, int pageNo, int startAddr, int length, byte[] pBuffer);
//ReadMem
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1ReadMem(int keyHandle, int start, int length, byte[] pBuffer);
//WriteMem
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1WriteMem(int keyHandle, int start, int length, byte[] pBuffer);
//encrypt
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1TriDesEncrypt(int keyHandle, int buffSize, byte[] pBuffer);
//desDecrypt
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1TriDesDecrypt(int keyHandle, int buffSize, byte[] pBuffer);
//led
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1Led(int keyHandle, int state);
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1PageGetProperty(int keyHandle, int pageNo, int propId, int[] propValue);
[DllImport("SmartX1AppX64", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int SmartX1GetSoftVersion(int keyHandle, int[] version);
public static string TridesEncrypt(string data, string key, Encoding encoding)
{
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
des.Key = Encoding.Default.GetBytes(key);
des.Mode = CipherMode.ECB;
des.Padding = PaddingMode.PKCS7;
ICryptoTransform DesEncrypt = des.CreateEncryptor();
byte[] dataBytes = encoding.GetBytes(data);
byte[] outPut = DesEncrypt.TransformFinalBlock(dataBytes, 0, dataBytes.Length);
return Convert.ToBase64String(outPut);
}
public static string TridesDecEncrypt(byte[] data, string key, Encoding encoding)
{
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
des.Key = Encoding.Default.GetBytes(key);
des.Padding = PaddingMode.PKCS7;
des.Mode = CipherMode.ECB;
ICryptoTransform DesDecEncrypt = des.CreateDecryptor();
byte[] outValue = DesDecEncrypt.TransformFinalBlock(data, 0, data.Length);
return encoding.GetString(outValue);
}
}
}

11
Assets/Scripts/SmartX1/SmartX1Api.cs.meta

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

8
Assets/StreamingAssets/xml.meta

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

2
Assets/StreamingAssets/xml/enSmartXProject.xml

File diff suppressed because one or more lines are too long

7
Assets/StreamingAssets/xml/enSmartXProject.xml.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e7af0c1bd47c22b47b39ec0c647de44f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save