Exemplo n.º 1
0
        /// <summary>
        /// run variable wheres
        /// </summary>
        /// <param name="newPoint"></param>
        /// <returns></returns>
        public object Run(object newPoint)
        {
            KeyValuePair <string, object> first = PublicVariables.First();

            PublicVariables[first.Key] = newPoint;
            object result = WhereInfo.Run(newPoint);

            foreach (VariableInfo variableInfo in Children)
            {
                object variableValue = null;
                System.Reflection.PropertyInfo property = null;
                foreach (KeyValuePair <string, object> variable in variableInfo.PublicVariables)
                {
                    if (variableInfo.PublicVariablePropertyNames.TryGetValue(variable.Key, out string name))
                    {
                        string[] nameValue = name.Split('.');
                        if (first.Key.Equals(nameValue[0], StringComparison.OrdinalIgnoreCase))
                        {
                            property = newPoint.GetType().GetProperties().FirstOrDefault(x => x.Name.Equals(nameValue.Last(), System.StringComparison.OrdinalIgnoreCase));
                            if (property != null)
                            {
                                object value = property.GetValue(newPoint);
                                variableValue = value;
                                break;
                            }
                        }
                    }
                }
                if (variableValue is IEnumerable enumerable)
                {
                    Type[] generics = property.PropertyType.GetGenericArguments();
                    if (generics.Length > 0)
                    {
                        var method = typeof(ConditionsCompiler).GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(x => x.Name == "GenerateArrayObject" && x.GetGenericArguments().Length > 0).FirstOrDefault();
                        method = method.MakeGenericMethod(generics[0]);
                        var value = method.Invoke(null, new object[] { variableValue, variableInfo });
                        value = typeof(Enumerable).GetMethod("ToList", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(generics[0]).Invoke(null, new object[] { value });
                        property.SetValue(newPoint, value);
                    }
                    else
                    {
                        var value = ConditionsCompiler.GenerateArrayObject(variableValue, variableInfo);
                        property.SetValue(newPoint, value);
                    }
                }
                else
                {
                    object value = variableInfo.Run(variableValue);
                }
            }
            return(result);
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            PublicVariables.SetUiApplication(commandData.Application);
            PublicVariables.SetUiDocument(commandData.Application.ActiveUIDocument);

            UpdaterClass updater = new UpdaterClass(commandData.Application.ActiveAddInId);

            UpdaterRegistry.RegisterUpdater(updater);
            UpdaterRegistry.EnableUpdater(updater.GetUpdaterId());
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), new ElementClassFilter(typeof(FamilyInstance)), Element.GetChangeTypeAny());
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), new ElementClassFilter(typeof(FamilyInstance)), Element.GetChangeTypeElementAddition());
            return(Result.Succeeded);
        }
        public void Get_Hit(int amount)
        {
            is_invicible = true;
            anim_manager.Get_Hit();
            bool death = PublicVariables.Lose_Health(amount);

            if (death)
            {
                anim_manager.Die_Anim();
                //Disable Network Player
            }

            StartCoroutine(Reset_InvicibilityIE());
        }
Exemplo n.º 4
0
        private IEnumerator DelayDestroy()
        {
            int _index = health_list.FindLastIndex(x => { return(x != null); });

            health_list[_index].GetComponent <Animator>().SetTrigger("Destroy");

            yield return(new WaitForSeconds(.2f));

            Destroy(health_list[_index]);
            PublicVariables.Lose_Health(1);

            if (PublicVariables.health == 0)
            {
                Game_Over(false);
            }
        }
Exemplo n.º 5
0
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult()
            {
                Result   = true,
                SendFlag = true,
            };

            //检查额度限制
            if (QuotaHelper.QuotaCheck(e.FromGroup, e.FromQQ) is false)
            {
                return(result);
            }
            PublicVariables.ReadOrderandAnswer();

            SendText sendText = new SendText();

            sendText.SendID = e.FromGroup;
            result.SendObject.Add(sendText);
            if (e.Message.Text.Trim().Length == GetOrderStr().Length)
            {
                sendText.MsgToSend.Add("指令无效,请在指令后添加pid");
                return(result);
            }
            if (!int.TryParse(e.Message.Text.Substring(GetOrderStr().Length).Replace(" ", ""), out int pid))
            {
                sendText.MsgToSend.Add("指令无效,检查是否为纯数字");
                return(result);
            }
            result.SendFlag = false;
            e.FromGroup.SendGroupMessage($"正在查询pid={pid}的插画信息,请等待……");
            IllustInfo illustInfo = PixivAPI.GetIllustInfo(pid);

            e.FromGroup.SendGroupMessage(illustInfo.IllustText);
            var message = e.FromGroup.SendGroupMessage(illustInfo.IllustCQCode);

            if (illustInfo.R18_Flag)
            {
                IniConfig ini  = MainSave.ConfigMain;
                Task      task = new Task(() =>
                {
                    Thread.Sleep(ini.Object["R18"]["RevokeTime"] * 1000);
                    e.CQApi.RemoveMessage(message.Id);
                }); task.Start();
            }
            return(result);
        }
