/// <summary> /// 停止 /// </summary> void CreateStopCmd() { CmdIdle cmd = CmdFactory.Create(CmdFactory.E_CmdType.Idle) as CmdIdle; Owner.BlackBoard.DesiredPosition = Owner.Position; Owner.BlackBoard.AddCmd(cmd); }
/// <summary> /// 移动 /// </summary> void CreateMoveCmd() { CmdMove cmd = CmdFactory.Create(CmdFactory.E_CmdType.Move) as CmdMove; Owner.BlackBoard.DesiredDirection = Direction; Owner.BlackBoard.DesiredPosition = Owner.Position; Owner.BlackBoard.MoveSpeedModifier = Force; Owner.BlackBoard.AddCmd(cmd); }
public void BucketFill(int x, int y, int color) { if (Canvas == null) { throw new InvalidOperationException("Canvas is null"); } var cmd = CmdFactory.CreateBucketFill(Canvas, x, y, color); this.StoreAndExecute(cmd); }
public void CreateRectangle(int x1, int y1, int x2, int y2, int color) { if (Canvas == null) { throw new InvalidOperationException("Canvas is null"); } var cmd = CmdFactory.CreateRectangle(Canvas, x1, y1, x2, y2, color); this.StoreAndExecute(cmd); }
private static void Main(string[] args) { HostFactory.Run(x => { var hostBuilder = new HostBuilder().ConfigureAppConfiguration((hostContext, configApp) => { var hostingEnvironment = hostContext.HostingEnvironment; _appConfiguration = AppConfigurations.Get(hostingEnvironment.ContentRootPath, hostingEnvironment.EnvironmentName); }).ConfigureServices((hostContext, services) => { //注入IConfiguration到DI容器 services.AddSingleton(_appConfiguration); services.AddOptions(); services.Configure <AppOptions>(_appConfiguration.GetSection("App")); //注入MyService到DI容器 //services.AddSingleton<IMyService, MyService>(); //}).ConfigureLogging((hostContext, logging) => //{ //}); CmdFactory.Init(); var connstr = _appConfiguration.GetConnectionString("Redis"); var csredis = new CSRedisClient(connstr + ",defaultDatabase=0,poolsize=50,ssl=false,writeBuffer=10240"); RedisHelper.Initialization(csredis); DbHelper.Initialization(_appConfiguration.GetConnectionString("DefaultConnectionString"), DbHelper.DbType.NPGSQL); }); var repository = LogManager.CreateRepository("loghelper"); var config = new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "hnlog.config"); log4net.Config.XmlConfigurator.Configure(repository, config); //初始化通用主机 var host = hostBuilder.Build(); var appOptions = host.Services.GetService <IOptions <AppOptions> >(); //注册为服务 x.Service <HnService>(sc => { sc.ConstructUsing(name => new HnService(appOptions)); sc.WhenStarted((s, hostControl) => s.Start(hostControl)); sc.WhenStopped((s, hostControl) => s.Stop(hostControl)); }); x.RunAsLocalSystem(); x.StartAutomatically(); x.SetDescription(appOptions.Value.Description); x.SetDisplayName(appOptions.Value.Name); x.SetServiceName(appOptions.Value.Name); }); }
private void CreateWeaponShow() { CmdWeaponShow cmd = CmdFactory.Create(CmdFactory.E_CmdType.WeaponShow) as CmdWeaponShow; if (IsShow) { Owner.BlackBoard.WeaponState = E_WeaponState.Attacking; } else { Owner.BlackBoard.WeaponState = E_WeaponState.NotInHands; } cmd.IsShow = IsShow; Owner.BlackBoard.AddCmd(cmd); }
/// <summary> /// 统一回收命令对象 /// </summary> public void Update() { IdleTimer += Time.deltaTime; ICmd cmd; for (int i = 0; i < ActiveCmds.Count; i++) { cmd = ActiveCmds[i]; if (cmd.IsActive) { continue; } CmdFactory.Return(cmd); ActiveCmds.RemoveAt(i); return; } }