public override GameState Operate(GameState currentState) { GameState newState = currentState.Copy(); IEnumerable <PathGraphVertex> path = PathGraph.FindShortestPath(currentState.Position, Game.Player.Position, false); float length = PathGraph.GetLengthOfPath(path); float duration = length / Human.RunSpeed; newState.AddTime(TimeSpan.FromSeconds(duration)); newState.Position = Game.Player.Position; newState.Damage -= Game.Player.Health; newState.Health -= Game.Player.Health * 0.9f; bool one = false; for (int i = 0; i < newState.QuarterStates.Length; i++) { if (newState.QuarterStates[i].Ownership == QuarterOwnership.His) { if (one) { newState.QuarterStates[i].Ownership = QuarterOwnership.Empty; newState.QuarterStates[i].OwnershipDuration = TimeSpan.Zero; } one = true; } } return(newState); }
/// <summary> /// Recomputes the waypoints according to path graph to get to the task target. /// </summary> /// <param name="from">Start position</param> /// <param name="to">Destination position</param> protected void RecomputeWaypoints(PositionInTown from, PositionInTown to) { wayPoints.Clear(); foreach (PathGraphVertex v in PathGraph.FindShortestPath(from, to, !(holder is Opponent))) { wayPoints.Enqueue(new WayPoint(v.Position)); } wayPoints.Enqueue(new WayPoint(to)); }
public override GameState Operate(GameState currentState) { IEnumerable <PathGraphVertex> path = PathGraph.FindShortestPath(currentState.Position, actionObject.Position, false); float length = PathGraph.GetLengthOfPath(path); GameState newState = currentState.Copy(); float duration = length / Human.RunSpeed; newState.AddTime(TimeSpan.FromSeconds(duration)); newState.Position = actionObject.Position; return(newState); }
public override GameState Operate(GameState currentState) { IEnumerable <PathGraphVertex> path = PathGraph.FindShortestPath(currentState.Position, box.Position, false); float length = PathGraph.GetLengthOfPath(path); GameState newState = currentState.Copy(); float duration = length / Human.RunSpeed; newState.AddTime(TimeSpan.FromSeconds(duration)); if (box is ToolBox) { GunType gunType = Game.BoxDefaultGuns[Game.Random.Next(Game.BoxDefaultGuns.Count)]; newState.Damage += gunType.Damage * gunType.DefaultBulletCount; } else { newState.Health = 100; } newState.Position = box.Position; return(newState); }