Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Text;
- using System.Text.RegularExpressions;
- using TGlib;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- namespace FullVersion
- {
- // Token: 0x020000D0 RID: 208
- public class FullVerMgr : BaseObject
- {
- // Token: 0x0600052A RID: 1322 RVA: 0x00051F95 File Offset: 0x00050395
- protected override void Awake()
- {
- base.Awake();
- g.full_ver_mgr = this;
- this.file_path = Application.persistentDataPath + "/at5_full_ver.dat";
- this.CheckSavedFullVerState(FullVerMgr.CHECK_STATE.START_GAME);
- }
- // Token: 0x0600052B RID: 1323 RVA: 0x00051FBF File Offset: 0x000503BF
- public void ConsumeFullVerTest()
- {
- }
- // Token: 0x0600052C RID: 1324 RVA: 0x00051FC1 File Offset: 0x000503C1
- public void CheckSavedFullVerState(FullVerMgr.CHECK_STATE state)
- {
- this.check_state = state;
- this.loadConnectingVC();
- this.GetDeviceInfo();
- }
- // Token: 0x0600052D RID: 1325 RVA: 0x00051FD8 File Offset: 0x000503D8
- private void CheckSavedFullVerFile()
- {
- if (File.Exists(this.file_path))
- {
- this.VerifyEncodedKey();
- }
- else
- {
- this.gl.FullVersion = 0;
- if (!this.file_checked && (SceneManager.GetActiveScene().name.Equals("Title") || SceneManager.GetActiveScene().name.Equals("CompanyLogo")))
- {
- this.closeConnectingVC();
- GameObject gameObject = GameObject.Find("TitleVC");
- if (gameObject != null)
- {
- gameObject.GetComponent<TitleManager>().ShowFullButton(true);
- }
- }
- else
- {
- this.CheckNetworkState();
- }
- this.file_checked = true;
- }
- }
- // Token: 0x0600052E RID: 1326 RVA: 0x0005208A File Offset: 0x0005048A
- private void CheckNetworkState()
- {
- AndroidManager.curActivity.Call("javaNetworkState", new object[]
- {
- 0
- });
- }
- // Token: 0x0600052F RID: 1327 RVA: 0x000520AA File Offset: 0x000504AA
- private void GetDeviceInfo()
- {
- AndroidManager.curActivity.Call("javaGetDeviceInfo", new object[0]);
- }
- // Token: 0x06000530 RID: 1328 RVA: 0x000520C1 File Offset: 0x000504C1
- private void CheckGoogleAccountFullVer()
- {
- AndroidManager.curActivity.Call("javaCheckFullVerState", new object[0]);
- }
- // Token: 0x06000531 RID: 1329 RVA: 0x000520D8 File Offset: 0x000504D8
- private void UpgradeFullVer()
- {
- AndroidManager.curActivity.Call("javaUpgradeFullVer", new object[0]);
- }
- // Token: 0x06000532 RID: 1330 RVA: 0x000520F0 File Offset: 0x000504F0
- public void NetworkState(string _state)
- {
- if (int.Parse(_state) == 0)
- {
- this.closeConnectingVC();
- base.showMessageBox(2, 80);
- }
- else
- {
- this.www_timeout = 10f;
- this.request_idx = FullVerMgr.REQUEST.CHECK_VERSION_0;
- this.RequestToServer("version.php", string.Empty);
- }
- }
- // Token: 0x06000533 RID: 1331 RVA: 0x00052140 File Offset: 0x00050540
- public void DeviceInfo(string data)
- {
- if (data == null)
- {
- this.closeConnectingVC();
- return;
- }
- this.device_id = data;
- this.CheckSavedFullVerFile();
- }
- // Token: 0x06000534 RID: 1332 RVA: 0x0005215C File Offset: 0x0005055C
- public void FullVerState(string _state)
- {
- this.closeConnectingVC();
- if (int.Parse(_state) == 0)
- {
- base.showMessageBox(3, 241);
- }
- else
- {
- this.www_timeout = 10f;
- this.full_ver_random_id = this.GenerateRandomID(50);
- string body = string.Format("{0}` {1}", this.full_ver_random_id, this.device_id);
- this.request_idx = FullVerMgr.REQUEST.GENERATE_FULL_VER_CODE;
- this.RequestToServer("in_app/generate_full_ver_code.php", body);
- }
- }
- // Token: 0x06000535 RID: 1333 RVA: 0x000521D0 File Offset: 0x000505D0
- public void PurchasedTransaction(string data)
- {
- this.closeConnectingVC();
- string[] array = Regex.Split(data, "` ");
- if (array.Length != 3)
- {
- return;
- }
- this.www_timeout = 15f;
- string text = array[0];
- string text2 = array[1];
- string text3 = array[2];
- this.full_ver_random_id = this.GenerateRandomID(50);
- string body = string.Format("{0}` {1}` {2}` {3}` {4}", new object[]
- {
- this.full_ver_random_id,
- this.device_id,
- text,
- text2,
- text3
- });
- this.request_idx = FullVerMgr.REQUEST.VERIFY_RECEIPT;
- this.RequestToServer("in_app/verify_receipt_full_ver.php", body);
- }
- // Token: 0x06000536 RID: 1334 RVA: 0x00052262 File Offset: 0x00050662
- public void FailedTransaction()
- {
- base.showDelayMessageBox(2, 84, null, false);
- this.closeConnectingVC();
- }
- // Token: 0x06000537 RID: 1335 RVA: 0x00052275 File Offset: 0x00050675
- public void FailedFullVerState()
- {
- this.gl.FullVersion = 0;
- this.closeConnectingVC();
- }
- // Token: 0x06000538 RID: 1336 RVA: 0x0005228C File Offset: 0x0005068C
- private string GenerateRandomID(int length)
- {
- string text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- StringBuilder stringBuilder = new StringBuilder();
- System.Random random = new System.Random();
- int length2 = text.Length;
- for (int i = 0; i < length; i++)
- {
- stringBuilder.Append(text[random.Next(length2)]);
- }
- return stringBuilder.ToString();
- }
- // Token: 0x06000539 RID: 1337 RVA: 0x000522E4 File Offset: 0x000506E4
- private void SaveServerKey(string server_key)
- {
- string param = string.Format("{0}` {1}", this.full_ver_random_id, server_key);
- string graph = TGEncode.Encode(param);
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- FileStream fileStream;
- try
- {
- fileStream = File.Create(this.file_path);
- binaryFormatter.Serialize(fileStream, graph);
- }
- catch (Exception ex)
- {
- this.closeConnectingVC();
- return;
- }
- fileStream.Close();
- this.closeConnectingVC();
- this.gl.FullVersion = 1;
- if (SceneManager.GetActiveScene().name.Equals("Title") || SceneManager.GetActiveScene().name.Equals("CompanyLogo"))
- {
- GameObject gameObject = GameObject.Find("TitleVC");
- if (gameObject != null)
- {
- gameObject.GetComponent<TitleManager>().ShowFullButton(false);
- }
- base.showDelayMessageBox(1, 26, null, false);
- }
- }
- // Token: 0x0600053A RID: 1338 RVA: 0x000523CC File Offset: 0x000507CC
- private void VerifyEncodedKey()
- {
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- try
- {
- FileStream fileStream = File.Open(this.file_path, FileMode.Open);
- string text = (string)binaryFormatter.Deserialize(fileStream);
- text = TGEncode.Decode(text);
- fileStream.Close();
- string[] array = Regex.Split(text, "` ");
- if (array.Length != 2)
- {
- this.closeConnectingVC();
- this.DeleteFullVerFile();
- }
- else
- {
- string text2 = array[0];
- string text3 = array[1];
- text2 = text2.Substring(22, 20);
- string text4 = TGEncode.Encode(text2);
- text4 = FullVerMgr.EncodeWithKey(text4, this.device_id);
- this.closeConnectingVC();
- int startIndex = 71;
- text = text.Substring(startIndex, text4.Length);
- if (!text4.Equals(text))
- {
- this.DeleteFullVerFile();
- }
- else
- {
- this.gl.FullVersion = 1;
- this.file_checked = true;
- if (this.check_state == FullVerMgr.CHECK_STATE.LOAD_GAME)
- {
- g.game_mgr.startGame();
- }
- else if (this.check_state == FullVerMgr.CHECK_STATE.TURN_OVER)
- {
- g.game_mgr.showNextTurnOverMessage();
- }
- else if (this.check_state == FullVerMgr.CHECK_STATE.START_GAME || this.check_state == FullVerMgr.CHECK_STATE.PURCHASE_IN_TITLE)
- {
- GameObject gameObject = GameObject.Find("TitleVC");
- if (gameObject != null)
- {
- gameObject.GetComponent<TitleManager>().ShowFullButton(false);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- this.DeleteFullVerFile();
- this.closeConnectingVC();
- }
- }
- // Token: 0x0600053B RID: 1339 RVA: 0x00052548 File Offset: 0x00050948
- private void DeleteFullVerFile()
- {
- try
- {
- this.gl.FullVersion = 0;
- File.Delete(this.file_path);
- if (this.gl.IsGamePlaying)
- {
- GameSlotManager.SaveGameSlot(5);
- g.game_mgr.logOut(GameManager.LOGOUT_TYPE.EXIT_BUTTON, null);
- }
- }
- catch (Exception ex)
- {
- }
- }
- // Token: 0x0600053C RID: 1340 RVA: 0x000525AC File Offset: 0x000509AC
- protected override void closeMessageYes(int message_index)
- {
- base.closeMessageYes(message_index);
- if (message_index == 241)
- {
- this.loadConnectingVC();
- this.UpgradeFullVer();
- }
- }
- // Token: 0x0600053D RID: 1341 RVA: 0x000525CC File Offset: 0x000509CC
- private void ResponseFromServer(string content)
- {
- if (this.request_idx == FullVerMgr.REQUEST.CHECK_VERSION_0 || this.request_idx == FullVerMgr.REQUEST.CHECK_VERSION_1)
- {
- if (content.Equals("1.0.0"))
- {
- this.loadConnectingVC();
- this.CheckGoogleAccountFullVer();
- }
- else
- {
- base.showDelayMessageBox(2, 75, null, false);
- }
- }
- else if (this.request_idx == FullVerMgr.REQUEST.VERIFY_RECEIPT)
- {
- string[] array = Regex.Split(content, "` ");
- if (array[array.Length - 1].Equals("in_app_full_ver_ok"))
- {
- this.SaveServerKey(array[0]);
- base.showDelayMessageBox(1, 82, null, false);
- }
- else
- {
- base.showDelayMessageBox(2, 85, null, false);
- }
- }
- else if (this.request_idx == FullVerMgr.REQUEST.GENERATE_FULL_VER_CODE)
- {
- string[] array2 = Regex.Split(content, "` ");
- if (array2[array2.Length - 1].Equals("full_ver_code_ok"))
- {
- this.SaveServerKey(array2[0]);
- }
- else
- {
- string message_add = string.Format("[{0}]", content);
- base.showDelayMessageBox(2, 15, message_add, false);
- }
- }
- }
- // Token: 0x0600053E RID: 1342 RVA: 0x000526CB File Offset: 0x00050ACB
- private void RequestToServer(string php_file, string body, bool showConnectingVC)
- {
- if (showConnectingVC)
- {
- this.loadConnectingVC();
- }
- base.StartCoroutine(this.Request(php_file, body));
- }
- // Token: 0x0600053F RID: 1343 RVA: 0x000526E8 File Offset: 0x00050AE8
- private void RequestToServer(string php_file, string body)
- {
- this.RequestToServer(php_file, body, true);
- }
- // Token: 0x06000540 RID: 1344 RVA: 0x000526F3 File Offset: 0x00050AF3
- private void loadConnectingVC()
- {
- if (this.connecting_vc == null)
- {
- this.connecting_vc = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("Prefabs/Misc/ConnectingVC"));
- }
- }
- // Token: 0x06000541 RID: 1345 RVA: 0x0005271B File Offset: 0x00050B1B
- private void closeConnectingVC()
- {
- if (this.connecting_vc != null)
- {
- UnityEngine.Object.Destroy(this.connecting_vc);
- this.connecting_vc = null;
- }
- }
- // Token: 0x06000542 RID: 1346 RVA: 0x00052740 File Offset: 0x00050B40
- private IEnumerator Request(string php_file, string body)
- {
- string url = Global.IP + php_file;
- Dictionary<string, string> headers = new Dictionary<string, string>();
- headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
- headers.Add("User-Agent", "AirTycoon5");
- string encoded_data = TGEncode.Encode(body);
- string data = "tgl=" + encoded_data;
- WWW www = null;
- for (int i = 0; i < 5; i++)
- {
- float start_time = Time.time;
- bool failed = false;
- www = new WWW(url, Encoding.UTF8.GetBytes(data), headers);
- while (!failed && !www.isDone)
- {
- if (www.progress == 0f && Time.time - start_time > this.www_timeout)
- {
- if (www != null)
- {
- www.Dispose();
- www = null;
- }
- failed = true;
- break;
- }
- yield return null;
- }
- if (www == null || !string.IsNullOrEmpty(www.error))
- {
- failed = true;
- }
- if (!failed)
- {
- break;
- }
- yield return new WaitForSeconds(1f);
- }
- this.closeConnectingVC();
- if (www == null || !string.IsNullOrEmpty(www.error))
- {
- string arg;
- if (www == null)
- {
- arg = "The request timed out";
- }
- else
- {
- arg = www.error;
- }
- if (this.request_idx == FullVerMgr.REQUEST.CHECK_VERSION_0)
- {
- Global.IP = "http://121.190.7.75:8284/AT5/";
- this.www_timeout = 10f;
- this.request_idx = FullVerMgr.REQUEST.CHECK_VERSION_1;
- this.RequestToServer("version.php", string.Empty);
- }
- else if (this.request_idx == FullVerMgr.REQUEST.CHECK_VERSION_1)
- {
- Global.IP = "http://tradegame2.iptime.org:8284/AT5/";
- string message_add = string.Format("[{0}]", arg);
- base.showMessageBox(2, 69, message_add, false);
- }
- else
- {
- string message_add2 = string.Format("[{0}]", arg);
- base.showMessageBox(2, 69, message_add2, false);
- }
- }
- else
- {
- string text = www.text;
- this.ResponseFromServer(text);
- }
- yield break;
- }
- // Token: 0x06000543 RID: 1347 RVA: 0x0005276C File Offset: 0x00050B6C
- private static string EncodeWithKey(string param, string key)
- {
- byte[] bytes = Encoding.UTF8.GetBytes(param);
- byte[] bytes2 = Encoding.UTF8.GetBytes(key);
- byte b = 0;
- int length = key.Length;
- byte[] array = new byte[bytes.Length];
- for (int i = 0; i < bytes.Length; i++)
- {
- byte b2 = bytes[i] ^ bytes2[i % length] ^ b;
- b = b2;
- array[i] = b2;
- }
- return Convert.ToBase64String(array);
- }
- // Token: 0x04000AF0 RID: 2800
- private GameObject connecting_vc;
- // Token: 0x04000AF1 RID: 2801
- private string device_id = string.Empty;
- // Token: 0x04000AF2 RID: 2802
- private string full_ver_random_id = string.Empty;
- // Token: 0x04000AF3 RID: 2803
- private string file_path;
- // Token: 0x04000AF4 RID: 2804
- private bool file_checked;
- // Token: 0x04000AF5 RID: 2805
- private const int FULL_VER_KEY_LENGTH = 20;
- // Token: 0x04000AF6 RID: 2806
- private const int FULL_VER_KEY_LENGTH_DUMMY = 50;
- // Token: 0x04000AF7 RID: 2807
- private const int FULL_VER_KEY_START_OFFSET = 22;
- // Token: 0x04000AF8 RID: 2808
- private const int SERVER_KEY_LENGTH_DUMMY = 46;
- // Token: 0x04000AF9 RID: 2809
- private const int SERVER_KEY_START_OFFSET = 19;
- // Token: 0x04000AFA RID: 2810
- private FullVerMgr.REQUEST request_idx;
- // Token: 0x04000AFB RID: 2811
- private FullVerMgr.CHECK_STATE check_state;
- // Token: 0x04000AFC RID: 2812
- private float www_timeout = 10f;
- // Token: 0x020000D1 RID: 209
- private enum REQUEST
- {
- // Token: 0x04000AFE RID: 2814
- CHECK_VERSION_0,
- // Token: 0x04000AFF RID: 2815
- CHECK_VERSION_1,
- // Token: 0x04000B00 RID: 2816
- GENERATE_FULL_VER_CODE,
- // Token: 0x04000B01 RID: 2817
- VERIFY_RECEIPT
- }
- // Token: 0x020000D2 RID: 210
- public enum CHECK_STATE
- {
- // Token: 0x04000B03 RID: 2819
- START_GAME,
- // Token: 0x04000B04 RID: 2820
- PURCHASE_IN_TITLE,
- // Token: 0x04000B05 RID: 2821
- LOAD_GAME,
- // Token: 0x04000B06 RID: 2822
- TURN_OVER
- }
- }
- }
Add Comment
Please, Sign In to add comment