Ejemplo n.º 1
0
        /// <summary>
        /// функција која се грижи за поставување на непријателите зависно од тоа за кој левел се работи.
        /// </summary>
        public void placeEvilMinionsGM()
        {
            int LR = Random.Next(2); // 0 за да дојде од лево и 1 за да дојде од десно на играчот.

            switch (GM)
            {
            case GameMode.Easy: {
                int RandomXX = Random2.Next(PositionRIGHT, PositionRIGHT + 200);
                PositionRIGHT += 300;
                FromRight      = true;
                FromLeft       = false;
                X              = RandomXX;
            }
            break;

            case GameMode.Medium: {
                if (LR == 0)
                {
                    int RandomX = Random2.Next(Math.Abs(PositionLEFT), Math.Abs(PositionLEFT - 500));
                    RandomX   = -RandomX;
                    FromLeft  = true;
                    FromRight = false;
                    X         = RandomX;
                }
                else if (LR == 1)
                {
                    int RandomXX = Random2.Next(PositionRIGHT, PositionRIGHT + 200);
                    PositionRIGHT += 300;
                    FromRight      = true;
                    FromLeft       = false;
                    X              = RandomXX;
                }
            }
            break;

            case GameMode.Hard: {
                if (LR == 0)
                {
                    int RandomX = Random2.Next(Math.Abs(PositionLEFT), Math.Abs(PositionLEFT - 500));
                    RandomX   = -RandomX;
                    FromLeft  = true;
                    FromRight = false;
                    X         = RandomX;
                }
                else if (LR == 1)
                {
                    int RandomXX = Random2.Next(PositionRIGHT, PositionRIGHT + 200);
                    PositionRIGHT += 300;
                    FromRight      = true;
                    FromLeft       = false;
                    X              = RandomXX;
                }
            }
            break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        public CurrentUser?GetCurrentUser()
        {
            var hasCurrentUser = currentUser != null;

#if DEBUG
            var read_cache = Random2.Next(100) % 2 == 0;
            hasCurrentUser = read_cache && hasCurrentUser;
#endif
            CurrentUser?result;
            if (hasCurrentUser)
            {
                result = currentUser?.Clone();
            }
            else
            {
                Func <ValueTask <CurrentUser?> > func = GetCurrentUserAsync;
                result = func.RunSync();
            }
#if DEBUG
            logger.LogDebug("read_cache: {0}, PhoneNumber: {1}", read_cache, result?.ToStringHideMiddleFour());
#endif
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 当前是否装有 Xposed 框架
        /// </summary>
        /// <returns></returns>
        public static bool IsXposedExists()
        {
            var classLoader = Java.Lang.ClassLoader.SystemClassLoader;

            if (classLoader == null)
            {
                throw new NullReferenceException("Java.Lang.ClassLoader.SystemClassLoader is null.");
            }

            try
            {
                var xpHelperObj = classLoader.LoadClass(XPOSED_HELPERS)?.NewInstance();
            }
            catch (Java.Lang.InstantiationException e)
            {
                e.PrintStackTraceWhenDebug();
                return(true);
            }
            catch (Java.Lang.IllegalAccessException e)
            {
                e.PrintStackTraceWhenDebug();
                return(true);
            }
            catch (Java.Lang.ClassNotFoundException e)
            {
                e.PrintStackTraceWhenDebug();
            }

            try
            {
                var xpBridgeObj = classLoader.LoadClass(XPOSED_BRIDGE)?.NewInstance();
            }
            catch (Java.Lang.InstantiationException e)
            {
                e.PrintStackTraceWhenDebug();
                return(true);
            }
            catch (Java.Lang.IllegalAccessException e)
            {
                e.PrintStackTraceWhenDebug();
                return(true);
            }
            catch (Java.Lang.ClassNotFoundException e)
            {
                e.PrintStackTraceWhenDebug();
            }

            try
            {
                throw new Java.Lang.Exception(Random2.GenerateRandomString(Random2.Next(5, 10)));
                // 通过主动抛出异常,检查堆栈信息来判断是否存在XP框架。
            }
            catch (Java.Lang.Exception e)
            {
                var hasFind = e.GetStackTrace()
                              .Any(x => x.ClassName != null &&
                                   x.ClassName.Contains(XPOSED_BRIDGE, StringComparison.OrdinalIgnoreCase));
                if (hasFind)
                {
                    return(true);
                }
            }

            return(false);
        }