public ActionResult Save(FlightPathFormViewModel flightPathFormViewModel) { bool exists = flightPathRepository.GetFlightPathByUniqueIndex(flightPathFormViewModel.DestinationId, flightPathFormViewModel.DepartureId) != null; if (exists && flightPathFormViewModel.FlightPathId == 0) //It applies only for New FlightPath not Edit { var containerViewModel = InitializeNewContainerFormViewModel(flightPathFormViewModel); ModelState.AddModelError("FlightPath.DestinationId", "This Destination is already part of this flight path"); return(View("FlightPathForm", containerViewModel)); } if (!ModelState.IsValid) { var containerViewModel = InitializeNewContainerFormViewModel(flightPathFormViewModel); return(View("FlightPathForm", containerViewModel)); } if (flightPathFormViewModel.FlightPathId == 0) { var planets = planetRepository.GetPlanetsByIdRaw(flightPathFormViewModel.DepartureId, flightPathFormViewModel.DestinationId); if (planets.Count != 2) { return(HttpNotFound()); } var flightPath = new FlightPath(planets.Single(p => p.PlanetID == flightPathFormViewModel.DepartureId), planets.Single(p => p.PlanetID == flightPathFormViewModel.DestinationId)); flightPathRepository.Add(flightPath); } unitOfWork.Complete(); return(RedirectToAction("Index", "FlightPath")); }
private void InitBallParts() { circ2 = new CollisionCircleD(); flightPath = new FlightPath(); flightPath.Load(); launchButton = new Button01(); }
public Parameters(FlightPath depart, FlightPath returning, DateTime depDate, DateTime?retDate) { leavingPath = depart; returningPath = returning; departingDate = depDate; returningDate = retDate; }
public async Task <FlightPath> GetFlightPath(int matchId) { var tournaments = _tournament.GetMongoDbCollection("TournamentMatchId"); var tournamentMatchId = tournaments.FindAsync(Builders <Event> .Filter.Where(cn => cn.MatchId == matchId)).Result.FirstOrDefaultAsync().Result.Id; var VehicleLeave = _genericRepository.GetMongoDbCollection("VehicleLeave"); var vehicleTransport = VehicleLeave.FindAsync(Builders <VehicleLeave> .Filter.Where(cn => cn.MatchId == tournamentMatchId && cn.Vehicle.VehicleType == "TransportAircraft")).Result.ToListAsync().Result.OrderBy(o => o.Id); var flightPathfirstPosition = vehicleTransport.Take(1).FirstOrDefault(); var flightPathlastPosition = vehicleTransport.TakeLast(1).LastOrDefault(); var fpath = new FlightPath(); fpath.MatchId = matchId; fpath.MapName = _matchRepository.GetMapName(tournamentMatchId).Result; fpath.FlightPathStart = flightPathfirstPosition.Character.Location; fpath.FlightPathEnd = flightPathlastPosition.Character.Location; return(await Task.FromResult(fpath)); }
public Params(int departureAirportId, int destinationAirportId, DateTime departureDate, DateTime?returnDate, FlightPath departureFlightPath) { DepartureAirportId = departureAirportId; DestinationAirportId = destinationAirportId; DepartureDate = departureDate; ReturnDate = returnDate; DepartureFlightPath = departureFlightPath; }
private void Awake() { flightPath = GameObject.FindObjectOfType <FlightPath>().GetComponent <FlightPath>(); targetDestination = Vector3.zero; healthComponent = GetComponent <OnHealth>(); //TODO : Create a better method of grabbing meshes }
public void UnsetPath() { if (currentPath != null) { currentPath.DestroyFlightTunnel(); currentPath = null; } }
void Awake() { // Keep references to the bee's flight path and colliders. flightPath = GetComponentInChildren <FlightPath>(); colliders = GetComponentsInChildren <Collider>(); // Create audio sources for sound playback. stunnedSource = AudioHelper.CreateAudioSource(gameObject, stunnedSound); }
//This is called from FlightPath.cs public void SetStageTimer() { //Finds the reference GameObject Pathfinder = GameObject.Find("Pathfinder"); FlightPath flightPath = Pathfinder.GetComponent <FlightPath> (); //Stores the variable "stopTime" into StageTimeLeft StageTimeLeft = flightPath.stopTime; }
public Position[] pathfind(FlightPath flightpath) { Position startPos = _coordinatesService.CalculatePosition(flightpath.startCoordinate); Position endPos = _coordinatesService.CalculatePosition(flightpath.endCoordinate); Position[] path = grid.GetPath(startPos, endPos); return(path); }
private FlightPathViewModel(FlightPath flightPath) { FlightPathId = flightPath.FlightPathId; DepartureId = flightPath.DepartureId; DepartureName = flightPath.Departure.Name; DestinationId = flightPath.DestinationId; DestinationName = flightPath.Destination.Name; Distance = flightPath.Distance; }
// Use this for initialization void Start() { //Instance, and makes Pathfinder look at the first waypoint cameraMovement = this; waypoints [0].LookAt(transform.position); for (int x = 1; x < waypoints.Count; x++) { //This should be what makes the Pathfinder look at every waypoint when needed to waypoints [x].LookAt(waypoints [x - 1].transform.position); } }
public List <Coordinate> FindPath(Coordinate startPoint, Coordinate endPoint) { AStarService astar = new AStarService(); //TODO: Get start and end from UTM FlightPath fp = new FlightPath(startPoint.latitude, startPoint.longitude, endPoint.latitude, endPoint.longitude); List <Position> paths = astar.pathfind(fp).ToList(); List <Coordinate> coordinates = paths.Select(_coordinateService.CalculateCoordinate).ToList(); return(coordinates); }
public Snowball(IEnumerable <Vector2> flightPath) : base(SnowballFightGame.SnowballDef, flightPath.First(), SnowballFightGame.SnowballLayer, state: States.Fly) { FlightPath = flightPath.GetEnumerator(); if (!FlightPath.MoveNext()) { State = States.Dead; } DrawOffset = new(-8, -8); }
private void PurchaseButton_Click(object sender, RoutedEventArgs e) { // grab the flight paths from the list views var departRoute = DepartList.SelectedItem as FlightPath; FlightPath returnRoute = null; if (passedInParams.returningDate != null) { returnRoute = ReturnList.SelectedItem as FlightPath; } // and navigate to the checkoutpage with the appropriate parameters being passed in Frame.Navigate(typeof(CheckoutPage), new CheckoutPage.Parameters(departRoute, returnRoute, passedInParams.departingDate, passedInParams.returningDate)); }
public FlightEnabledNavigator( INavigationProvider innerNavigator, IFlightEnabledPlayerMover playerMover, IFlightNavigationArgs flightNavigationArgs) { this.logger = new Logger(this); this.innerNavigator = innerNavigator; this.playerMover = playerMover; this.flightNavigationArgs = flightNavigationArgs; Navigator.NavigationProvider = this; CurrentPath = new FlightPath(Vector3.Zero, Vector3.Zero, flightNavigationArgs); logger.Verbose("Replacing Navigator with Flight Navigator."); }
public FlightEnabledNavigator( INavigationProvider innerNavigator, IFlightEnabledPlayerMover playerMover, IFlightNavigationArgs flightNavigationArgs) { logger = new Logger(this); this.innerNavigator = innerNavigator; this.playerMover = playerMover; this.flightNavigationArgs = flightNavigationArgs; Navigator.NavigationProvider = this; CurrentPath = new FlightPath(Vector3.Zero, Vector3.Zero, flightNavigationArgs); logger.Verbose(Localization.Localization.FlightEnabledNavigator_Enabled); }
public void SetEndTimer() { //finds the reference GameObject Pathfinder = GameObject.Find("Pathfinder"); FlightPath flightPath = Pathfinder.GetComponent <FlightPath> (); //Stores the variable "TimeTillEnd" into EndTimer EndTimer = flightPath.TimeTillEnd; //Sets bool to TRUE so script can start the end timer StartEndTimer = true; GameObject scoreDisplay = GameObject.Find("ScoreDisplay"); ScorePoints scorePoints = scoreDisplay.GetComponent <ScorePoints> (); //Calls the final score function in ScorePoints.cs scorePoints.ScoreResult(); }
public IHttpActionResult GetDistance(int?destinationId, int?departureId) { if (!departureId.HasValue || !destinationId.HasValue) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var planets = planetRepository.GetPlanetsByIdRaw(departureId ?? (int)InvalidPropertyValues.undefinedValue, destinationId ?? (int)InvalidPropertyValues.undefinedValue); if (planets.Count != 2) { throw new HttpResponseException(HttpStatusCode.NotFound); } var distance = FlightPath.FindDistance(planets[0], planets[1]); return(Ok(distance)); }
// Update is called once per frame public virtual void DoSpawnAndParent() { FlightPath fp = GameObject.Instantiate(flightPathToSpawn) as FlightPath; fp.transform.parent = transform; fp.transform.position = routes[0].pathNodes[0].position; fp.transform.rotation = routes[0].pathNodes[0].rotation; foreach (FlightRoute route in routes) { route.targetGameObject = fp.gameObject; } FlightPathTrigger[] triggers = gameObject.GetComponentsInChildren <FlightPathTrigger>(); foreach (FlightPathTrigger fpt in triggers) { fpt.targetFlightPath = fp; } fp.routes = routes; fp.Initialize(); }
public override void Update(MooseGame _game, GameTime gameTime) { if (State == States.Fly) { Position = FlightPath.Current; FlightPath.MoveNext(); FlightPath.MoveNext(); FlightPath.MoveNext(); if (IsBlocked()) { State = States.Hit; StateCompleteAction = () => State = States.Dead; } } if (State == States.Dead) { Remove = true; } base.Update(_game, gameTime); }
/// <summary> /// Call this to snap the end of a flight path to an opened honeycomb. This method would /// only perform the snapping if there is an opened honeycomb that is close enough. /// </summary> /// <param name="path">Flight path for a given bee.</param> public void SnapToHoneycomb(FlightPath path) { // Get the end point of the path. Vector2 current = path.GetLastPosition(); // Go through and find an open honeycomb that is close by the end point. foreach (GameObject honeycombObject in openHoneycombs) { Vector2 testPos = honeycombObject.transform.position; if (Vector2.Distance(current, testPos) < honeycombSize * 0.55f) { Honeycomb honeycomb = honeycombObject.GetComponent <Honeycomb>(); // Snap the path to the honeycomb. path.ConnectToHoneycomb(honeycomb); // Register this path with the honeycomb, this is so that we can update // the path's color if the honeycomb is closed before the bee reaches it. honeycomb.RegisterPath(path); break; } } }
private async Task<GeneratePathResult> GeneratePath(Vector3 start, Vector3 end) { CurrentPath = new FlightPath(start, end, flightNavigationArgs); FlightPath path; if (FlightPath.Paths.TryGetValue(CurrentPath.Key, out path)) { CurrentPath = path; return GeneratePathResult.SuccessUseExisting; } if (await CurrentPath.BuildPath()) { if (CurrentPath.Count > 0) { FlightPath.Paths[CurrentPath.Key] = CurrentPath; return GeneratePathResult.Success; } } logger.Error( Localization.Localization.FlightEnabledNavigator_NoPath); Clear(); Navigator.NavigationProvider = innerNavigator; #pragma warning disable 4014 Task.Factory.StartNew( #pragma warning restore 4014 () => { Thread.Sleep(10000); logger.Info(Localization.Localization.FlightEnabledNavigator_ResetNavigatonProvider); Navigator.NavigationProvider = this; }); return GeneratePathResult.Failed; }
/// <summary> /// Keep a reference to the path in our list. This is used to update all connected paths /// when the honeycomb closes. /// </summary> /// <param name="path">The flight path to be tracked.</param> public void RegisterPath(FlightPath path) { paths.Add(path); }
bool drag = false; // Are we currently dragging. void Update() { // Check if we are currently dragging the mouse. if (!drag) { // We only enter drag mode during gameplay and when the player hold the left mouse button. if (GameplayManager.Instance.CanPlay() && Input.GetMouseButtonDown(0)) { //Create 3D ray pointing into the world at the mouse position Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Check if our ray is hitting anything in the scene RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, 1000f)) { //Check if the ray hits a bee. If so, we have 'selected the bee if (hitInfo.transform.CompareTag("Bee")) { //Make sure the bee is not stunned BeeController bee = hitInfo.transform.GetComponent <BeeController>(); if (!bee.IsStunned()) { //Append waypoints to path for this bee, //starting at current position currentPath = hitInfo.transform.GetComponentInChildren <FlightPath>(); currentPath.Clear(); currentPath.Append(hitInfo.transform.position); //Enter dragmode, keep appending waypoints to bee's path drag = true; } } } } } else { // Check if we should stay in drag mode. We will exit if the bee has reached a honeycomb // or the end of its path. if (currentPath == null || currentPath.EndReached() || currentPath.Waypoints.Count == 0) { drag = false; } else { // Create a 3D ray pointing into the world and test against the play plane, which is // set at position with z equals 0. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; playPlane.Raycast(ray, out hitInfo, 1000f); // Check if we have dragged far enough from our last waypoint. Vector3 currentPosition = hitInfo.point; Vector3 lastPosition = currentPath.GetLastPosition(); if (Vector3.Distance(currentPosition, lastPosition) > segmentLength) { // Keep adding fixed-length segments up to the current position. This way the // dash-line for the path will be consistent instead of looking stretched. float dragLength = Vector3.Distance(currentPosition, lastPosition); Vector3 direction = Vector3.Normalize(currentPosition - lastPosition); float totalLength = segmentLength; while (totalLength < dragLength) { currentPath.Append(lastPosition + (direction * totalLength)); totalLength += segmentLength; } } // Check if the player has stopped dragging. if (Input.GetMouseButtonUp(0)) { // Try to snap the bee's path to the closest honeycomb. Beehive.Instance.SnapToHoneycomb(currentPath); // Exit drag mode. drag = false; } } } }
public static FlightPathViewModel CreateFromModel(FlightPath flightPath) { return(new FlightPathViewModel(flightPath)); }
private async Task<GeneratePathResult> GeneratePath(Vector3 start, Vector3 end) { CurrentPath = new FlightPath(start, end, flightNavigationArgs); FlightPath path; if (FlightPath.Paths.TryGetValue(CurrentPath.Key, out path)) { CurrentPath = path; return GeneratePathResult.SuccessUseExisting; } if (await CurrentPath.BuildPath()) { if (CurrentPath.Count > 0) { FlightPath.Paths[CurrentPath.Key] = CurrentPath; return GeneratePathResult.Success; } } logger.Error( "Error encountered trying to find a path. Trying innerNavigator for 10 seconds before re-enabling flight."); Clear(); Navigator.NavigationProvider = innerNavigator; #pragma warning disable 4014 Task.Factory.StartNew( #pragma warning restore 4014 () => { Thread.Sleep(10000); logger.Info("Resetting NavigationProvider to Flight Navigator."); Navigator.NavigationProvider = this; }); return GeneratePathResult.Failed; }
private decimal CalculateRevenuePerDistance(IEnumerable <FlightSeat> flightSeats, FlightPath flightpath) { if (flightSeats == null || flightSeats.Count() == 0) { return((decimal)InvalidPropertyValues.undefinedValue); } var flightIncome = flightSeats.Sum(s => s.GetPrice()); if (flightpath == null || flightpath.Distance == 0) { return((decimal)InvalidPropertyValues.undefinedValue); } var result = flightIncome / flightpath.Distance; return(Math.Round(result, 2, MidpointRounding.AwayFromZero)); }
// Update is called once per frame void Update() { GameObject pathy = GameObject.Find("Pathfinder"); FlightPath flightPath = pathy.GetComponent <FlightPath> (); if (SceneManager.GetActiveScene().name == "Tut_Level") { } if (SceneManager.GetActiveScene().name == "Level_1_FullEnvironment") { if (flightPath.CurrentStageNum == 1) { //Debug.Log ("some shit"); if (EndBlock != flightPath.CurrentStageNum) { Debug.Log(flightPath.CurrentStageNum); if (Andys [0].gameObject.activeSelf == false) { if (Andys [1].gameObject.activeSelf == false) { if (Andys [2].gameObject.activeSelf == false) { Debug.Log("About to stop the clock"); flightPath.StopTheClock(); EndBlock = flightPath.CurrentStageNum; Debug.Log(EndBlock); //CurrentStageNum++; } } } } } if (flightPath.CurrentStageNum == 2) { if (EndBlock != flightPath.CurrentStageNum) { Debug.Log(flightPath.CurrentStageNum); if (Andys [3].gameObject.activeSelf == false) { if (Andys [4].gameObject.activeSelf == false) { Debug.Log("About to stop the clock"); flightPath.StopTheClock(); EndBlock = flightPath.CurrentStageNum; Debug.Log(EndBlock); //CurrentStageNum++; } } } } if (flightPath.CurrentStageNum == 3) { if (EndBlock != flightPath.CurrentStageNum) { Debug.Log(flightPath.CurrentStageNum); if (Andys [5].gameObject.activeSelf == false) { if (Andys [6].gameObject.activeSelf == false) { Debug.Log("About to stop the clock"); flightPath.StopTheClock(); EndBlock = flightPath.CurrentStageNum; Debug.Log(EndBlock); //CurrentStageNum++; } } } } if (flightPath.CurrentStageNum == 4) { if (EndBlock != flightPath.CurrentStageNum) { Debug.Log(flightPath.CurrentStageNum); if (Andys [7].gameObject.activeSelf == false) { if (Andys [8].gameObject.activeSelf == false) { Debug.Log("About to stop the clock"); flightPath.StopTheClock(); EndBlock = flightPath.CurrentStageNum; Debug.Log(EndBlock); //CurrentStageNum++; } } } } if (flightPath.CurrentStageNum == 5) { if (EndBlock != flightPath.CurrentStageNum) { Debug.Log(flightPath.CurrentStageNum); if (Andys [9].gameObject.activeSelf == false) { if (Andys [10].gameObject.activeSelf == false) { if (Andys [11].gameObject.activeSelf == false) { Debug.Log("About to stop the clock"); flightPath.StopTheClock(); EndBlock = flightPath.CurrentStageNum; Debug.Log(EndBlock); //CurrentStageNum++; } } } } } if (flightPath.CurrentStageNum == 6) { if (EndBlock != flightPath.CurrentStageNum) { Debug.Log(flightPath.CurrentStageNum); if (Andys [12].gameObject.activeSelf == false) { if (Andys [13].gameObject.activeSelf == false) { Debug.Log("About to stop the clock"); flightPath.StopTheClock(); EndBlock = flightPath.CurrentStageNum; Debug.Log(EndBlock); //CurrentStageNum++; } } } } } if (SceneManager.GetActiveScene().name == "Level_2") { } }
public void Remove(FlightPath flightPath) { context.FlightPaths.Remove(flightPath); }
public void Add(FlightPath flightPath) { context.FlightPaths.Add(flightPath); }
private void Update() { if (MinigameManager.IsPaused || !m_miniGame.GameLogic.IsGameInProgress || !m_isBattleInProgress) { return; } Vector3 position; switch (m_currentMovementPhase) { case MovementPhase.APPROACH: position = base.transform.position; position.x -= 3.8f * Time.deltaTime; base.transform.position = position; if (!m_hasAppearanceSoundPlayed && position.x < m_miniGame.VisibleWorldBounds.max.x) { m_miniGame.PlaySFX(mg_jr_Sound.BOSS_KLUTZY_LOOP.ClipName()); m_hasAppearanceSoundPlayed = true; } if (m_klutzySprite.bounds.max.x < m_miniGame.VisibleWorldBounds.max.x) { int num = (int)(m_targetFlightPath = (FlightPath)Random.Range(0, 3)); switch (m_targetFlightPath) { case FlightPath.TOP: m_currentVerticalMovementDirection = 1f; break; case FlightPath.MIDDLE: m_currentVerticalMovementDirection = 0f; break; case FlightPath.BOTTOM: m_currentVerticalMovementDirection = -1f; break; default: Assert.IsTrue(condition: false, "Invalid flight path"); break; } m_currentMovementPhase = MovementPhase.WAITING; } break; case MovementPhase.WAITING: m_timeWaiting += Time.deltaTime; if (m_timeWaiting > 0.5f && Random.value > 0.5f) { m_miniGame.PlaySFX(mg_jr_Sound.BOSS_KLUTZY_LAUGH.ClipName()); m_currentMovementPhase = MovementPhase.NORMAL; } break; case MovementPhase.NORMAL: position = base.transform.position; position.x -= 3.8f * Time.deltaTime; position.y += 1.8f * Time.deltaTime * m_currentVerticalMovementDirection; if (position.y > 3f) { position.y = 3f; m_currentVerticalMovementDirection = -1f; m_currentMovementPhase = MovementPhase.WAITING; } if (position.y < -1f) { position.y = -1f; m_currentVerticalMovementDirection = 1f; m_currentMovementPhase = MovementPhase.WAITING; } base.transform.position = position; if (position.x < m_miniGame.VisibleWorldBounds.min.x && !m_miniGame.VisibleWorldBounds.Intersects(m_reactorRingsRight.bounds)) { if (m_bossCompleteCallback != null) { m_bossCompleteCallback(); } m_miniGame.StopSFX(mg_jr_Sound.BOSS_KLUTZY_LOOP.ClipName()); m_isBattleInProgress = false; m_miniGame.Resources.ReturnPooledResource(base.gameObject); } break; default: Assert.IsTrue(condition: false, "Unknown movement phase"); break; } }
public void SetPath(FlightPath path) { currentPath = path; currentPath.DrawFlightTunnel(); }
public LightFlightPathViewModel(FlightPath flightPath) { FlightPathId = flightPath.FlightPathId; Name = $"{flightPath.Departure.Name} ➔ {flightPath.Destination.Name}"; }