void Start() { canMove = true; //SpawnPoint //respawnPosition = transform.position; theLevelManager = FindObjectOfType <LevelManager>(); lastPositionScript = FindObjectOfType <LastPosition>(); evolveScript = FindObjectOfType <Evolve>(); tvPlayer = FindObjectOfType <PlayerController>(); transformationCloudScript = FindObjectOfType <TransformationCloud>(); hurtPlayerScript = FindObjectOfType <HurtPlayer>(); //Assign variables rb2d = gameObject.GetComponent <Rigidbody2D>(); anim = gameObject.GetComponent <Animator>(); //Start with full health currentHealth = maxHealth; //tvPlayer = FindObjectOfType<PlayerController>(); transform.position = lastPositionScript.pos; }
public void ToBinary(BinaryWriter writer) { writer.Write(Index); LastPosition.ToBinary(writer); TargetPosition.ToBinary(writer); writer.Write((int)Type); }
void Start() { crouchTrigger.enabled = false; //Defaults to facing right. facingRight = true; //Enables mobility. canMove = true; //SpawnPoint respawnPosition = transform.position; //References to other scripts. theLevelManager = FindObjectOfType <LevelManager>(); lastPositionScript = FindObjectOfType <LastPosition>(); evolveScript = FindObjectOfType <Evolve>(); thePlayerController = FindObjectOfType <PlayerController>(); playerGun = FindObjectOfType <PlayerGun>(); //Assign variables rb2d = gameObject.GetComponent <Rigidbody2D>(); anim = gameObject.GetComponent <Animator>(); //Start with full health currentHealth = maxHealth; transform.position = lastPositionScript.pos; }
private static void CreateLastPosition(int topPosition, List <ISquare> board) { var lastPostion = new LastPosition(new List <IPlayer>()) { Position = topPosition }; board[topPosition - 1] = lastPostion; }
/// <summary> /// Revert the current position to the last position. /// </summary> public void Undo() { // Revert CurrentPosition = LastPosition.Clone(); // Add log entry. Log.Add(new LogEntry { Time = DateTime.Now, Position = CurrentPosition.Clone() }); }
// Update is called once per frame void Update() { LastPosition ancestor = objectToFollow.GetComponent <LastPosition>(); //dirty hack. needed because we don't know when last pos of ancestor was called the last time if (Vector3.Distance(objectToFollow.transform.position, ancestor.OldPosition) < Vector3.kEpsilon) { return; } transform.position = ancestor.OldPosition; }
public void Disconnect(Guid id) { var player = AllPlayers.players.FirstOrDefault(i => i.ID == id); LastPosition.SaveLastPoint(player.Login, player.Position); AllPlayers.players.Remove(player); foreach (PlayerServer playerServer in AllPlayers.players) { playerServer.OperationContext.GetCallbackChannel <IClientCallback>().DisconectEnemy(id); } }
public void OnPlayerLanded_WhenCalled_SetTheWinnerVariableToTrue() { //Arrange var player = new Player(new Die(), 100) { CurrentPosition = 100 }; var lastPostion = new LastPosition(new List <IPlayer>()); //Act lastPostion.OnPlayerLanded(player); //Assert Assert.True(lastPostion.HasAWinner); Assert.Single(lastPostion.Players); }
public void Save(XmlTextWriter xml) { xml.WriteAttributeString("id", Id); xml.WriteAttributeString("description", Description); // xml.WriteAttributeString("enabled", Enabled.ToString()); xml.WriteAttributeString("stepsFor360", StepsFor360.ToString()); xml.WriteAttributeString("minStepInterval", MinStepInterval.ToString()); xml.WriteAttributeString("lastPosition", LastPosition.ToString()); xml.WriteAttributeString("lastStepDirection", LastStepDirection.ToString()); xml.WriteAttributeString("lastStepType", LastStepType.ToString()); xml.WriteAttributeString("lastStepIndex", LastStepIndex.ToString()); xml.WriteAttributeString("keepTourque", KeepTourque.ToString()); xml.WriteAttributeString("hasZeroSensor", HasZeroSensor.ToString()); xml.WriteAttributeString("invertZeroSensor", InvertZeroSensor.ToString()); xml.WriteAttributeString("reverseDirection", ReverseDirection.ToString()); _initialPosition = CurrentPosition; }
public void Execute() { if ((DateTime.Now - LastLastPositionUpdate > TimeSpan.FromMilliseconds(1000) && LastPosition.GetDistance(GetPosition.Invoke()) > 24) || TryCount > 2) { Reset(); return; } if (CurrentPath.Count == 0) { TryCount = 0; List <Vector3> nodes = GeneratePath.Invoke(GetPosition.Invoke(), TargetPosition); if (nodes.Count == 0) { // pathfinding was unsuccessful return; } foreach (Vector3 node in nodes) { CurrentPath.Enqueue(node); } CurrentPathTargetPosition = TargetPosition; } List <Vector3> forces = new List <Vector3>(); Vector3 currentPosition = GetPosition.Invoke(); Vector3 targetPosition = CurrentPath.Peek(); double distanceToTargetPosition = currentPosition.GetDistance(targetPosition); if (distanceToTargetPosition > 128) { Reset(); return; } else if (distanceToTargetPosition < MovementSettings.WaypointCheckThreshold) { if (CurrentPath.Count > 0) { targetPosition = CurrentPath.Dequeue(); } else if (CurrentPath.Count == 0) { return; } } Vector3 positionToGoTo = BotUtils.MoveAhead(GetRotation.Invoke(), targetPosition, 2); bool updateForces = true; switch (State) { case MovementEngineState.Moving: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); break; case MovementEngineState.DirectMoving: PlayerVehicle.MoveToPosition(targetPosition); updateForces = false; break; case MovementEngineState.Following: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); forces.Add(PlayerVehicle.Seperate(1)); break; case MovementEngineState.Chasing: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); break; case MovementEngineState.Fleeing: forces.Add(PlayerVehicle.Flee(positionToGoTo, 1)); break; case MovementEngineState.Evading: forces.Add(PlayerVehicle.Evade(positionToGoTo, 1, TargetRotation)); break; case MovementEngineState.Wandering: forces.Add(PlayerVehicle.Wander(1)); break; case MovementEngineState.Stuck: forces.Add(PlayerVehicle.Unstuck(1)); break; default: return; } if (updateForces) { PlayerVehicle.Update(forces); } if (DateTime.Now - LastJumpCheck > TimeSpan.FromMilliseconds(250)) { double distanceTraveled = LastPosition.GetDistance(GetPosition.Invoke()); if ((LastPosition.X == 0 && LastPosition.Y == 0 && LastPosition.Z == 0) || distanceTraveled < 0.3) { Jump.Invoke(); TryCount++; } LastPosition = GetPosition.Invoke(); LastLastPositionUpdate = DateTime.Now; LastJumpCheck = DateTime.Now; } LastTargetPosition = GetPosition.Invoke(); HasMoved = true; }
public void Execute() { if (DateTime.Now - LastAction < TimeSpan.FromMilliseconds(250)) { return; } LastAction = DateTime.Now; if ((DateTime.Now - LastLastPositionUpdate > TimeSpan.FromMilliseconds(1000) || TryCount > 2)) { Reset(); return; } if (CurrentPath.Count == 0) { TryCount = 0; List <Vector3> nodes = new List <Vector3>(); if (WowInterface.ObjectManager.Player.Position.GetDistance(TargetPosition) > 5) { List <Vector3> getPathResult = WowInterface.PathfindingHandler.GetPath((int)WowInterface.ObjectManager.MapId, WowInterface.ObjectManager.Player.Position, TargetPosition); if (getPathResult != null && getPathResult.Count > 0) { nodes.AddRange(getPathResult); } } else { Vector3 moveAlongSurfaceResult = WowInterface.PathfindingHandler.MoveAlongSurface((int)WowInterface.ObjectManager.MapId, WowInterface.ObjectManager.Player.Position, TargetPosition); if (moveAlongSurfaceResult != default && moveAlongSurfaceResult != Vector3.Zero) { nodes.Add(moveAlongSurfaceResult); } } if (nodes == null || nodes.Count == 0) { // pathfinding was unsuccessful return; } foreach (Vector3 node in nodes) { CurrentPath.Enqueue(node); } CurrentPathTargetPosition = TargetPosition; } List <Vector3> forces = new List <Vector3>(); Vector3 currentPosition = WowInterface.ObjectManager.Player.Position; Vector3 targetPosition = CurrentPath.Peek(); double distanceToTargetPosition = currentPosition.GetDistance(targetPosition); if (distanceToTargetPosition > 4096) { Reset(); return; } else if (distanceToTargetPosition < MovementSettings.WaypointCheckThreshold) { if (CurrentPath.Count > 0) { targetPosition = CurrentPath.Dequeue(); } else if (CurrentPath.Count == 0) { return; } } Vector3 positionToGoTo = targetPosition; bool updateForces = true; switch (State) { case MovementEngineState.Moving: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); forces.Add(PlayerVehicle.AvoidObstacles(2)); break; case MovementEngineState.DirectMoving: WowInterface.CharacterManager.MoveToPosition(targetPosition); updateForces = false; break; case MovementEngineState.Following: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); forces.Add(PlayerVehicle.Seperate(0.5f)); forces.Add(PlayerVehicle.AvoidObstacles(2)); break; case MovementEngineState.Chasing: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); break; case MovementEngineState.Fleeing: forces.Add(PlayerVehicle.Flee(positionToGoTo, 1)); break; case MovementEngineState.Evading: forces.Add(PlayerVehicle.Evade(positionToGoTo, 1, TargetRotation)); break; case MovementEngineState.Wandering: forces.Add(PlayerVehicle.Wander(1)); break; case MovementEngineState.Stuck: forces.Add(PlayerVehicle.Unstuck(1)); break; default: return; } if (DateTime.Now - LastJumpCheck > TimeSpan.FromMilliseconds(250)) { double distanceTraveled = LastPosition.GetDistance(WowInterface.ObjectManager.Player.Position); if ((LastPosition.X == 0 && LastPosition.Y == 0 && LastPosition.Z == 0) || distanceTraveled < 0.01) { ++TryCount; } else { TryCount = 0; // if (Straving) // { // WowInterface.HookManager.LuaDoString("StrafeLeftStop();MoveBackwardStop();StrafeRightStop();MoveBackwardStop();"); // Straving = false; // } } // if the target position is higher than us, jump if (TryCount > 1 || (distanceToTargetPosition < 3 && currentPosition.Z + 2 < targetPosition.Z)) { WowInterface.CharacterManager.Jump(); TryCount = 0; // if (DateTime.Now > StrafeEnd) // { // int msToStrafe = Rnd.Next(1000, 5000); // // if (Rnd.Next(0, 2) == 0) // { // WowInterface.HookManager.LuaDoString("StrafeLeftStart();MoveBackwardStart();"); // Straving = true; // } // else // { // WowInterface.HookManager.LuaDoString("StrafeRightStart();MoveBackwardStart();"); // Straving = true; // } // // StrafeEnd = DateTime.Now + TimeSpan.FromMilliseconds(msToStrafe + 200); // } } if (updateForces && !Straving) { PlayerVehicle.Update(forces); } LastPosition = WowInterface.ObjectManager.Player.Position; LastLastPositionUpdate = DateTime.Now; LastJumpCheck = DateTime.Now; } LastTargetPosition = WowInterface.ObjectManager.Player.Position; HasMoved = true; }
private void carregarIngressos() { IngressoDAO dao = new IngressoDAO(); ingressos = dao.getMeusIngressos(View.frmLogin.pessoa.cpf); LastPosition lastPosition = new LastPosition(80, 25, 3, 169, 3, 138, -7, 4, -7, 210); foreach (Ingresso ingresso in ingressos) { Panel panel = new Panel(); panel.BackColor = System.Drawing.SystemColors.ButtonHighlight; panel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; panel.Location = new System.Drawing.Point(lastPosition.panelPositionHor, lastPosition.panelPositionVer); panel.Name = "panelIngresso " + ingresso.id; panel.Size = new System.Drawing.Size(270, 245); panel.TabIndex = 10; panel.Click += new EventHandler(panel_Click); this.Controls.Add(panel); Label lblNomeEvento = new Label(); lblNomeEvento.Font = new System.Drawing.Font("Gadugi", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lblNomeEvento.ForeColor = System.Drawing.Color.Black; lblNomeEvento.Location = new System.Drawing.Point(lastPosition.lblNomeEventoPositionHor, lastPosition.lblNomeEventoPositionVer); lblNomeEvento.Name = "lblNomeEvento " + ingresso.id; lblNomeEvento.Size = new System.Drawing.Size(262, 31); lblNomeEvento.TabIndex = 1; lblNomeEvento.Text = ingresso.nomeEvento; lblNomeEvento.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; lblNomeEvento.Click += new EventHandler(panel_Click); panel.Controls.Add(lblNomeEvento); Label lblDataEvento = new Label(); lblDataEvento.Font = new System.Drawing.Font("Gadugi", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lblDataEvento.ForeColor = System.Drawing.Color.SandyBrown; lblDataEvento.ImageAlign = System.Drawing.ContentAlignment.BottomCenter; lblDataEvento.Location = new System.Drawing.Point(lastPosition.lblDataEventoPositionHor, lastPosition.lblDataEventoPositionVer); lblDataEvento.Name = "lblDataEvento " + ingresso.id; lblDataEvento.Size = new System.Drawing.Size(144, 31); lblDataEvento.TabIndex = 1; lblDataEvento.Text = ingresso.dataHoraEvento.ToString(); lblDataEvento.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; lblDataEvento.Click += new EventHandler(panel_Click); panel.Controls.Add(lblDataEvento); Button btnShowEvento = new Button(); btnShowEvento.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(112)))), ((int)(((byte)(86)))), ((int)(((byte)(247))))); btnShowEvento.FlatAppearance.BorderColor = System.Drawing.Color.White; btnShowEvento.FlatAppearance.BorderSize = 0; btnShowEvento.FlatStyle = System.Windows.Forms.FlatStyle.Flat; btnShowEvento.Font = new System.Drawing.Font("Century Gothic", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); btnShowEvento.ForeColor = System.Drawing.Color.White; btnShowEvento.Location = new System.Drawing.Point(lastPosition.btnShowEventPositionHor, lastPosition.btnShowEventPositionVer); btnShowEvento.Name = "btnShowEvento " + ingresso.id; btnShowEvento.Size = new System.Drawing.Size(283, 35); btnShowEvento.TabIndex = 6; btnShowEvento.Text = "Detalhes"; btnShowEvento.UseVisualStyleBackColor = false; btnShowEvento.Click += new EventHandler(panel_Click); panel.Controls.Add(btnShowEvento); PictureBox pictureEvento = new PictureBox(); if (ingresso.imgEvent == null) { pictureEvento.Image = Properties.Resources.apolloCadastroOficial; } else { MemoryStream mstream = new MemoryStream(ingresso.imgEvent); pictureEvento.Image = System.Drawing.Image.FromStream(mstream); } pictureEvento.Location = new System.Drawing.Point(lastPosition.pictureEventoPositionHor, lastPosition.pictureEventoPositionVer); pictureEvento.Name = "pictureBoxEvento " + ingresso.id; pictureEvento.Size = new System.Drawing.Size(283, 135); pictureEvento.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; pictureEvento.TabIndex = 0; pictureEvento.TabStop = false; pictureEvento.Click += new EventHandler(panel_Click); panel.Controls.Add(pictureEvento); int newPanelPositionHor = 0; int newPanelPositionVer = 0; if (lastPosition.panelPositionHor > 380) { newPanelPositionHor = 80; newPanelPositionVer = lastPosition.panelPositionVer + 265; } else { newPanelPositionHor = lastPosition.panelPositionHor + 300; newPanelPositionVer = lastPosition.panelPositionVer; } lastPosition = new LastPosition(newPanelPositionHor, newPanelPositionVer, lastPosition.lblNomeEventoPositionHor, lastPosition.lblNomeEventoPositionVer, lastPosition.lblDataEventoPositionHor, lastPosition.lblDataEventoPositionVer, lastPosition.pictureEventoPositionHor, lastPosition.pictureEventoPositionVer, lastPosition.btnShowEventPositionHor, lastPosition.btnShowEventPositionVer); } }
public void Execute() { if (CurrentPath.Count == 0 || CurrentPathTargetPosition.GetDistance(TargetPosition) > 1) { List <Vector3> nodes = GeneratePath.Invoke(GetPosition.Invoke(), TargetPosition); if (nodes.Count == 0) { // pathfinding was unsuccessful return; } foreach (Vector3 node in nodes) { CurrentPath.Enqueue(node); } CurrentPathTargetPosition = TargetPosition; } List <Vector3> forces = new List <Vector3>(); Vector3 currentPosition = GetPosition.Invoke(); Vector3 targetPosition = CurrentPath.Peek(); double distanceToTargetPosition = currentPosition.GetDistance2D(targetPosition); if (distanceToTargetPosition < MovementSettings.WaypointCheckThreshold) { if (CurrentPath.Count > 0) { targetPosition = CurrentPath.Dequeue(); } else if (CurrentPath.Count == 0) { return; } } Vector3 positionToGoTo = MoveAhead(targetPosition, 1.5); switch (State) { case MovementEngineState.Moving: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); break; case MovementEngineState.Following: forces.Add(PlayerVehicle.Seek(positionToGoTo, 1)); forces.Add(PlayerVehicle.Seperate(1)); break; case MovementEngineState.Chasing: forces.Add(PlayerVehicle.Pursuit(positionToGoTo, 1, TargetRotation)); break; case MovementEngineState.Fleeing: forces.Add(PlayerVehicle.Flee(positionToGoTo, 1)); break; case MovementEngineState.Evading: forces.Add(PlayerVehicle.Evade(positionToGoTo, 1, TargetRotation)); break; case MovementEngineState.Wandering: forces.Add(PlayerVehicle.Wander(1)); break; case MovementEngineState.Stuck: forces.Add(PlayerVehicle.Unstuck(1)); break; default: return; } // move PlayerVehicle.Update(forces); if (DateTime.Now - LastJumpCheck > TimeSpan.FromMilliseconds(500)) { double distanceTraveled = LastPosition.GetDistance(GetPosition.Invoke()); if ((LastPosition.X == 0 && LastPosition.Y == 0 && LastPosition.Z == 0) || distanceTraveled < 0.5) { Jump.Invoke(); } LastPosition = GetPosition.Invoke(); LastJumpCheck = DateTime.Now; } HasMoved = true; }
/// <summary> /// You most likely don't need to override this. Is is only for some very special cases /// /// I made this virtual so that it can be overwritten. There are some specific challenge bots we shouldn't/don't need to call this on. /// </summary> /// <param name="game"></param> public virtual void PostDoTurn(Game game) { LastHealth.UpdateLastHealths(); LastPosition.UpdateLastPositions(); TrackPortalCreations.UpdateEnemyPortalCreations(); }
private void Start() { last = new LastPosition(); }
public override string ToString() => $"{Name}: LastPosition={(LastPosition?.ToString() ?? "")}" + $", DT={DT.ToString("dd.MM.yyyy HH:mm")}" + $", State={State}" + $", Speed={Speed.ToString("F1", CultureInfo.InvariantCulture)}";