public RoadSegmentData(Polygon rs, TileCtrl tile, RoadLocation loc, RoadState state) { RoadSegment = rs; Tile = tile; Location = loc; RoadState = state; }
public LogRoadUpdate(int gameIndex, RoadCtrl road, RoadState oldState, RoadState newState) { OldRoadState = oldState; Road = road; Index = road.Index; NewRoadState = newState; GameIndex = gameIndex; }
public object Convert(object value, Type targetType, object parameter, string language) { RoadState desiredState = StaticHelpers.ParseEnum <RoadState>((string)parameter); RoadState actualState = (RoadState)value; if (actualState == desiredState) { return(Visibility.Visible); } return(Visibility.Collapsed); }
public override void Execute(Core core) { Debug.Log("Command Execute: " + this.ToString()); if (!core.Grid.IsFree(position)) { return; } RoadState roadState = core.CoreFactory.RoadFactory.AddRoadPoint(position); Debug.Log("Road building state: " + roadState.ToString()); }
public RoadState AddRoadPoint(Vector3 position) { roadQueue.Enqueue(position); RoadState state = GetRoadStateFromQueueSize(); if (state == RoadState.FINISHED) { CreateRoadFromTo(roadQueue.Dequeue(), roadQueue.Dequeue()); return(RoadState.FINISHED); } return(state); }
public static void Start() { Thread tr = new Thread(() => { while (true) { roadBState = RoadState.Green; roadAState = RoadState.Red; Thread.Sleep(fullPeriod - subPeriod); roadBState = RoadState.Yellow; Console.WriteLine("change to yellow"); Thread.Sleep(subPeriod); roadBState = RoadState.Red; roadAState = RoadState.Green; Thread.Sleep(fullPeriod - subPeriod); roadAState = RoadState.Yellow; Console.WriteLine("change to yellow"); Thread.Sleep(subPeriod); } }); tr.Start(); }
/// <summary> /// 行车路线规划 /// </summary> /// <param name="start"></param> /// <param name="end"></param> private async void GetNavigationDriving(LatLng start, LatLng end) //路线规划 { AMapRouteResults rts; if (_avoidLatLng==null) //不做路径规避的路线 { //距离最短导航方式 rts = await AMapNavigationSearch.DrivingNavigation(start.longitude, start.latitude, end.longitude, end.latitude, 2, null, null, null, null, null, Extensions.All); } else //做路径规避的路线 { Debug.WriteLine("Avoidlatlng经纬度" + _avoidLatLng.longitude + " " + _avoidLatLng.latitude); List<AMapLocation> locations = computeAvoidLocations(_avoidLatLng);//获取规避区域 AMapPolygon polygon = new AMapPolygon(); polygon._Type = AMapPolygon.Types.Type.POLYGON; polygon.Points = locations; List<AMapPolygon> polygons = new List<AMapPolygon>(); polygons.Add(polygon); rts = await AMapNavigationSearch.DrivingNavigation(start.longitude, start.latitude, end.longitude, end.latitude, 2, null, null, null, polygons, null, Extensions.All); } if (rts.Erro == null) { if (rts.Count == 0) { MessageBox.Show("无查询结果"); return; } AMapRoute route = rts.Route; List<AMapPath> paths = route.Paths.ToList(); foreach (AMapPath item in paths) { Debug.WriteLine("起点终点距离:" + item.Distance); Debug.WriteLine("预计耗时:" + item.Duration / 60 + "分钟"); Debug.WriteLine("导航策略:" + item.Strategy); List<AMapStep> steps = item.Steps.ToList(); List<RoadState> roadStates=new List<RoadState>(); string avoid_roadname = null; //查询每一条道路 foreach (var temp in steps) { if(temp.Road=="") continue; RoadState tempState=new RoadState(); tempState.RoadName = temp.Road; tempState.State = true; tempState.State = _client.AcquireRoadState(temp.Road); roadStates.Add(tempState); } //寻找第一条规避的路径 foreach (var road in roadStates) { if (road.State == false) { avoid_roadname = road.RoadName; break; } } GetNavigationDriving_Avoid(start, end, avoid_roadname); } } else { MessageBox.Show(rts.Erro.Message); } }
public static UpdateRoadModel SetRoadState(MainPage page, RoadCtrl road, RoadState newState, RoadRaceTracking raceTracker) { RoadState oldState = road.RoadState; if (newState == oldState) { throw new Exception("Why are you updating the road state to be the same state it already is?"); } UpdateRoadModel model = new UpdateRoadModel() { Page = page, Player = page.CurrentPlayer, PlayerIndex = page.CurrentPlayer.AllPlayerIndex, PlayerName = page.CurrentPlayer.PlayerName, OldState = page.NewGameState, Action = CatanAction.UpdatedRoadState, RoadIndex = road.Index, OldRoadState = road.RoadState, NewRoadState = newState, GameIndex = page.GameContainer.CurrentGame.Index, OldRaceTracking = raceTracker }; road.RoadState = newState; switch (newState) { case RoadState.Unowned: if (oldState == RoadState.Ship) { model.Player.GameData.Ships.Remove(road); } else { model.Player.GameData.Roads.Remove(road); } road.Owner = null; road.Number = -1; break; case RoadState.Road: road.Number = model.Player.GameData.Roads.Count; // undo-able model.Player.GameData.Roads.Add(road); road.Owner = model.Player; break; case RoadState.Ship: model.Player.GameData.Roads.Remove(road); // can't be a ship if you aren't a road model.Player.GameData.Ships.Add(road); break; default: break; } string raceTrackCopy = JsonSerializer.Serialize <RoadRaceTracking>(raceTracker); RoadRaceTracking newRaceTracker = JsonSerializer.Deserialize <RoadRaceTracking>(raceTrackCopy); //await AddLogEntry(CurrentPlayer, GameState, CatanAction.UpdatedRoadState, true, logType, road.Number, new LogRoadUpdate(_gameView.CurrentGame.Index, road, oldState, road.RoadState)); CalculateAndSetLongestRoad(page, newRaceTracker); model.NewRaceTracking = newRaceTracker; return(model); }