Пример #1
0
 public override void Run(string[] parameters)
 {
     string name = parameters[1];
     int health = int.Parse(parameters[2]);
     int damage = int.Parse(parameters[3]);
     var factory = new ObjectGenerator();
     var behavior = (AbstractBehavior)factory.Create(parameters[4], "Blobs.Behavior");
     var attack = (AbstractAttack)factory.Create(parameters[5], "Blobs.Attack");
     var blob = new Blob(name, health, damage, behavior, attack);
     engine.Db.AddBlob(blob);
     engine.Db.GetBlob(name).OutputMessage += engine.OnIncomingOutputMessage;
 }
Пример #2
0
        private static void Main()
        {
            //检测.net版本。
            if (!VersionCheck.Check4FromRegistry())
            {
                MessageBox.Show(".net版本过低。本程序需要运行在.net4.0或.net4.0以后的版本!", "提示");
                return;
            }
            App.Instance.ApplicationDirectory = Environment.CurrentDirectory + "\\";

            //同时只能运行一个实例。
            if (SingletonApp.IsMutexExsited)
            {
                SingletonApp.ShowRunningInstance();
                return;
            }
            //指定运行日志要保存的目录
            RunningLog.Start(App.Instance.ApplicationDirectory + "\\history\\");

            //判断当前登录用户是否为管理员
            if (WindowsAuthority.IsAdministrator)
            {
                //设置应用程序退出和异常的事件
                Application.ApplicationExit += App.Instance.RaiseApplicationExist;
                Application.ThreadExit      += App.Instance.RaiseMainThreadExist;
                Application.ThreadException += (o, e) => MessageBox.Show(e.Exception.ToString());

                try
                {
                    //运行应用程序内核
                    App.Instance.BuildModule();
                    App.Instance.Initialize();
                    App.Instance.RaiseStarting();

                    //启动Ui界面
                    IInvoke invoker = ObjectGenerator.Create("FlightViewerUI.dll", "BinHong.FlightViewerUI.UiInvoker") as IInvoke;
                    invoker.Invoke();
                }
                catch (Exception e)
                {
                    string msg = e.Message;
#if DEBUG
                    msg = e.Message + e.StackTrace;
#endif
                    RunningLog.Record(LogType.System, LogLevel.Error, msg);
                    Thread.Sleep(200);
                    MessageBox.Show(msg);
                }
                finally
                {
                    SingletonApp.ReleaseMutex();
                }
            }
            else
            {
                WindowsAuthority.RunAsAdministrator(Application.ExecutablePath);
            }
        }