Exemplo n.º 6
0
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult()
            {
                Result   = true,
                SendFlag = true,
            };

            //检查额度限制
            if (QuotaHelper.QuotaCheck(e.FromGroup, e.FromQQ) is false)
            {
                return(result);
            }
            PublicVariables.ReadOrderandAnswer();

            SendText sendText = new SendText();

            sendText.SendID = e.FromGroup;
            result.SendObject.Add(sendText);

            string keyword = e.Message.Text.Replace(" ", "").Substring(GetOrderStr().Length);

            e.FromGroup.SendGroupMessage($"正在查询关键字为{keyword}的插画信息,请等待……");
            IllustInfo illustInfo = PixivAPI.GetHotSearch(keyword);

            e.FromGroup.SendGroupMessage(illustInfo.IllustText);
            var message = e.FromGroup.SendGroupMessage(illustInfo.IllustCQCode);

            if (illustInfo.R18_Flag)
            {
                IniConfig ini  = MainSave.ConfigMain;
                Task      task = new Task(() =>
                {
                    Thread.Sleep(PublicVariables.R18_RevokeTime * 1000);
                    e.CQApi.RemoveMessage(message.Id);
                }); task.Start();
            }
            return(result);
        }
Exemplo n.º 7
0
        public void CQStartup(object sender, CQStartupEventArgs e)
        {
            MainSave.AppDirectory   = e.CQApi.AppDirectory;
            MainSave.CQApi          = e.CQApi;
            MainSave.CQLog          = e.CQLog;
            MainSave.ImageDirectory = CommonHelper.GetAppImageDirectory();

            IniConfig ini = new IniConfig(e.CQApi.AppDirectory + "Config.ini");

            ini.Load();
            MainSave.ConfigMain = ini;
            PublicVariables.ReadOrderandAnswer();
            try
            {
                WebProxy proxy = null;
                if (ini.Object["Proxy"]["IsEnabled"].GetValueOrDefault(0) == 1)
                {
                    //代理设置
                    string uri, username, pwd;
                    uri      = ini.Object["Proxy"]["ProxyUri"].GetValueOrDefault("");
                    username = ini.Object["Proxy"]["ProxyName"].GetValueOrDefault("");
                    pwd      = ini.Object["Proxy"]["ProxyPwd"].GetValueOrDefault("");
                    proxy    = new WebProxy
                    {
                        Address     = new Uri(uri),
                        Credentials = new NetworkCredential(username, pwd)
                    };
                    MainSave.Proxy = proxy;
                }
            }
            catch (Exception ex)
            {
                MainSave.CQLog.Warning("代理设置无效", $"代理参数有误,错误信息:{ex.Message}");
            }

            ini = MainSave.ConfigLimit;
            if (ini.Object == null || ini.Object.Count == 0)
            {
                File.WriteAllText(e.CQApi.AppDirectory + "ConfigLimit.ini", "[Config]\nTimestamp=1608773153");
                ini.Load();
            }
            if (JudgeifTimestampOverday(ini.Object["Config"]["Timestamp"].GetValueOrDefault(0), CommonHelper.GetTimeStamp()))
            {
                if (File.Exists(MainSave.AppDirectory + "ConfigLimit.ini"))
                {
                    File.WriteAllText(MainSave.AppDirectory + "ConfigLimit.ini", "[Config]\nTimestamp=1608773153");
                    MainSave.CQLog.Info("涩图机重置", "限制已重置");
                }
            }
            timersTimer.Interval = 1000;
            timersTimer.Enabled  = true;
            timersTimer.Elapsed += TimersTimer_Elapsed;
            timersTimer.Start();

            MainSave.Instances.Add(new ClearLimit());
            MainSave.Instances.Add(new CustomAPI());
            MainSave.Instances.Add(new GetLoliconPic());
            MainSave.Instances.Add(new HotSearch());
            MainSave.Instances.Add(new JsonPic());
            MainSave.Instances.Add(new LocalPic());
            MainSave.Instances.Add(new PIDSearch());
            MainSave.Instances.Add(new RankPic());
            MainSave.Instances.Add(new SauceNao());
            MainSave.Instances.Add(new TraceMoe());
            MainSave.Instances.Add(new YandeRePic());
            MainSave.Instances.Add(new YandeReTagSearch());
        }
Exemplo n.º 8
0
 private void OnLevelWasLoaded(int level)
 {
     PublicVariables.Reset_Level(10);
 }