public MoveToPositionQuestObjective(WowInterface wowInterface, Vector3 position, double distance, MovementAction movementAction = MovementAction.Moving) { WowInterface = wowInterface; WantedPosition = position; Distance = distance; MovementAction = movementAction; }
public void Update(MoveCharacter moveCharacter, MovementAction movementAction, Vector3 targetPosition, float rotation = 0f) { if (movementAction == MovementAction.DirectMove) { moveCharacter?.Invoke(targetPosition); return; } List <Vector3> forces = GetForces(movementAction, targetPosition, rotation); foreach (Vector3 force in forces) { Velocity += force; } if (IsOnWaterSurface && Velocity.Z > 0f) { Velocity = new(Velocity.X, Velocity.Y, 0f); } float maxVelocity = Config.MovementSettings.MaxVelocity; if (Bot.Player.IsMounted) { maxVelocity *= 2; } Velocity.Limit(maxVelocity); Vector3 currentPosition = Bot.Player.Position; currentPosition.Add(Velocity); moveCharacter?.Invoke(currentPosition); }
public MoveToPositionQuestObjective(AmeisenBotInterfaces bot, Vector3 position, double distance, MovementAction movementAction = MovementAction.Move) { Bot = bot; WantedPosition = position; Distance = distance; MovementAction = movementAction; }
public void NewMoveAction(Input input, Point tile) { bool addWayPointHold = !input.IsKeyMapDown(KeyMap.AddWayPointHold); MovementAction move = new MovementAction(location, tile, vehicleParameters, vehicleSpecific); AddAction(move, addWayPointHold); }
public float resolveAction(Data.Action action) { Entity e; if (!entityList.TryGetValue(action.entityId, out e)) { Debug.LogError("resolveAction() - can't find entity with id " + action.entityId); } if (action is MovementAction) { if (!action.isActionSkiped()) { MovementAction movementAction = (MovementAction)action; solver.resolveMovement(e, movementAction.path); return(movementAction.path.Length * 0.2f); } // TODO else give MP } else if (action is SpellAction) { if (!action.isActionSkiped()) { SpellAction spellAction = (SpellAction)action; Cell target = grid.GetCell(spellAction.targetCellId); SpellData spell = DataManager.SPELL_DATA[spellAction.spellId]; solver.resolveSpell(spell, e, target, spellAction is QuickSpellAction); return(0.5f); } // TODO else give AP } return(0); }
public void GivenHotelInNightTime_WithSubCorridorACandLightsOff_WhenMotionDetected_ThenSubCorridorLightsShouldbeOn() { var hotel = new Hotel() .With(new Floor() .With(new MainCorridor() .With(new Light()) .With(new AC())) .With(new SubCorridor() .With(new Light() { Switch = Switch.OFF }) .With(new AC() { Switch = Switch.OFF }))); IAction actiontobePerformed = new MovementAction(hotel, new ActionLocation(1, 1)); actiontobePerformed.PerformAction(); Assert.True(hotel .Floors.First() .SubCorridors.First() .Lights.First() .Switch == Switch.ON); }
public void GivenHotelInNightTime_WithManySubCorridorsACandLightsOn_WhenMotionDetectedInOneCorridor_LightShouldbeOnAndPowerConsumptionInRange() { var hotel = new Hotel() .With(new Floor() .MainCorridorsWithSingleAcAndLight(corridorCount: 2) .SubCorridorWithSingleAcAndLight(corridorCount: 5)); var actionLocation = new ActionLocation(1, 1); IAction actiontobePerformed = new MovementAction(hotel, new ActionLocation(1, 1)); actiontobePerformed.PerformAction(); Assert.True(hotel .Floors.First() .SubCorridors[actionLocation.SubCorridor] .Lights.First() .Switch == Switch.ON); var firstfloor = hotel .Floors.First(); Console.WriteLine(firstfloor.MaxPowerConsumption()); Console.WriteLine(firstfloor.CurrentPowerConsumption()); Assert.True(firstfloor.MaxPowerConsumption() > firstfloor.CurrentPowerConsumption()); }
public void Update(MoveCharacter moveCharacter, MovementAction movementAction, Vector3 targetPosition, float rotation = 0f) { if (movementAction == MovementAction.DirectMove) { moveCharacter?.Invoke(targetPosition); return; } List <Vector3> forces = GetForces(movementAction, targetPosition, rotation); for (int i = 0; i < forces.Count; ++i) { Velocity += forces[i]; } if (IsOnWaterSurface && Velocity.Z > 0f) { Velocity = new Vector3(Velocity.X, Velocity.Y, 0f); } Velocity.Limit(WowInterface.MovementSettings.MaxVelocity); Vector3 currentPosition = WowInterface.ObjectManager.Player.Position; currentPosition.Add(Velocity); moveCharacter?.Invoke(currentPosition); }
/// <summary> /// Performs one action from the available actions. /// </summary> /// <param name="availableActions">All available actions. Must not be null or empty.</param> public override void PerformMovementActionFromAvailableActions(List <MovementAction> availableActions) { // Ask the magic oracle what action to perform. MovementAction chosenMovement = learner.OptimalAction(availableActions); PerformMovement(chosenMovement); }
public override bool Execute() { if (!Check()) { return(false); } int level = GetAbilityLevel(); Vector2 direction = target.GetCoordinates() - character.GetCoordinates(); Vector2 destination = target.GetCoordinates(); int i; for (i = 0; i < level + 1 && this.gameManager.GetTile(destination + direction).IsWalkable(); i++) { destination += direction; } if (destination != target.GetCoordinates()) { this.action = new MovementAction(target, destination, character.movementSpeed, false); this.action.Execute(); } character.AddActionFinisher(new AbilityFinisher(character, this.abilityClass, 2)); character.SetOnCooldown(this.abilityClass, true); this.startTime = Time.time; return(true); }
private static bool MoveOverlay(Overlay overlay, MovementAction movementAction) { var originalIndex = GisEditor.ActiveMap.Overlays.IndexOf(overlay); switch (movementAction) { case MovementAction.Up: GisEditor.ActiveMap.Overlays.MoveUp(overlay); break; case MovementAction.Down: GisEditor.ActiveMap.Overlays.MoveDown(overlay); break; case MovementAction.ToTop: GisEditor.ActiveMap.Overlays.MoveToTop(overlay); break; case MovementAction.ToBottom: GisEditor.ActiveMap.Overlays.MoveToBottom(overlay); break; default: break; } var currentIndex = GisEditor.ActiveMap.Overlays.IndexOf(overlay); var needRefresh = currentIndex != originalIndex; if (needRefresh) { GisEditor.ActiveMap.Refresh(); } return(needRefresh); }
private Vector2 ConvertMovementActionToVector2(MovementAction action, PlayerModel playerModel) { var playerBody = playerModel.ObjectBody; //Start calculations var linearImpulseForce = playerModel.Speed; var movementRate = linearImpulseForce / 2; Vector2 desiredVelocity; var leftHorizontalVelocity = Math.Max(playerBody.LinearVelocity.X - movementRate, -linearImpulseForce); var rightHorizontalVelocity = Math.Min(playerBody.LinearVelocity.X + movementRate, linearImpulseForce); var upVerticalVelocity = Math.Max(playerBody.LinearVelocity.Y - movementRate, -linearImpulseForce); var downVerticalVelocity = Math.Min(playerBody.LinearVelocity.Y + movementRate, linearImpulseForce); switch (action.Direction) { case EDirection.Down: desiredVelocity = new Vector2(0, downVerticalVelocity); break; case EDirection.Up: desiredVelocity = new Vector2(0, upVerticalVelocity); break; case EDirection.Left: desiredVelocity = new Vector2(leftHorizontalVelocity, 0); break; case EDirection.Right: desiredVelocity = new Vector2(rightHorizontalVelocity, 0); break; case EDirection.UpLeft: desiredVelocity = new Vector2(leftHorizontalVelocity, upVerticalVelocity); break; case EDirection.UpRight: desiredVelocity = new Vector2(rightHorizontalVelocity, upVerticalVelocity); break; case EDirection.DownLeft: desiredVelocity = new Vector2(leftHorizontalVelocity, downVerticalVelocity); break; case EDirection.DownRight: desiredVelocity = new Vector2(rightHorizontalVelocity, downVerticalVelocity); break; default: throw new ArgumentOutOfRangeException(); } var velChange = desiredVelocity - playerBody.LinearVelocity; var impulse = playerBody.Mass * velChange; return(impulse); }
public async Task SendMovement(MovementAction movementAction) { bool res = false; if (_interpolator != null) { try { if (!_gameLogic.IsPlayerSpawned(movementAction.Username)) //Should Deprecate this in favor of requiring the player to call the SpawnPlayer action. { _gameLogic.HandleSpawnPlayer(movementAction.Username, movementAction.PlayerClass); } res = _interpolator.ParseAction(movementAction); } catch (Exception e) { Console.WriteLine(e); } } var responseString = res ? "Action accepted by interpolator" : "Action rejected by interpolator. Action sent too close to previous action."; await Clients.Caller.ReceiveString(responseString); }
public void OwnerMoved(MovementAction action) { _objectThatSeeMe.ParallelAction(element => element.VisibleAi.SomeoneThatIamSeeWasMoved(Owner, action)); _objectsThatISee.ParallelAction(element => element.VisibleAi.SomeoneThatSeeMeWasMoved(Owner, action)); Calculate(); }
private void updateSampling(float delta) { timeCounter += delta; float interval = 1.0f / SampleRate; if(timeCounter > interval) { timeCounter -= interval; //tracks movement and direction if(firstTimeSample || Vector3.Distance(lastSamplePos,PlayerObject.Position) >= SampleDiff) { MovementAction mAction = new MovementAction(); mAction.Record(PlayerObject.Position); ActionTracker.TrackAction(mAction); lastSamplePos = PlayerObject.Position; } if(firstTimeSample || Vector3.Distance(lastSampleDir,PlayerObject.DirectionAngle) >= SampleDiff) { LookAction lAction = new LookAction(); lAction.Record(PlayerObject.DirectionAngle); ActionTracker.TrackAction(lAction); lastSampleDir = PlayerObject.DirectionAngle; } if(firstTimeSample) firstTimeSample = false; } }
/// <summary> /// Initializes a new instance of the <see cref="MovingObstacle"/> class. /// </summary> /// <param name="position">The initial position.</param> /// <param name="type">The type of the obstacle.</param> public MovingObstacle(GridPosition position, MovingObstacleType type) : base(position) { this.type = type; this.PossibleMovements = MovementAction.VonNeumannNeighbourhoodMovements(); EpisodeManager.AddEpisodeChangesReceiver(this); }
public Movement(IInput input, Vector2 position, MovementAction action = MovementAction.IDLE, MovementDirection direction = MovementDirection.RIGHT) { _input = input; Position = position; Action = action; Direction = direction; }
/// <summary> /// Applies the <see cref="T:MovingGardenObject+MovementAction"/> to this object. /// </summary> /// <param name="movementAction">The <see cref="T:MovingGardenObject+MovementAction"/> to apply.</param> public void ApplyMovementAction(MovementAction movementAction) { GridPosition tmp = this + movementAction.GridMovement; this.X = tmp.X; this.Y = tmp.Y; }
public override Action CreateInstance(Unit unit) { MovementAction instance = ScriptableObject.CreateInstance <MovementAction>(); instance.Init(unit, "Move"); return(instance); }
public static MenuItem GetMovementMenuItem(MovementAction movementAction, bool isMovementEnabled = true) { var command = new ObservedCommand(() => { MoveItem(movementAction); }, () => !(GisEditor.LayerListManager.SelectedLayerListItems.Count > 0) && isMovementEnabled); string headerString = String.Empty; string imageName = String.Empty; switch (movementAction) { case MovementAction.Up: headerString = "Move up"; imageName = "moveUp"; break; case MovementAction.Down: headerString = "Move down"; imageName = "moveDown"; break; case MovementAction.ToTop: headerString = "Move to top"; imageName = "toTop"; break; case MovementAction.ToBottom: headerString = "Move to bottom"; imageName = "toBottom"; break; default: break; } return(GetMenuItem(headerString, string.Format("/GisEditorPluginCore;component/Images/{0}.png", imageName), command)); }
public void MoveCharacter(Vector3 position) { MovementAction move = new MovementAction(position, 10); move.owner = gameObject; actionQueue.Add(move); }
private void ApplyFrostbite(MovementAction movement, UnitBasicProperties attacker) { if (attacker.side == UnitSide.Hollow) { movement.MoveDistance = Math.Max(0, movement.MoveDistance - (attacker.isFrozen ? 1 : 0)); } }
private List <Vector3> GetForces(MovementAction movementAction, Vector3 targetPosition, float rotation = 0f, bool enablePlayerForces = false) { List <Vector3> forces = new(); switch (movementAction) { case MovementAction.Move: forces.Add(Seek(targetPosition, 1f)); if (enablePlayerForces) { forces.Add(Seperate(0.05f)); } forces.Add(AvoidObstacles(0.5f)); break; case MovementAction.Follow: forces.Add(Seek(targetPosition, 1f)); forces.Add(Seperate(0.03f)); forces.Add(AvoidObstacles(0.03f)); break; case MovementAction.Chase: forces.Add(Seek(targetPosition, 1f)); break; case MovementAction.Flee: Vector3 fleeForce = Flee(targetPosition, 1f); fleeForce.Z = 0; // set z to zero to avoid going under the terrain forces.Add(fleeForce); break; case MovementAction.Evade: forces.Add(Evade(targetPosition, 1f, rotation)); break; case MovementAction.Wander: Vector3 wanderForce = Wander(1f); wanderForce.Z = 0; // set z to zero to avoid going under the terrain forces.Add(wanderForce); break; case MovementAction.Unstuck: forces.Add(Unstuck(1f)); break; case MovementAction.None: break; case MovementAction.DirectMove: break; default: break; } return(forces); }
// Use this for initialization void Start() { _velocity = new Vector2(0, 0); _direction = new Vector2(0, 0); velocityFunction = setVelocity; GlobalAirFriction = AirFriction; }
public MovementInfo(MovementAction action, string oldPath, string newPath, long oldRevision, long newRevision) { Action = action; OldPath = oldPath; NewPath = newPath; OldRevision = oldRevision; NewRevision = newRevision; }
public MoveVehicleToPositionQuestObjective(WowInterface wowInterface, Vector3 position, double distance, MovementAction movementAction = MovementAction.Moving, bool forceDirectMove = false) { WowInterface = wowInterface; WantedPosition = position; Distance = distance; MovementAction = movementAction; ForceDirectMove = forceDirectMove; }
public async Task WhenMovingIntoUnwalkableTile_ThenMovementIsCancelled() { _playArea.Setup(i => i.GameMap.IsWalkable(It.IsAny <int>(), It.IsAny <int>())).Returns(false); var action = new MovementAction(_creature.Id, MovementDirection.West); await _resolver.ResolveAsync(action); Assert.AreEqual(5, _creature.Position.X); }
public async Task WhenMovingOneStepWest_ThenXPositionIsDecreasedByOne() { _playArea.Setup(i => i.GameMap.IsWalkable(It.IsAny <int>(), It.IsAny <int>())).Returns(true); var action = new MovementAction(_creature.Id, MovementDirection.West); await _resolver.ResolveAsync(action); Assert.AreEqual(4, _creature.Position.X); }
public bool Get(out Vector3 position, out MovementAction type) { if (Bot.CombatClass != null && !Bot.CombatClass.HandlesMovement && IWowUnit.IsValidAliveInCombat(Bot.Player) && IWowUnit.IsValidAlive(Bot.Target) && !Bot.Player.IsGhost) { float distance = Bot.Player.DistanceTo(Bot.Target); switch (Bot.CombatClass.Role) { case WowRole.Dps: if (Bot.CombatClass.IsMelee) { if (distance > Bot.Player.MeleeRangeTo(Bot.Target)) { position = Bot.Target.Position; type = MovementAction.Chase; return(true); } } else { if (distance > 26.5f + Bot.Target.CombatReach) { position = Bot.Target.Position; type = MovementAction.Chase; return(true); } } break; case WowRole.Heal: if (distance > 26.5f + Bot.Target.CombatReach) { position = Bot.Target.Position; type = MovementAction.Chase; return(true); } break; case WowRole.Tank: if (distance > Bot.Player.MeleeRangeTo(Bot.Target)) { position = Bot.Target.Position; type = MovementAction.Chase; return(true); } break; } } type = MovementAction.None; position = Vector3.Zero; return(false); }
public override void PerformMovementActionFromAvailableActions(List <MovementAction> availableActions) { // For now, all moving obstacles simply perform random movements. // Note: Maybe replace with implementation depending on the type. // (e.g. Animals are chasing the robot, Persons are evading it). int randIndex = UnityEngine.Random.Range(0, availableActions.Count); MovementAction chosenMovement = availableActions[randIndex]; PerformMovement(chosenMovement); }
private void FinalizeEncounter() { resolvingMovement = false; movementRecieved = null; attackerRecieved = null; primaryTargetRecieved = null; SetGlobalPanelVisibility(false); }
public void Explorer_RoverActionMove_ForwardsTheRoverOneStepKeepWithinPlateau( int width, int height, int startX, int startY, Orientation orientation, MovementAction action, int expectedx, int expectedy ) { MarsExplorer x = Build(width, height, startX, startY, orientation); var rover = x.Rovers.ToList()[0]; x.DoAction(rover, action); Assert.AreEqual(rover.Position.X, expectedx); Assert.AreEqual(rover.Position.Y, expectedy); }
public void Explorer_RoverActionRotate_ValidNewOrientation( Orientation orientation, MovementAction action, Orientation expected ) { int width = 10; int height = 10; int startX = 2; int startY = 10; MarsExplorer x = Build(width, height, startX, startY, orientation); var rover = x.Rovers.ToList()[0]; x.DoAction(rover, action); rover.Position.Orientation.ShouldBe(expected); }
public void DoAction(Rover rover, MovementAction action) { var moveMap = NavigationProvider.GetMoveActionCommands(); var rotationMap = NavigationProvider.GetRotationCommands(); // Alternate: use a map switch (action) { case MovementAction.M: var moveCommand = moveMap[rover.Position.Orientation]; moveCommand(rover, Plateau); break; case MovementAction.L: case MovementAction.R: var rotationCommand = rotationMap[action]; rotationCommand(rover); break; default: // Is this the correct default action? throw new ApplicationException($"Invalid movment action {action}"); } }
/// <summary> /// Create an action from a string line /// </summary> public static Action Create(string line) { Action.ActionTypes actionType = (Action.ActionTypes)int.Parse(line.Substring (0, line.IndexOf (','))); switch(actionType) { case Action.ActionTypes.Movement: MovementAction mAction = new MovementAction(); mAction.Load(line); return mAction; break; case Action.ActionTypes.Look: LookAction lAction = new LookAction(); lAction.Load(line); return lAction; break; case Action.ActionTypes.Interact: InteractAction iAction = new InteractAction(); iAction.Load(line); return iAction; break; case Action.ActionTypes.TextInfo: TextInfoAction tAction = new TextInfoAction(); tAction.Load(line); return tAction; break; case Action.ActionTypes.Teleport: TeleportAction tlAction = new TeleportAction(); tlAction.Load(line); return tlAction; break; default: return null; break; } }
public void ChooseActions() { // Clears previous lists. abilityActions.Clear(); movementActions.Clear(); allies.Clear(); enemies.Clear(); // Finds allies and enemies. for (int i = 0; i < gameManager.Factions.Count; i++) { if (i == character.Faction) { allies = gameManager.Factions[i].Units; } else { enemies.AddRange(gameManager.Factions[i].Units); } } // Percentage of current health to max health used to determine how healthy a character is. healthiness = character.Health / character.MaxHealth; // Find locations to move to. moveLocations = character.MyLocation.FindPossibleMoves((int)character.Movement, character.Speed); // Find possible abilities to use. abilities = character.Abilities; // Creates a list of movement actions with scores. ScoreMovementActions(); // Chooses a movement action from that list chosenMovement = ChooseMovementAction(); // Creates a list of ability actions based off the chosen movement action ScoreAbilityActions(); // Chooses an ability action from that list. chosenAbility = ChooseAbilityAction(); }