internal bool IsPlayerCloseToStation(GameObject player, StationController station) { StationJobGenerationRange stationRange = station.GetComponent <StationJobGenerationRange>(); float playerSqrDistanceFromStationCenter = (player.transform.position - stationRange.stationCenterAnchor.position).sqrMagnitude; return(stationRange.IsPlayerInJobGenerationZone(playerSqrDistanceFromStationCenter)); }
static void Postfix(ref StationController stationController) { if (stationController.stationInfo.YardID == "FF") { foreach (CargoGroup cargoGroup in stationController.proceduralJobsRuleset.inputCargoGroups) { if (cargoGroup.cargoTypes.Contains(CargoType.Corn)) { cargoGroup.cargoTypes.Add(Main.MILK); break; } } } else if (stationController.stationInfo.YardID == "FM") { foreach (CargoGroup cargoGroup in stationController.proceduralJobsRuleset.outputCargoGroups) { if (cargoGroup.cargoTypes.Contains(CargoType.Corn)) { cargoGroup.cargoTypes.Add(Main.MILK); break; } } } }
public bool ChangeStation(StationController station) { if (frequency >= station.frequency - 20 && frequency <= station.frequency + 20) { if (currentStation == null) { currentStation = station; currentStation.Play(); currentStation.currentAudio.volume = 0; //noiseSource.Stop(); } else { if (frequency >= station.frequency - 5 && frequency <= station.frequency + 5) { currentStation.currentAudio.volume = 1; noiseSource.volume = 0.1f; } else { noiseSource.volume = (Mathf.Abs(frequency - station.frequency) / 100) * 3; currentStation.currentAudio.volume += Mathf.Abs(frequency - station.frequency) / 150; } } return(true); } return(false); }
private void SetStationLinks() { StationController thisStation = selectedObj.GetComponent <StationController>(); foreach (StationModel station in data.stations) { foreach (Items item in station.factory.inputItems) { foreach (Items thisItem in thisStation.GetOutputItems()) { if (thisItem.name == item.name) { station.lineTarget = thisStation.transform.position; station.lineColor = item.color; station.NotifyChange(); } } } foreach (Items item in station.factory.outputItems) { foreach (Items thisItem in thisStation.GetInputItems()) { if (thisItem.name == item.name) { station.lineTarget = thisStation.transform.position; station.lineColor = item.color; station.NotifyChange(); } } } } }
//Call this every time a battle group is Instantiated public void Initialize(StationController ps, Team team, int tagNum) { parentStation = ps; this.team = team; this.tagNumber = tagNum; if (team == Team.Team1) { //Blue Renderer.color = new Color(0f, 0f, 1f, 0.5f); } else if (team == Team.Team2) { //Red Renderer.color = new Color(1f, 0f, 0f, 0.5f); } else if (team == Team.Team3) { //Green Renderer.color = new Color(0f, 1f, 0f, 0.5f); } else { //Grey Renderer.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); } GroupName.text = "BG\n" + tagNum; }
/// <summary> /// When the traveler arrived to the station, /// it has to decide how to get to the next waypoint or its final destination. /// </summary> /// <param name="station"></param> public virtual void ArrivedAt(StationController station) { wayPointIndex = itinerary.FindStopIndex(station); SetAnimation(false); startPosition = station.transform.position; CheckInfo(); if (wayPointIndex < itinerary.StageInfos.Count) { var info = itinerary.StageInfos[wayPointIndex]; //Debug.Log(info); if (info.Category == LineCategory.Walk) { ++wayPointIndex; startTime = Time.time; journeyLength = Vector3.Distance(startPosition, CurrentDestination()); SetAnimation(true); return; } } else { // The last part of walking! SetAnimation(true); return; } CurrentStop().QueueTraveler(this); }
public DebuggerWindow(StationController stationController) { InitializeComponent(); Dispatcher.Invoke(() => IsEnabled = false); //disable until connected _stationController = stationController; _logViewModel = new ViewModels.LogViewModel(); logView.DataContext = _logViewModel; _sendCommandViewModel = new ViewModels.SendCommandViewModel(); sendCommandView.DataContext = _sendCommandViewModel; _scenarioSelectViewModel = new ViewModels.ScenarioSelectViewModel(); _scenarioSelectViewModel.ScenarioCalled += ScenarioViewModel_ScenarioCalled; scenarioSelectView.DataContext = _scenarioSelectViewModel; _sendCommandViewModel.ExecuteExpressionCommand = new Commands.RelayCommand(command => { _stationController.SendCommand((string)command); _sendCommandViewModel.CommandExpression = string.Empty; }, _ => !string.IsNullOrEmpty(_sendCommandViewModel.CommandExpression)); _stationController.ClientConnected += StationController_ClientConnected; _stationController.ClientDisconnected += StationController_ClientDisconnected; _stationController.DataReceived += StationController_DataReceived; _stationController.RunningStateChanged += StationController_RunningStateChanged; _scenarioSelectViewModel.Scenarios = new System.Collections.ObjectModel.ObservableCollection <Scenario>(_stationController.Scenarios); }
public void GetStations() { //Arrange var controller = new StationController(new StationService(new StationRepositoryStub())); var expected = new List <StationVm>(); var Stations = new StationVm() { StationId = 0, StationName = "Stavanger", }; expected.Add(Stations); expected.Add(Stations); expected.Add(Stations); // Act var actionResult = (ViewResult)controller.Index(); var result = (List <StationVm>)actionResult.Model; //Assert Assert.AreEqual(actionResult.ViewName, ""); for (var i = 0; i < result.Count; i++) { Assert.AreEqual(expected[i].StationId, result[i].StationId); Assert.AreEqual(expected[i].StationName, result[i].StationName); } }
/// <summary> /// Get a itinerary from station 'start' to station 'end' based on the 'preference'. /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="preference"></param> /// <returns></returns> public Itinerary GetItinerary(StationController start, StationController end, TravelPreference preference) { if (start.Equals(end)) { return(null); } if (start.outOfService || end.outOfService) { return(null); } var itineraries = new List <Itinerary>(GetItineraries(start, end)); switch (preference) { case TravelPreference.none: break; case TravelPreference.transit: itineraries.Sort((x, y) => x.Transits.Count.CompareTo(y.Transits.Count)); break; default: case TravelPreference.time: itineraries.Sort((x, y) => x.GetTotalTravelTime().CompareTo(y.GetTotalTravelTime())); break; } if (itineraries.Count < 1) { //Debug.LogFormat("No itinery between {0}, {1}", start, end); return(null); } return(itineraries[0]); }
/// <summary> /// Traveler will move towards the next waypoint, /// If it has reached the current destination, ArrivedAt(station) will be called to decide what to do next. /// If the current destination is the final destination, the gameobject will be deactivated. /// </summary> void Update() { if (!meshRenderer.enabled) { return; } if (Vector3.Distance(transform.position, CurrentDestination()) < 1) { if (CurrentDestination() == destination.transform.position) { SetAnimation(false); gameObject.SetActive(false); return; } StationController station = CurrentStop(); if (station != null) { SetAnimation(false); ArrivedAt(station); return; } } float distCovered = (Time.time - startTime) * speed; float fracJourney = distCovered / journeyLength; transform.position = Vector3.Lerp(startPosition, CurrentDestination(), fracJourney); }
public static GameObject FindClosest(GameObject target) { Player targetPlayer = PlayerDatabase.Instance.GetObjectPlayer(target); GameObject closest = null; float smallestMagnitude = 999999999999999999999999999999999f; foreach (GameObject gameObject in _Instances) { if (targetPlayer != PlayerDatabase.Instance.GetObjectPlayer(gameObject)) { continue; } else { StationController stationController = gameObject.GetComponent <StationController>(); if (stationController != null && !stationController.Constructed) { continue; } } float magnitude = (target.transform.position - gameObject.transform.position).sqrMagnitude; if (magnitude < smallestMagnitude) { closest = gameObject; smallestMagnitude = magnitude; } } return(closest); }
/// <summary> /// Based on the id of the station, return the before and after stations. /// Only return stations with travel time > 0 from this station. /// If the station is at the side, only one will return. /// </summary> /// <param name="stationId"></param> /// <returns>A list of station ids</returns> public List <StationController> GetAdjacentStations(StationController station) { List <StationController> adjacents = new List <StationController>(); //int index = stations.FindIndex(x => x.Equals(station)); int index = GetIndex(station); if (index > 0 && index < stations.Count) { StationController previous = stations[index - 1]; if (allowTraveling[index - 1]) { adjacents.Add(previous); } } if (index >= 0 && index < stations.Count - 1) { StationController next = stations[index + 1]; try { if (allowTraveling[index]) { adjacents.Add(next); } } catch (Exception) { Debug.LogError(station); Debug.LogError(index); } } return(adjacents); }
// Use this for initialization void Start() { dialogController = dialogCanvas.GetComponent <DialogController>(); stationController = stationObject.GetComponent <StationController>(); Begin(); }
protected override object Action(object obj) { Driver driver = (Driver)obj; StationController.PingMyStation(driver.session_token); DateTime startTime = DateTime.Now; do { Thread.Sleep(2000); GetUserResponse user = StationController.GetUser(driver.session_token, driver.user_id); if (user.stations.Count > 0 && user.stations[0].accessible != null && user.stations[0].accessible == "available") { return(null); } }while (DateTime.Now - startTime < TimeSpan.FromSeconds(10.0)); Thread.CurrentThread.Abort(); return(null); }
static void Main(string[] args) { var station = new Station(); var shuttle = new Shuttle(1, "Columbia"); IRule dockingRule = new DockingRule(shuttle); ICommand dock = new Dock(station, shuttle, dockingRule); var controller = new StationController(); controller.ExecuteCommand(dock, DockingSuccessful, DockingFailed); var shuttle2 = new Shuttle(2, "Discovery"); dockingRule = new DockingRule(shuttle2); dock = new Dock(station, shuttle2, dockingRule); controller.ExecuteCommand(dock, DockingSuccessful, DockingFailed); var shuttle3 = new Shuttle(3, "Challenger"); dockingRule = new DockingRule(shuttle3); dock = new Dock(station, shuttle3, dockingRule); controller.ExecuteCommand(dock, DockingSuccessful, DockingFailed); var undock = new Undock(station, shuttle2); controller.ExecuteCommand(undock, Undocked, (result) => { }); controller.ExecuteCommand(dock, DockingSuccessful, DockingFailed); }
private void backgroundWorkerVerifying_DoWork(object sender, DoWorkEventArgs e) { m_verifyOK = true; try { StationController.ConnectDropbox(1024 * 1024 * 500); //500MB } catch (DropboxNoSyncFolderException) { m_verifyOK = false; } catch (DropboxWrongAccountException) { m_verifyOK = false; } catch (ConnectToCloudException) { MessageBox.Show(I18n.L.T("ConnectCloudError"), "Waveface"); m_verifyOK = false; } catch { m_verifyOK = false; } }
private void label_switchAccount_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { DialogResult _confirm = MessageBox.Show(I18n.L.T("ChangeOwnerWarning", lblUserName.Text), "Waveface", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (_confirm == DialogResult.No) { return; } Cursor = Cursors.WaitCursor; try { StationController.RemoveOwner(m_stationToken); MessageBox.Show(I18n.L.T("ChangeOwnerSuccess", m_driver.email), "waveface"); string statioinUI = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "StationUI.exe"); Process.Start(statioinUI); Application.Exit(); } catch (Exception _e) { MessageBox.Show(I18n.L.T("ChangeOwnerError") + " : " + _e, "waveface"); } finally { Cursor = Cursors.Default; } }
void Awake() { pedGlobalParam = FindObjectOfType <FlashPedestriansGlobalParameters>(); logSeriesId = LoggerAssembly.GetLogSeriesId(); //LOG STATION LOG INFO log.Info(string.Format("{0}:{1}:{2}", logSeriesId, "title", GetIdAndName() + " log")); //LOG STATION QUEUING CHART INFO log.Info(string.Format("{0}:{1}:{2}:{3}", logSeriesId, "chart type", 0, UIChartTypes.Line.ToString())); //LOG STATION LOG INFO log.Info(string.Format("{0}:{1}:{2}:{3}", logSeriesId, "legend", 0, GetIdAndName() + " queuing")); Collider[] coll = Physics.OverlapSphere(this.transform.position, radiusToCheckStations * 10, 1 << LayerMask.NameToLayer("Stations")); List <StationController> aux = new List <StationController>(); // Add all the stations found except for this one foreach (Collider C in coll) { StationController station = C.GetComponent <StationController>(); if (!station.Equals(this)) { aux.Add(station); } } stationsNearThisStation = aux.ToArray(); }
private void ShowConfirmationMessage(DataGridViewCellEventArgs e, int id) { if (MessageBox.Show("¿Está seguro que desea eliminar la estación?", "Ventana de confirmación", MessageBoxButtons.YesNo) == DialogResult.Yes) { StationController.RemoveStationFromDGV(dataGridView, id, e.RowIndex); } }
internal List <StationController> GetRemainingStations(StationController station, LineDirection direction) { int index = GetIndex(station); var remaining = stations.GetRange(index, stations.Count - index); return(remaining); }
// Build // Station public void BuildStationOn(Vector2 pos) { bool validPos = true; //TODO: Add unbuildable area. validPos &= Mathf.Abs(pos.x) <= ViewRange.x / 2.0f - 2.0f; validPos &= Mathf.Abs(pos.y) <= ViewRange.y / 2.0f - 1.8f; // Check overlap foreach (var station in StationList) { validPos &= Vector2.Distance(pos, station.Pos) > 1.0f; } if (validPos) { Debug.Log("Build station on" + pos); ParticleSystem Smoke = Instantiate(SmokePS, pos, Quaternion.identity); Smoke.Play(); GameObject newStation = Instantiate(StationPrefab, pos, Quaternion.identity, StationGroup.transform); StationController controller = newStation.GetComponent <StationController>(); Station station = controller.Initialize(false); StationList.Add(station); AudioSource.PlayClipAtPoint(buildStationAC, pos); //TODO: Manage animator UpdateIdleMailTargetStation(); MoneyLeft -= GameMaster.Instance.StationCost; } else { //TODO: Build error } }
private void btnAddBS_Click(object sender, EventArgs e) { this.name = this.input_name.Text; this.capacity = this.input_capacity.Text; if (this.name != null && this.capacity != null) { if (StationController.IsNumberCapacity(this.capacity)) { if (!this.stationController.RepeatedPatent(this.name)) { this.label_error.ForeColor = Color.Transparent; this.input_name.ReadOnly = true; this.input_capacity.ReadOnly = true; this.show_same.Text = this.name; this.combo_box_station.Enabled = true; StationController.FeedComboBox(combo_box_station); } else { Error("Nombre ya Ingresado"); } } else { Error("Capacidad Campo Numérico"); } } else { Error("Error, Campo Vacío"); } }
public void Initialize() { Controller = gameObject.GetComponent <StationController>(); if (Controller != null) { StationRange = Controller.GetComponent <StationJobGenerationRange>(); StorageTracks = GetStorageTracks(Controller); PlatformTracks = GetLoadingTracks(Controller); // register tracks for train spawning, since they are ignored in the base game foreach (Track t in PlatformTracks.Union(StorageTracks)) { YardTracksOrganizer.Instance.InitializeYardTrack(t); YardTracksOrganizer.Instance.yardTrackIdToTrack[t.ID.FullID] = t; } var sb = new StringBuilder($"Created generator for {Controller.stationInfo.Name}:\n"); sb.Append("Coach Storage: "); sb.AppendLine(string.Join(", ", StorageTracks.Select(t => t.ID))); sb.Append("Platforms: "); sb.Append(string.Join(", ", PlatformTracks.Select(t => t.ID))); PassengerJobs.ModEntry.Logger.Log(sb.ToString()); RegisterStation(Controller, this); // check if the player is already inside the generation zone float playerDist = StationRange.PlayerSqrDistanceFromStationCenter; PlayerWasInGenerateRange = StationRange.IsPlayerInJobGenerationZone(playerDist); } }
/// <summary> /// Controls the behaviour when the pedestrian arrives to a station. /// </summary> /// <param name="station">Station where the pedestrian has arrived.</param> public override void ArrivedAt(StationController station) { // Update the current stop where the pedestrian is stopIndex = routing.GetIndexFrom(station); // Check if the itinerary is still valid in the routing if (station.outOfService || stopIndex == -1 || !routing.itinerary.IsValid(stopIndex)) { RedoRouteFromStation(station); if (embarked) { Disembark(station); } } else { //Get the information of the next part of the route var info = routing.GetRouteInfoFrom(station); if (info == null || info.Category == LineCategory.Walk) { // The pedestrian will walk from this point FSM.SetBool("OnStation", false); if (embarked) { Disembark(station); } } else { // The pedestrian will take the commute from this point station.QueueTraveler(this); } } }
public void ChangeFrequency(float angle) { if (angle <= 90f || angle >= 270f) { pointer.transform.localRotation = Quaternion.Euler(0f, 0f, angle); } frequency = GetFrequency(angle); for (int i = 0; i < stations.Length; i++) { if (ChangeStation(stations[i])) { return; } } if (currentStation != null) { Debug.Log("bbbb"); currentStation.Stop(); currentStation = null; noiseSource.volume = 1; noiseSource.Play(); } //Debug.Log(angle+" -> "+GetFrequency(angle)); }
/// <summary> /// Disembark the pedestrian from a certain station. /// </summary> /// <param name="station">Station from which the pedestrian will disembark.</param> public void Disembark(StationController station) { this.GetComponent <LODGroup>().enabled = true; this.transform.position = station.transform.position; embarked = false; UpdateInfoBalloon(); }
internal static List <Track> GetStorageTracks(StationController station) { var trackNames = StorageTrackNames[station.stationInfo.YardID]; return(AllTracks .Where(t => trackNames.Contains(t.ID.ToString())) .ToList()); }
internal static List <Track> GetLoadingTracks(StationController station) { var trackNames = PlatformTrackNames[station.stationInfo.YardID]; var result = AllTracks.Where(t => trackNames.Contains(t.ID.ToString())).ToList(); return(result); }
public void ChangeStationState(StationController stationController, bool value) { if (stationController != null) { stationController.GetComponentInParent <RoutingController>().SetStationOutOfService(stationController, value); stationController.SendMessage("UpdateStationMaterial", value); } }
private static void Postfix(JobChainController __result, StationController startingStation, Track startingTrack, List <TrainCar> transportedTrainCars, System.Random rng) { if (NetworkManager.IsClient() && NetworkManager.IsHost() && SingletonBehaviour <NetworkJobsManager> .Instance) { SingletonBehaviour <NetworkJobsManager> .Instance.newlyGeneratedJobChains.Add(__result); SingletonBehaviour <NetworkJobsManager> .Instance.newlyGeneratedJobChainStation = startingStation; } }
public override void tick(StationController stationController) { if (stationController != null && stationController.getState() != StationController.State.ACTIVE) { return; } this.armRaise.tick(Time.deltaTime); this.mainRotator.tick(Time.deltaTime); this.armSpinRotator.tick(Time.deltaTime); if (this.currentState != KMGExperience.State.LOWERING && this.currentState != KMGExperience.State.STOPPING) { if (this.mainRotator.getCurrentSpeed() > this.mainRotator.getMaxSpeed() * 0.8f && this.armRaise.startFromTo()) { Fabric.EventManager.Instance.PostEvent(this.raiseArmSound.name, base.gameObject); } } else if (this.armSpinRotator.getCurrentSpeed() < this.armSpinRotator.getMaxSpeed() * 0.2f && this.armRaise.startToFrom()) { Fabric.EventManager.Instance.PostEvent(this.lowerArmSound.name, base.gameObject); } if (this.currentState == KMGExperience.State.STARTING) { if (this.mainRotator.reachedFullSpeed()) { this.armSpinRotator.start(); this.currentState = KMGExperience.State.RUNNING; base.triggerRunloopSound(); } } else if (this.currentState == KMGExperience.State.RUNNING) { if (this.armSpinRotator.getCompletedRotationsCount() >= this.spins) { this.armSpinRotator.stop(); this.currentState = KMGExperience.State.LOWERING; } } else if (this.currentState == KMGExperience.State.LOWERING && this.armSpinRotator.isStopped()) { this.currentState = KMGExperience.State.STOPPING; this.mainRotator.stop(); base.triggerDecelerateSound(); } foreach(Transform T in armRaiseAxis) { T.localRotation = armRaiseAxis[0].localRotation; } foreach(Transform T in armSpinAxis) { T.localRotation = armSpinAxis[0].localRotation; } foreach (Transform T in armAxis) { T.localRotation = armSpinAxis[0].localRotation; } }
public override void tick(StationController stationController) { if (currentPhase != null && animating) { currentPhase.Run(); if (!currentPhase.running) { NextPhase(); } } }
public override void tick(StationController stationController) { if (currentPhase != null && animating) { currentPhase.Run(); if (!currentPhase.running) { Debug.Log("-=====[Next Phase]=====-"); NextPhase(); } } }
public override void tick(StationController stationController) { if (CurrentState == State.Running) { Time += UnityEngine.Time.deltaTime; if (Time > 60) { CurrentState = State.Stopped; Time = 0; } } }
public override void tick(StationController stationController) { }
public bool BuyItem(Inventory.Row itemRow) { if(mCredits >= itemRow.credits){ mCurrentItem = itemRow; mCredits -= itemRow.credits; mState = PlayerState.Navigation; mDOCK_ENABLED = false; GameObject[] all_stations = GameObject.FindGameObjectsWithTag("Station"); GameObject oldStation = mDestinationStation; while(mDestinationStation == oldStation){ int randIndex = (int)(Random.value * all_stations.Length); mDestinationStation = all_stations[randIndex]; } mClosestStation.GetComponent<StationController>().tearDownShopPanel(); mClosestStation = null; return true; } return false; }
void perceptionEnter(GameObject other) { if (other.GetComponent<CWMonoBehaviour>().checkFlags(ObjectFlags.STATION)) { mClosestStation = other.GetComponent<StationController>(); } }
void perceptionExit(GameObject other) { if (mCanDock && other.GetComponent<CWMonoBehaviour>().checkFlags(ObjectFlags.STATION)) { mClosestStation = null; } }