コード例 #1
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
        private Vector2 InternalDecrypt()
        {
            if (!inited)
            {
                currentCryptoKey = cryptoKey;
                hiddenValue      = Encrypt(zero);
                fakeValue        = zero;
                fakeValueActive  = false;
                inited           = true;

                return(zero);
            }

            Vector2 value;

            value.x = TSFloat.Decrypt(hiddenValue.x, currentCryptoKey);
            value.y = TSFloat.Decrypt(hiddenValue.y, currentCryptoKey);

            if (ObscuredCheatingDetector.ExistsAndIsRunning && fakeValueActive && !CompareVectorsWithTolerance(value, fakeValue))
            {
                ObscuredCheatingDetector.Instance.OnCheatingDetected();
            }

            return(value);
        }
コード例 #2
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
        /// <summary>
        /// 使用随机的新密钥
        /// </summary>
        public void RandomizeCryptoKey()
        {
            var decrypted = InternalDecrypt();

            currentCryptoKey = ThreadSafeRandom.Next();
            hiddenValue      = Encrypt(decrypted, currentCryptoKey);
        }
コード例 #3
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
        public static TSVector2 FromEncrypted(EncryptedVector2 encrypted)
        {
            var instance = new TSVector2();

            instance.SetEncrypted(encrypted);
            return(instance);
        }
コード例 #4
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
 /// <summary>
 /// 在SetNewCryptoKey()之后使用
 /// 使用新的密钥加密当前实例
 /// </summary>
 public void ApplyNewCryptoKey()
 {
     if (currentCryptoKey != cryptoKey)
     {
         hiddenValue      = Encrypt(InternalDecrypt(), cryptoKey);
         currentCryptoKey = cryptoKey;
     }
 }
コード例 #5
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
        /// <summary>
        /// 解密
        /// </summary>
        public static Vector2 Decrypt(EncryptedVector2 value, int key)
        {
            if (key == 0)
            {
                key = cryptoKey;
            }

            Vector2 result;

            result.x = TSFloat.Decrypt(value.x, key);
            result.y = TSFloat.Decrypt(value.y, key);

            return(result);
        }
コード例 #6
0
        private TSVector2(Vector2 value)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(value);

#if UNITY_EDITOR
            fakeValue       = value;
            fakeValueActive = true;
#else
            var detectorRunning = ObscuredCheatingDetector.ExistsAndIsRunning;
            fakeValue       = detectorRunning ? value : zero;
            fakeValueActive = detectorRunning;
#endif

            inited = true;
        }
コード例 #7
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
        /// <summary>
        /// Mimics constructor of regular Vector2.
        /// </summary>
        /// <param name="x">X component of the vector</param>
        /// <param name="y">Y component of the vector</param>
        public TSVector2(float x, float y)
        {
            currentCryptoKey = cryptoKey;
            hiddenValue      = Encrypt(x, y, currentCryptoKey);

            if (ObscuredCheatingDetector.ExistsAndIsRunning)
            {
                fakeValue       = new Vector2(x, y);
                fakeValueActive = true;
            }
            else
            {
                fakeValue       = zero;
                fakeValueActive = false;
            }

            inited = true;
        }
コード例 #8
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
        /// <summary>
        /// 设置加密后的值
        /// </summary>
        /// <param name="encrypted"></param>
        public void SetEncrypted(EncryptedVector2 encrypted)
        {
            inited      = true;
            hiddenValue = encrypted;

            if (currentCryptoKey == 0)
            {
                currentCryptoKey = cryptoKey;
            }

            if (ObscuredCheatingDetector.ExistsAndIsRunning)
            {
                fakeValueActive = false;
                fakeValue       = InternalDecrypt();
                fakeValueActive = true;
            }
            else
            {
                fakeValueActive = false;
            }
        }
コード例 #9
0
ファイル: TSVector2.cs プロジェクト: a13782425/TSFramework
 /// <summary>
 /// 解密
 /// </summary>
 public static Vector2 Decrypt(EncryptedVector2 value)
 {
     return(Decrypt(value, 0));
 }