private static void HandleEvent(PathEvent pathEvent, ISession session) { Logger.Write(session.Translation.GetTranslation(pathEvent.IsCalculated ? TranslationString.WalkingPathCalculated : TranslationString.WalkingPathReal, pathEvent.StringifiedPath)); }
void server_onNewTrajectory(object obj, PathEvent trajectoryArgs) { if (this.onNewTrajectory != null) { this.onNewTrajectory(obj, trajectoryArgs); } }
public void PlayerReady(PlayerController pc) { PathEvent pathChanged = pc.getPathChangedEvent(); PathEvent pathEnded = pc.getPathEndedEvent(); pathChanged.AddListener(HandleChangedPath); }
public void nextEvent() { //Start a new path to the targetPosition, return the result to the OnPathComplete function eventScript = FindClosestPath().GetComponent <PathEvent>(); waitScript.waitEvent = eventScript.waitUpToEvent; enemy.gameEvent = eventScript.eventNum; seeker.StartPath(transform.position, FindClosestPath().transform.position, OnPathComplete); movingEvent = true; firstDuckSearch = true; }
void game_onNewTrajectory(object obj, PathEvent trajectoryArgs) { if (this.game != null) { var centre = this.game.GetCentre(); if (centre != null) { this.centreX = centre[0]; this.centreY = centre[1]; } // Shift le circuit var newTraj = this.ShiftCircuit(trajectoryArgs.Path); // Streaming du nouveau circuit shifté var newTrajStream = this.PrepareToStreaming(newTraj); this.pss.Pss.StreamTrajectory(newTrajStream); if (Singleton.UniBi) { // Unimanuel if (Singleton.MainGaucheX) { // gauche frame = new MazeGameModel((ushort)(Singleton.CalibrX * 10), (ushort)(Singleton.CalibrY * 10), UniBiCodes.UnimanuelGauche).MakeFrame(); } else { // droite frame = new MazeGameModel((ushort)(Singleton.CalibrX * 10), (ushort)(Singleton.CalibrY * 10), UniBiCodes.UnimanuelDroite).MakeFrame(); } } else { // Bimanuel if (Singleton.MainGaucheX) { // gauche frame = new MazeGameModel((ushort)(Singleton.CalibrX * 10), (ushort)(Singleton.CalibrY * 10), UniBiCodes.BimanuelGaucheXDroiteY).MakeFrame(); } else { // droite frame = new MazeGameModel((ushort)(Singleton.CalibrX * 10), (ushort)(Singleton.CalibrY * 10), UniBiCodes.BimanuelGaucheYDroiteX).MakeFrame(); } } this.canSendPos = true;// Lancement du mod et positionement du robot } }
public MCMediator(Tuple <ISde, FdmBase, IRng> parts, PathEvent <double> optionPaths, EndOfSimulation <double> finishOptions, int numberSimulations) { sde = parts.Item1; fdm = parts.Item2; rng = parts.Item3; // Define slots for path information path = optionPaths; // Signal end of simulation finish = finishOptions; NSim = numberSimulations; res = new double[fdm.NT + 1]; mis = i => { if ((i / 10000) * 10000 == i) { Console.WriteLine("Iteration # {0}", i); } }; }
/// <summary> /// Will change the pathData to move along the path by the given distance /// </summary> /// <param name="pathData">A PathData that store a current state on the path</param> /// <param name="distanceToGo">The amount to move along the path</param> /// <returns>The event that happened during the move : nothing, direction changed (for ping pong) or finished (for once path)</returns> public PathEvent Move(PathData pathData, float distanceToGo) { PathEvent evt = PathEvent.Nothing; while (distanceToGo > 0) { Vector3 direction = m_WorldNode[pathData.nextNode] - pathData.position; float dist = distanceToGo; if (direction.sqrMagnitude < dist * dist) { dist = direction.magnitude; pathData.currentNode = pathData.nextNode; if (pathData.direction > 0) { pathData.nextNode += 1; if (pathData.nextNode >= m_WorldNode.Length) { //we reach the end switch (pathType) { case PathType.BackForth: pathData.nextNode = m_WorldNode.Length - 2; pathData.direction = -1; evt = PathEvent.ChangedDirection; break; case PathType.Loop: pathData.nextNode = 0; break; case PathType.Once: pathData.nextNode -= 1; evt = PathEvent.Finished; distanceToGo = -1; break; } } } else { pathData.nextNode -= 1; if (pathData.nextNode < 0) { //reached the beginning again switch (pathType) { case PathType.BackForth: pathData.nextNode = 1; pathData.direction = 1; evt = PathEvent.ChangedDirection; break; case PathType.Loop: pathData.nextNode = m_WorldNode.Length - 1; break; case PathType.Once: pathData.nextNode += 1; distanceToGo = -1; evt = PathEvent.Finished; break; } } } } pathData.position = pathData.position + direction.normalized * dist; //We remove the distance we moved. That way if we didn't had enough distance to the next goal, we will do a new loop to finish //the remaining distance we have to cover this frame toward the new goal distanceToGo -= dist; } return(evt); }
public void nextEvent() { //Start a new path to the targetPosition, return the result to the OnPathComplete function eventScript = FindClosestPath().GetComponent<PathEvent>(); waitScript.waitEvent = eventScript.waitUpToEvent; enemy.gameEvent = eventScript.eventNum; seeker.StartPath (transform.position,FindClosestPath().transform.position, OnPathComplete); movingEvent = true; firstDuckSearch = true; }
public void FixedUpdate() { if (path == null) { //We have no path to move after yet return; } //if(enemy.nextEvent) //{ // nextEvent(); // enemy.nextEvent = false; // } //Player is only moving inbetween gameplay if(movingEvent) { //REACHED END OF CURRENT PATH if (currentWaypoint >= path.vectorPath.Count) { Debug.Log ("End Of Path Reached"); currentWaypoint = 0; eventScript = FindClosestPath().GetComponent<PathEvent>(); if(eventScript.isThisEvent) { enemy.canFire = true; movingEvent = false; enemy.movingEvent = false; waitScript.waitEvent = eventScript.waitEvent; enemy.nextEvent = false; enemy.spawned = false; } return; } //Only move if the player is not hit and not ducking if(script.playerHit == false & script.canShootEnemy & canMove) { //Direction to the next waypoint Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized; dir *= speed * Time.fixedDeltaTime; controller.SimpleMove (dir); } //Check if we are close enough to the next waypoint //If we are, proceed to follow the next waypoint if (Vector3.Distance (transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) { currentWaypoint++; return; } } //If player right clicks, enter ducking event. //Calls Duck(), moves to duckNode. //If player lets go, calls Duck() and moves back to firing node. //I feel this could be enhanced more, storing the paths instead of always searching. if(duckEvent & !script.playerHit) { //Begin ducking to duckNode if(beginDuck & !returnDuck) { Duck (); //If player reaches end of path if (currentWaypoint >= duckPath.vectorPath.Count & beginDuck) { currentWaypoint = 0; lockpos = true; } //As long as player is not at the end of the path if(!lockpos) { //Direction to the next waypoint Vector3 dir = (duckPath.vectorPath[currentWaypoint]-transform.position).normalized; dir *= duckSpeed * Time.fixedDeltaTime; controller.SimpleMove (dir); //Check if we are close enough to the next waypoint //If we are, proceed to follow the next waypoint if (Vector3.Distance (transform.position,duckPath.vectorPath[currentWaypoint]) < nextWaypointDistance) { currentWaypoint++; return; } } } //End ducking to firing position if(returnDuck & !beginDuck) { Duck (); //Reaching end of firing path if (currentWaypoint >= path.vectorPath.Count) { Debug.Log ("End Of Duck Reached"); currentWaypoint = 0; returnDuck = false; duckEvent = false; //firstDuckSearch = true; } //Direction to the next waypoint Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized; dir *= duckSpeed * Time.fixedDeltaTime; controller.SimpleMove (dir); //Check if we are close enough to the next waypoint //If we are, proceed to follow the next waypoint if (Vector3.Distance (transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) { currentWaypoint++; return; } } } if(enemy.nextEvent) { Debug.Log ("nextEvent FIRING"); if(!destroyedEvent) { Destroy(FindClosestPath()); destroyedEvent = true; } FindClosestPath(); nextEvent(); } }
public void FixedUpdate() { if (path == null) { //We have no path to move after yet return; } //if(enemy.nextEvent) //{ // nextEvent(); // enemy.nextEvent = false; // } //Player is only moving inbetween gameplay if (movingEvent) { //REACHED END OF CURRENT PATH if (currentWaypoint >= path.vectorPath.Count) { Debug.Log("End Of Path Reached"); currentWaypoint = 0; eventScript = FindClosestPath().GetComponent <PathEvent>(); if (eventScript.isThisEvent) { enemy.canFire = true; movingEvent = false; enemy.movingEvent = false; waitScript.waitEvent = eventScript.waitEvent; enemy.nextEvent = false; enemy.spawned = false; } return; } //Only move if the player is not hit and not ducking if (script.playerHit == false & script.canShootEnemy & canMove) { //Direction to the next waypoint Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized; dir *= speed * Time.fixedDeltaTime; controller.SimpleMove(dir); } //Check if we are close enough to the next waypoint //If we are, proceed to follow the next waypoint if (Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]) < nextWaypointDistance) { currentWaypoint++; return; } } //If player right clicks, enter ducking event. //Calls Duck(), moves to duckNode. //If player lets go, calls Duck() and moves back to firing node. //I feel this could be enhanced more, storing the paths instead of always searching. if (duckEvent & !script.playerHit) { //Begin ducking to duckNode if (beginDuck & !returnDuck) { Duck(); //If player reaches end of path if (currentWaypoint >= duckPath.vectorPath.Count & beginDuck) { currentWaypoint = 0; lockpos = true; } //As long as player is not at the end of the path if (!lockpos) { //Direction to the next waypoint Vector3 dir = (duckPath.vectorPath[currentWaypoint] - transform.position).normalized; dir *= duckSpeed * Time.fixedDeltaTime; controller.SimpleMove(dir); //Check if we are close enough to the next waypoint //If we are, proceed to follow the next waypoint if (Vector3.Distance(transform.position, duckPath.vectorPath[currentWaypoint]) < nextWaypointDistance) { currentWaypoint++; return; } } } //End ducking to firing position if (returnDuck & !beginDuck) { Duck(); //Reaching end of firing path if (currentWaypoint >= path.vectorPath.Count) { Debug.Log("End Of Duck Reached"); currentWaypoint = 0; returnDuck = false; duckEvent = false; //firstDuckSearch = true; } //Direction to the next waypoint Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized; dir *= duckSpeed * Time.fixedDeltaTime; controller.SimpleMove(dir); //Check if we are close enough to the next waypoint //If we are, proceed to follow the next waypoint if (Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]) < nextWaypointDistance) { currentWaypoint++; return; } } } if (enemy.nextEvent) { Debug.Log("nextEvent FIRING"); if (!destroyedEvent) { Destroy(FindClosestPath()); destroyedEvent = true; } FindClosestPath(); nextEvent(); } }
public void SubscribeToPathEnded(PathEvent pathEnded) { pathEnded.AddListener(PickUpItem); }