internal void Add <TBehavior>(string path, Func <TBehavior> creator, dynamic rule) where TBehavior : WebSocketBehavior { path = HttpUtility.UrlDecode(path).TrimSlashFromEnd(); lock (_sync) { WebSocketServiceHost host; if (_hosts.TryGetValue(path, out host)) { throw new ArgumentException("Already in use.", "path"); } host = new WebSocketServiceHost <TBehavior>(path, creator, null, new Logger()); if (!_clean) { host.KeepClean = false; } if (_waitTime != host.WaitTime) { host.WaitTime = _waitTime; } if (_state == ServerState.Start) { host.Start(); } _hosts.Add(path, path, host, rule); } }
public void GetBasicBestRoutes() { SetUp(); StudentLogic testLogic = new StudentLogic(); SchoolVanLogic schoolVanLogic = new SchoolVanLogic(); Student newStudent = TestStudent(1); newStudent.Id = testLogic.GetNextIdFree() - 1; testLogic.Add(newStudent); SchoolVanLogic logic = new SchoolVanLogic(); SchoolVan newSchoolVan = new SchoolVan(); logic.Add(newSchoolVan); newSchoolVan.Id = logic.GetNextIdFree() - 1; Route expectedRoute = new Route(); expectedRoute.TheSchoolVan = newSchoolVan; Coordinate schoolCoordinate = new Coordinate(); expectedRoute.Add(schoolCoordinate); expectedRoute.Add(newStudent); List <Route> expectedRoutes = new List <Route>(); expectedRoutes.Add(expectedRoute); List <Route> obtainRoutes = schoolVanLogic.GetBestRoutes(); Assert.IsTrue(obtainRoutes.SequenceEqual(expectedRoutes)); }
public void AddToRouteFail() { Route newRoute = new Route(); Coordinate newCoordinate = new Coordinate(); newRoute.Add(newCoordinate); int invalidObjectRoute = 5; newRoute.Add(invalidObjectRoute); }
public void AddToRouteSuccess() { Route newRoute = new Route(); Coordinate newCoordinate = new Coordinate(); newRoute.Add(newCoordinate); Student newStudent = TestStudent(); newRoute.Add(newStudent); Assert.IsTrue(newRoute.Length() == 2); }
public void CalculateBasicDistance() { Route newRoute = new Route(); Coordinate newCoordinate = new Coordinate(); newRoute.Add(newCoordinate); Student newStudent = TestStudent(); newRoute.Add(newStudent); Assert.IsTrue(newRoute.TotalDistance() == 0); }
public void testIfContainsObserver() { Route myRoute = new Route(a, "Weight"); myRoute.Add(aToB); myRoute.Add(bToC); myRoute.Add(cToD); //Assert.IsTrue(myRoute.ContainsObserver()); //Assert.AreEqual(3, myRoute.PathCost); //Assert.AreEqual(d, myRoute.Destination); }
public void CalculateSimpleDistance() { Route newRoute = new Route(); Coordinate newCoordinate = new Coordinate(); newCoordinate.X = 5; newRoute.Add(newCoordinate); Student newStudent = TestStudent(); newStudent.Coordinates.X = 5; newStudent.Coordinates.Y = 5; newRoute.Add(newStudent); Assert.IsTrue(newRoute.TotalDistance() == 10); }
async Task InitializeServer() { Route.Add("/log", (req, res, props) => { using (var reader = new StreamReader(req.InputStream, Encoding.UTF8)) { try { var json = reader.ReadToEnd(); var logRequest = JsonConvert.DeserializeObject <LogRequest>(json); richTextBox.AppendText(logRequest.Tag); richTextBox.AppendText(Environment.NewLine); } catch { /* Ignore on invalid tag request */ } } res.AsText("OK"); }, "POST"); await HttpServer.ListenAsync( Port, CancellationToken.None, Route.OnHttpRequestAsync ); }
public override async void OnNavigatedTo(INavigationParameters parameters) { base.OnNavigatedTo(parameters); try { if (parameters.GetNavigationMode() == NavigationMode.New) { if (parameters.TryGetValue("TripDetails", out TripModel trip)) { Name = trip.Name; StartTime = trip.StartTime; EndTime = trip.EndTime; Duration = trip.Duration; AverageSpeed = trip.AverageSpeed; trip.Route.ForEach(x => Route.Add(x)); CurrentLocation = new CoordinateModel { Latitude = trip.Route.Average(x => x.Latitude), Longitude = trip.Route.Average(x => x.Longitude), }; return; } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void AddWaypoinnt() { // Return when the user has not selected a process. if (FFACE == null) { AppServices.InformUser("No process has been selected."); return; } if (FFACE.Player.Zone != Config.Instance.Route.Zone && Config.Instance.Route.Zone != Zone.Unknown) { AppServices.InformUser("Cannot record waypoints from a different zone."); return; } Config.Instance.Route.Zone = FFACE.Player.Zone; var position = new Position { X = FFACE.Player.Position.X, Y = FFACE.Player.Position.Y, Z = FFACE.Player.Position.Z, H = FFACE.Player.Position.H }; Application.Current.Dispatcher.Invoke(() => Route.Add(position)); AppServices.InformUser("Waypoint added!"); }
public void TestMethod1() { IEdge edge1 = new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 }); IEdge edge2 = new Edge(new AttributePair <Double> { Name = "Weight", Attribute = 1 }); graph.ConnectNodeToWith(src, nodes[1], edge1); graph.ConnectNodeToWith(nodes[1], nodes[2], edge2); route1.Add(edge1); route1.Add(edge2); Assert.IsFalse(route1.Equals(route2)); }
public MainWindow() { InitializeComponent(); Console.WriteLine(Convert.ToByte("FF", 16)); this.Get <NumericUpDown>("HowManyBox").KeyDown += HowMany_KeyDown; this.Get <Button>("HowManyButton").Click += HowMany_Click; DataContext = Model; Route.Add("/barcode-scan/add-item", (HttpAction)HandleBarcodeScanAddItem, "POST"); Route.Add("/barcode-scan/oauth/return{unused}", (HttpAction)HandleOAuthCallback); int port = 8074; Console.WriteLine($"HTTP server listening on port {port}"); CancellationTokenSource cts = new CancellationTokenSource(); Task ts = HttpServer.ListenAsync(port, cts.Token, Route.OnHttpRequestAsync, useHttps: false); Console.WriteLine("Visit https://sso.digikey.com/as/authorization.oauth2?response_type=code&client_id=31801af8-5c22-4b34-b2f6-cc3a38275b58&redirect_uri=https://catalog.muny.us/barcode-scan/oauth/return to get OAuth tokens"); }
/* * This method creates the route that the bike in the VR will follow. */ public void CreateRoute(RouteData[] routeData) { connector.SendPacket(Route.Add(routeData), new Action <JObject>(data => { Console.WriteLine($"Response add: {data}"); connector.SendPacket(Route.ShowRoute(false), new Action <JObject>(dataRoute => { Console.WriteLine("Route skeleton had been made"); })); var roadId = data["data"]?["data"]?["uuid"]?.ToString(); AddRoad(roadId); connector.SendPacket(Node.AddModel("Bike", null, new TransformComponent(1, -1, 1, 1, 0, 45, 0), new ModelComponent(GetModelObjects("bike/bike.fbx"), true, false, "")), new Action <JObject>(bikeData => { bikeUuid = bikeData["data"]?["data"]?["uuid"]?.ToString(); CreatePanel(bikeUuid); connector.SendPacket(Route.Follow(roadId, bikeData["data"]?["data"]?["uuid"]?.ToString(), updateValues.Speed / 3, -1, "XZ", 1, false, new[] { 0, 0, 0 }, new[] { 0, 0, 0 }), new Action <JObject>(e => { Console.WriteLine("Following the set route!"); })); })); })); }
public void Init() { if (_launcherInfo != null) { Name = AircraftInformation.AircraftFile.Replace(".acf", ""); Livery = GetLastParthOfLiveryPath(AircraftInformation.Livery); Location = new Location(AircraftInformation.Latitude, AircraftInformation.Longitude); SummaryDistanceNauticalMiles = _launcherInfo.SummaryDistanceNauticalMiles; SummaryHours = _launcherInfo.SummaryHours; foreach (Location location in _launcherInfo.TargetLocation) { LocationInformation additionalInformation = null; if (_launcherInfo.LocationInformations != null && _launcherInfo.LocationInformations.ContainsKey(location)) { additionalInformation = _launcherInfo.LocationInformations[location]; } RoutePoint routePoint = new RoutePoint(location, Id); if (additionalInformation != null) { routePoint.Update(additionalInformation.Name, additionalInformation.Comment); } Route.Add(routePoint); } } }
protected Route ParseGamsSolution(string routePath, int[] mapping, Route currentRoute) { //TODO!!!!! Verificar q exista el fichero, si no existe es q gams no pudo encontrar solucion para alguna ruta Route newRoute = new Route(currentRoute.Vehicle); Regex routeExp = new Regex(@"(?<ci>C\d+)\S+(?<cj>C\d+)\S+(?<v>\d\.d+)"); StreamReader reader = new StreamReader(Path.Combine(routePath, "tspspdsolution.dat")); double cost = double.Parse(reader.ReadLine().Trim()); if (cost == 0) { Console.WriteLine("weak feasible {0} strong feasible {1}", ProblemData.IsFeasible(currentRoute), ((VRPSimultaneousPickupDelivery)ProblemData).IsStrongFeasible(currentRoute)); return(currentRoute); } Dictionary <int, int> routeInfo = GetRouteInfo(reader); int lastCLient = 0; int newClient = routeInfo[lastCLient]; while (newClient != 0) { newRoute.Add(mapping[newClient]); lastCLient = newClient; newClient = routeInfo[lastCLient]; } return(newRoute); }
static void Main() { Route.Add("/", (req, res, props) => { res.AsText("Welcome to the Simple Http Server"); }); Route.Add("/users/{id}", (req, res, props) => { res.AsText($"You have requested user #{props["id"]}"); }, "POST"); Route.Add("/header", (req, res, props) => { res.AsText($"Value of my-header is: {req.Headers["my-header"]}"); }); HttpServer.ListenAsync( 1337, CancellationToken.None, Route.OnHttpRequestAsync ) .Wait(); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
public async void InitRoute() { ShowDetails = true; if (Waypoints.Count() > 2) { Route.Clear(); foreach (var w in Waypoints) { Route.Add(new Position(w.Latitude, w.Longitude)); } } else { var leg = await Host.GeocodingService.GetDirectionsFromGoogle( new[] { OriginAddress.Latitude, OriginAddress.Longitude }, new[] { DestinationAddress.Latitude, DestinationAddress.Longitude }); Route.Clear(); if (leg != null) { foreach (var step in leg.steps) { Route.Add(new Position(step.end_location.lat, step.end_location.lng)); } } } Loaded = true; }
private void goToHiddenStationIfExists() { if (lastStation.NextStations.Length > 0) { route.Add(lastStation.NextStations[0]); } }
private void Goto(GridItem item) { if (item.PathIndex == null) { item.PathIndex = Squares.Max(x => x.PathIndex ?? 0) + 1; Route.Add(item); } }
private void Search() { Route.Add(Start); Route.CurrentLength = 0; Route.Next = Block.None; IsSearching = false; }
public void toStringRoute() { Route aRoute = new Route(); Coordinate newCoordinate = new Coordinate(); Coordinate newCoordinateStudent = new Coordinate(); Student newStudent = new Student(); newStudent.Name = "Jaime"; newCoordinateStudent.X = 10; newCoordinateStudent.Y = 5; newStudent.Coordinates = newCoordinateStudent; aRoute.Add(newCoordinate); aRoute.Add(newStudent); string ruta = aRoute.ToStringRoute(); Assert.IsTrue(ruta.Equals("Camioneta 0: - Escuela [0,0] - Jaime [10,5]")); }
public static Route AddParameter(this Route route, string parameterName) { route.Add(new RouteSegment { Kind = RouteSegmentMatcherKinds.Parameter, Name = parameterName }); return(route); }
public static Route AddController(this Route route) { route.Add(new RouteSegment { Kind = RouteSegmentMatcherKinds.Controller }); return(route); }
public static Route AddLiteral(this Route route, string literal) { route.Add(new RouteSegment { Kind = RouteSegmentMatcherKinds.Literal, Name = literal }); return(route); }
public static Route AddAction(this Route route) { route.Add(new RouteSegment { Kind = RouteSegmentMatcherKinds.Action }); return(route); }
public void AddRoutePoint(float x, float y, bool shouldIncludeTri = false) { Point p = new Point(x, y); if (shouldIncludeTri) { p.Tris.Add(GetTriContainingPoint(x, y)); } Route.Add(p); }
public PropertyRoute AddDynamic(MemberInfo mi) { if (Value is Entity) { return(PropertyRoute.Root(value.GetType()).Add(mi)); } else { return(Route.Add(mi)); } }
public static Route AddDefaultAction(this Route route, string defaultActionName, string defaultLiteralName) { route.Add(new RouteSegment { Kind = RouteSegmentMatcherKinds.Action, Value = defaultActionName, Name = defaultLiteralName }); return(route); }
public static Route AddDefaultController(this Route route, string defaultControllerName, string defaultLiteralName) { route.Add(new RouteSegment { Kind = RouteSegmentMatcherKinds.Controller, Value = defaultControllerName, Name = defaultLiteralName }); return(route); }
public void RoutesSetEquals() { Route newRoute = new Route(); Coordinate newCoordinate = new Coordinate(); newCoordinate.X = 5; newRoute.Add(newCoordinate); Route anotherEqualsRoute = new Route(); anotherEqualsRoute.TheRoute = newRoute.TheRoute; Assert.IsTrue(newRoute.Equals(anotherEqualsRoute)); }
private void _treeView_Expanded(object sender, RoutedEventArgs e) { var treeViewItem = e.OriginalSource as TreeViewItem; if (treeViewItem == null) return; var treeViewModel = (TreeViewModelBase)_treeView.SearchItemFromElement((DependencyObject)treeViewItem); var path = new Route(); foreach (var item in treeViewModel.GetAncestors()) { if (item is SignatureTreeViewModel) path.Add(((SignatureTreeViewModel)item).Value.LinkItem.Signature); } Settings.Instance.LinkControl_ExpandedPaths.Add(path); }
private void Setting_Init() { NativeMethods.SetThreadExecutionState(ExecutionState.SystemRequired | ExecutionState.Continuous); { bool initFlag = false; _amoebaManager = new AmoebaManager(_serviceManager.Config.Cache.Path, _bufferManager); _amoebaManager.Load(_configrationDirectoryPaths["AmoebaManager"]); if (!File.Exists(Path.Combine(_serviceManager.Paths["Configuration"], "Amoeba.version"))) { initFlag = true; { var p = new System.Diagnostics.ProcessStartInfo(); p.UseShellExecute = true; p.FileName = Path.GetFullPath(Path.Combine(_serviceManager.Paths["Core"], "Amoeba.exe")); p.Arguments = "Relate on"; OperatingSystem osInfo = Environment.OSVersion; // Windows Vista以上。 if (osInfo.Platform == PlatformID.Win32NT && osInfo.Version >= new Version(6, 0)) { p.Verb = "runas"; } try { System.Diagnostics.Process.Start(p); } catch (System.ComponentModel.Win32Exception) { } } { // Amoeba Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(AmoebaConverter.FromTagString("Tag:AAAABkFtb2ViYQEgyeOUT6BPIlq8Nfe1kndaS0ETNlmJY90wt-Osb-l2mZqamJsU"))); // Test Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(AmoebaConverter.FromTagString("Tag:AAAABFRlc3QBIMEj2xDMP6_RAoVbePTEZwHz8Fcd29tqB9MY0JZyn6eS5iXI_A"))); } { Settings.Instance.Global_SearchKeywords.Clear(); Settings.Instance.Global_SearchKeywords.Add("Box"); Settings.Instance.Global_SearchKeywords.Add("Picture"); Settings.Instance.Global_SearchKeywords.Add("Movie"); Settings.Instance.Global_SearchKeywords.Add("Music"); Settings.Instance.Global_SearchKeywords.Add("Archive"); Settings.Instance.Global_SearchKeywords.Add("Document"); Settings.Instance.Global_SearchKeywords.Add("Executable"); Settings.Instance.Global_UploadKeywords.Clear(); Settings.Instance.Global_UploadKeywords.Add("Document"); var pictureSearchItem = new SearchItem() { Name = "Type - \"Picture\"" }; pictureSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(jpeg|jpg|jfif|gif|png|bmp)$", true))); var movieSearchItem = new SearchItem() { Name = "Type - \"Movie\"" }; movieSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(mpeg|mpg|avi|divx|asf|wmv|rm|ogm|mov|flv|vob)$", true))); var musicSearchItem = new SearchItem() { Name = "Type - \"Music\"" }; musicSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(mp3|wma|m4a|ogg|wav|mid|mod|flac|sid)$", true))); var archiveSearchItem = new SearchItem() { Name = "Type - \"Archive\"" }; archiveSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(zip|rar|7z|lzh|iso|gz|bz|xz|tar|tgz|tbz|txz)$", true))); var documentSearchItem = new SearchItem() { Name = "Type - \"Document\"" }; documentSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(doc|txt|pdf|odt|rtf)$", true))); var executableSearchItem = new SearchItem() { Name = "Type - \"Executable\"" }; executableSearchItem.SearchNameRegexCollection.Add(new SearchContains<SearchRegex>(true, new SearchRegex(@"\.(exe|jar|sh|bat)$", true))); Settings.Instance.SearchControl_SearchTreeItem.Children.Clear(); Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(pictureSearchItem)); Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(movieSearchItem)); Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(musicSearchItem)); Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(archiveSearchItem)); Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(documentSearchItem)); Settings.Instance.SearchControl_SearchTreeItem.Children.Add(new SearchTreeItem(executableSearchItem)); } { var tempBox = new Box(); tempBox.Name = "Temp"; var box = new Box(); box.Name = "Box"; box.Boxes.Add(tempBox); var route = new Route(); route.Add(box.Name); Settings.Instance.LibraryControl_Box = box; Settings.Instance.LibraryControl_ExpandedPaths.Add(route); } _amoebaManager.ConnectionCountLimit = 32; _amoebaManager.ListenUris.Clear(); _amoebaManager.ListenUris.Add(string.Format("tcp:{0}:{1}", IPAddress.Any.ToString(), _random.Next(1024, ushort.MaxValue + 1))); _amoebaManager.ListenUris.Add(string.Format("tcp:[{0}]:{1}", IPAddress.IPv6Any.ToString(), _random.Next(1024, ushort.MaxValue + 1))); var ipv4ConnectionFilter = new ConnectionFilter(ConnectionType.Tcp, null, new UriCondition(@"tcp:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3}).*"), null); var ipv6ConnectionFilter = new ConnectionFilter(ConnectionType.Tcp, null, new UriCondition(@"tcp:\[(\d|:)*\].*"), null); var tcpConnectionFilter = new ConnectionFilter(ConnectionType.Tcp, null, new UriCondition(@"tcp:.*"), null); var torConnectionFilter = new ConnectionFilter(ConnectionType.Socks5Proxy, "tcp:127.0.0.1:19050", new UriCondition(@"tor:.*"), null); var i2pConnectionFilter = new ConnectionFilter(ConnectionType.None, null, new UriCondition(@"i2p:.*"), null); _amoebaManager.Filters.Clear(); _amoebaManager.Filters.Add(ipv4ConnectionFilter); _amoebaManager.Filters.Add(ipv6ConnectionFilter); _amoebaManager.Filters.Add(tcpConnectionFilter); _amoebaManager.Filters.Add(torConnectionFilter); _amoebaManager.Filters.Add(i2pConnectionFilter); Directory.CreateDirectory(@"../Download"); _amoebaManager.DownloadDirectory = @"../Download"; if (CultureInfo.CurrentUICulture.Name == "ja-JP") { Settings.Instance.Global_UseLanguage = "Japanese"; } else { Settings.Instance.Global_UseLanguage = "English"; } // Trust.txtにあるノード情報を追加する。 if (File.Exists(Path.Combine(_serviceManager.Paths["Settings"], "Trust.txt"))) { var list = new List<string>(); using (StreamReader reader = new StreamReader(Path.Combine(_serviceManager.Paths["Settings"], "Trust.txt"), new UTF8Encoding(false))) { string line; while ((line = reader.ReadLine()) != null) { list.Add(line); } } Settings.Instance.Global_TrustSignatures.AddRange(list); } // Nodes.txtにあるノード情報を追加する。 if (File.Exists(Path.Combine(_serviceManager.Paths["Settings"], "Nodes.txt"))) { var list = new List<Node>(); using (StreamReader reader = new StreamReader(Path.Combine(_serviceManager.Paths["Settings"], "Nodes.txt"), new UTF8Encoding(false))) { string line; while ((line = reader.ReadLine()) != null) { list.Add(AmoebaConverter.FromNodeString(line)); } } _amoebaManager.SetOtherNodes(list); } } else { Version version; using (StreamReader reader = new StreamReader(Path.Combine(_serviceManager.Paths["Configuration"], "Amoeba.version"), new UTF8Encoding(false))) { version = new Version(reader.ReadLine()); } if (version <= new Version(4, 0, 18)) { // Covenant Settings.Instance.ChatControl_ChatCategorizeTreeItem.ChatTreeItems.Add(new ChatTreeItem(AmoebaConverter.FromTagString("Tag:AAAACENvdmVuYW50ASBJDZp3I-Ng-iWJwmq2Us-q45iWCQQpekfoZExA5Zom9EZtMqE"))); } } using (StreamWriter writer = new StreamWriter(Path.Combine(_serviceManager.Paths["Configuration"], "Amoeba.version"), false, new UTF8Encoding(false))) { writer.WriteLine(_serviceManager.AmoebaVersion.ToString()); } _connectionSettingManager = new ConnectionSettingManager(_amoebaManager); _connectionSettingManager.Load(_configrationDirectoryPaths["ConnectionSettingManager"]); _overlayNetworkManager = new OverlayNetworkManager(_amoebaManager, _bufferManager); _overlayNetworkManager.Load(_configrationDirectoryPaths["OverlayNetworkManager"]); _transferLimitManager = new TransfarLimitManager(_amoebaManager); _transferLimitManager.Load(_configrationDirectoryPaths["TransfarLimitManager"]); _transferLimitManager.Start(); _catharsisManager = new CatharsisManager(_amoebaManager, _bufferManager, _serviceManager); _catharsisManager.Load(_configrationDirectoryPaths["CatharsisManager"]); if (initFlag) { _catharsisManager.Save(_configrationDirectoryPaths["CatharsisManager"]); _transferLimitManager.Save(_configrationDirectoryPaths["TransfarLimitManager"]); _overlayNetworkManager.Save(_configrationDirectoryPaths["OverlayNetworkManager"]); _connectionSettingManager.Save(_configrationDirectoryPaths["ConnectionSettingManager"]); _amoebaManager.Save(_configrationDirectoryPaths["AmoebaManager"]); Settings.Instance.Save(_configrationDirectoryPaths["Settings"]); } } }
private MovementManager getMovementFor(Train train, bool isLocalTrain, NetworkTrainPlayer networkPlayer, GuiPlayersPointsElement playersPoints, NetworkEntityPlaying network) { float rotationSpeed = train.RotationSpeed; float translationSpeed = train.TranslationSpeed * GameMapSizeFactor.GetFactorForCurrentMapRelativeToFirstMap(); int maxPassengers = train.MaxPassengers; Transform mover = train.transform.parent ?? train.transform; TransformOperations.To(mover).SetRotationTo(FirstStation.transform.position); Route route = new Route(); route.Add(null); route.Add(FirstStation); if (isLocalTrain) { FirstStation.StartHighlight(); } Player player = networkPlayer == null ? PlayerFactory.CreateLocal(train) : networkPlayer; TrainPassengersLimit trainPassengersLimit = TrainPassengersLimitFactory.Get(TrainPassengersLimitType); trainPassengersLimit.SetLimit(maxPassengers); TrainPassengers passengers = new TrainPassengers(trainPassengersLimit, player); TimeCounter timeCounter = new TimeCounter(); timeCounters.Add(timeCounter); CurrentPoints points = new CurrentPoints(CurrentMap.GetCurrentMap(), passengers, timeCounter); playersPoints.AddPoints(player, points); GuiButtonRendererControl backToMenuButton = null; GuiButtonRendererControl showRankingButton = null; Movement firstMovement, normalMovement, goOutMovement; if (isLocalTrain) { Camera camera = Camera.main; Vector3 cameraOffset = -(mover.position - camera.transform.position); firstMovement = new ParallelMovement() .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationStartStepType, TERRESTRIAL)) .AddMovement(new TranslationMovement(camera.transform, translationSpeed, TranslationStartStepType, TERRESTRIAL, cameraOffset)); //firstMovement.Update(FirstStation.transform.position); normalMovement = new SequentialMovement() .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL)) .AddMovement(new ParallelMovement() .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL)) .AddMovement(new TranslationMovement(camera.transform, translationSpeed, TranslationDefaultStepType, TERRESTRIAL, cameraOffset))); goOutMovement = new SequentialMovement() .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL)) .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL)); MapCamera trainCamera = new TrainCamera(Camera.main); MapCamera freeCamera = new FreeCamera(Camera.main); CameraManager cameraManager = new CameraManager(trainCamera); backToMenuButton = new GuiButtonRendererControl(() => Application.LoadLevel(SceneNames.MENU)); showRankingButton = new GuiButtonRendererControl(() => SocialManager.ForegroundActions.ShowLeaderboard(CurrentMap.GetCurrentMap())); GuiButtonRendererControl setTrainCameraButton = new GuiButtonRendererControl(() => cameraManager.SetCamera(trainCamera)); GuiButtonRendererControl setFreeCameraButton = new GuiButtonRendererControl(() => cameraManager.SetCamera(freeCamera)); gui.AddElement(new GuiHudElement(passengers, timeCounter)); gui.AddElement(GuiElementFactory.GetSwitchCameraElement("Train\nCam", GuiPosition.DOWN_LEFT, setTrainCameraButton)); gui.AddElement(GuiElementFactory.GetSwitchCameraElement("Free\nCam", GuiPosition.DOWN_RIGHT, setFreeCameraButton)); input.AddLocal(route, cameraManager); input.AddButtons(backToMenuButton, showRankingButton, setTrainCameraButton, setFreeCameraButton); } else { firstMovement = new TranslationMovement(mover, translationSpeed, TranslationStartStepType, TERRESTRIAL); //firstMovement.Update(FirstStation.transform.position); goOutMovement = normalMovement = new SequentialMovement() .AddMovement(new RotationMovement(mover, rotationSpeed, RotationDefaultStepType, TERRESTRIAL)) .AddMovement(new TranslationMovement(mover, translationSpeed, TranslationDefaultStepType, TERRESTRIAL)); networkPlayer.SetRoute(route); } return new MovementManager(FirstStation, LastStation, route, firstMovement, normalMovement, goOutMovement, passengers, timeCounter, points, gui, backToMenuButton, showRankingButton, isLocalTrain, playersPoints, network); }