|
8 | 8 | using System.Text;
|
9 | 9 | using Newtonsoft.Json;
|
10 | 10 | using LootLocker.LootLockerEnums;
|
| 11 | +using static LootLocker.LootLockerConfig; |
11 | 12 |
|
12 | 13 | namespace LootLocker.Requests
|
13 | 14 | {
|
| 15 | + |
14 | 16 | public partial class LootLockerSDKManager
|
15 | 17 | {
|
16 | 18 | #region Init
|
17 | 19 |
|
18 | 20 | static bool initialized;
|
19 |
| - public static bool Init() |
| 21 | + static bool Init() |
20 | 22 | {
|
21 | 23 | DebugMessage("SDK is Intializing");
|
22 | 24 | LootLockerServerManager.CheckInit();
|
23 | 25 | return LoadConfig();
|
24 | 26 | }
|
25 | 27 |
|
| 28 | + public static bool Init(string apiKey, string gameVersion, platformType platform, bool onDevelopmentMode) |
| 29 | + { |
| 30 | + DebugMessage("SDK is Intializing"); |
| 31 | + LootLockerServerManager.CheckInit(); |
| 32 | + return LootLockerConfig.CreateNewSettings(apiKey, gameVersion, platform, onDevelopmentMode); |
| 33 | + } |
| 34 | + |
26 | 35 | static bool LoadConfig()
|
27 | 36 | {
|
28 | 37 | initialized = true;
|
| 38 | + if (LootLockerConfig.current == null) |
| 39 | + { |
| 40 | + Debug.LogError("SDK could not find settings, please contact support \n You can also set config manually by calling init"); |
| 41 | + return false; |
| 42 | + } |
29 | 43 | if (string.IsNullOrEmpty(LootLockerConfig.current.apiKey))
|
30 | 44 | {
|
31 | 45 | DebugMessage("Key has not been set, Please login to sdk manager or set key manually and then try again");
|
32 | 46 | initialized = false;
|
33 | 47 | return false;
|
34 | 48 | }
|
35 | 49 |
|
| 50 | + |
36 | 51 | return initialized;
|
37 | 52 | }
|
38 | 53 |
|
@@ -78,21 +93,49 @@ public static void DebugMessage(string message, bool IsError = false)
|
78 | 93 | #region Authentication
|
79 | 94 | public static void VerifySteamID(string steamSessionTicket, Action<LootLockerVerifyResponse> onComplete)
|
80 | 95 | {
|
81 |
| - if (!CheckInitialized()) return; |
| 96 | + if (!CheckInitialized()) |
| 97 | + { |
| 98 | + LootLockerVerifyResponse response = new LootLockerVerifyResponse(); |
| 99 | + response.success = false; |
| 100 | + response.hasError = true; |
| 101 | + response.Error = "SDk not initialised"; |
| 102 | + response.text = "SDk not initialised"; |
| 103 | + onComplete?.Invoke(response); |
| 104 | + return; |
| 105 | + } |
82 | 106 | LootLockerVerifyRequest verifyRequest = new LootLockerVerifyRequest(steamSessionTicket);
|
83 | 107 | LootLockerAPIManager.Verify(verifyRequest, onComplete);
|
84 | 108 | }
|
85 | 109 |
|
86 | 110 | public static void VerifyID(string deviceId, Action<LootLockerVerifyResponse> onComplete)
|
87 | 111 | {
|
88 |
| - if (!CheckInitialized()) return; |
| 112 | + if (!CheckInitialized()) |
| 113 | + { |
| 114 | + LootLockerVerifyResponse response = new LootLockerVerifyResponse(); |
| 115 | + response.success = false; |
| 116 | + response.hasError = true; |
| 117 | + response.Error = "SDk not initialised"; |
| 118 | + response.text = "SDk not initialised"; |
| 119 | + onComplete?.Invoke(response); |
| 120 | + return; |
| 121 | + } |
89 | 122 | LootLockerVerifyRequest verifyRequest = new LootLockerVerifyRequest(deviceId);
|
90 | 123 | LootLockerAPIManager.Verify(verifyRequest, onComplete);
|
91 | 124 | }
|
92 | 125 |
|
93 | 126 | public static void StartSession(string deviceId, Action<LootLockerSessionResponse> onComplete)
|
94 | 127 | {
|
95 |
| - if (!CheckInitialized()) return; |
| 128 | + if (!CheckInitialized()) |
| 129 | + { |
| 130 | + LootLockerSessionResponse response = new LootLockerSessionResponse(); |
| 131 | + response.success = false; |
| 132 | + response.status = false; |
| 133 | + response.hasError = true; |
| 134 | + response.Error = "SDk not initialised"; |
| 135 | + response.text = "SDk not initialised"; |
| 136 | + onComplete?.Invoke(response); |
| 137 | + return; |
| 138 | + } |
96 | 139 | LootLockerConfig.current.deviceID = deviceId;
|
97 | 140 | LootLockerSessionRequest sessionRequest = new LootLockerSessionRequest(deviceId);
|
98 | 141 | LootLockerAPIManager.Session(sessionRequest, onComplete);
|
@@ -938,7 +981,7 @@ public static void PickDropsFromDropTable(int[] picks, int tableId, Action<LootL
|
938 | 981 | PickDropsFromDropTableRequest data = new PickDropsFromDropTableRequest();
|
939 | 982 | data.picks = picks;
|
940 | 983 |
|
941 |
| - LootLockerAPIManager.PickDropsFromDropTable(data,tableId, onComplete); |
| 984 | + LootLockerAPIManager.PickDropsFromDropTable(data, tableId, onComplete); |
942 | 985 | }
|
943 | 986 | #endregion
|
944 | 987 | }
|
|
0 commit comments