private void Bus_OnReceived(object sender, BusEventArgs e) { if (e.Topic == BusOption.CMD_INPUT) { //接收到了控制命令 DriveControl Ctrl = JsonSerializer.Deserialize <DriveControl>(e.Message); if (Ctrl.Cmd == DriveControl.CMD_SHUTDOWN) { ISRun = false; } } }
static void Main(string[] args)//each char is 100m!! { MeteorologicCentrum mCentrum = new MeteorologicCentrum(); DriveControl control = new DriveControl(numOfCars: 25); mCentrum.OnWeatherChanged += control.WeatherHasChanged; while (true) { foreach (var v in control.Run()) { control.UpdateRoad(); if (rnd.Next(0, 5) == 0) { mCentrum.TriggerWeatherChange(); } Thread.Sleep(50); } } }
public void Awake() { Main = this; }