private double HandleOtherRobot(IHommRobot otherRobot) { var combatTriggerTime = BeginCombat(otherRobot.Player, map[robot.Player.Location], map[newLocation]); otherRobot.ControlTrigger.ScheduledTime = combatTriggerTime + 0.01; return(HommRules.Current.CombatDuration); }
public CombatHelper(IHommRobot robot) { this.robot = robot; world = robot.World; player = robot.Player; hommEngine = world.HommEngine; commonEngine = world.CommonEngine; }
private static void DoUpdateLocation(IHommRobot actor, Location newLocation) { actor.World.Round.Update(actor.Player, newLocation); if (actor.Player.HasNoArmy()) { actor.Die(); } }
private double HandleMovementCollision(IHommRobot collisionRobot) { robot.World.Clocks.AddTrigger(new OneTimeTrigger(collisionRobot.ControlTrigger.ScheduledTime, () => { var combatTriggerTime = BeginCombat(collisionRobot.Player, map[robot.Player.Location], map[newLocation]); collisionRobot.ControlTrigger.ScheduledTime = combatTriggerTime + 0.01; })); collisionRobot.ControlTrigger.ScheduledTime = double.PositiveInfinity; return(double.PositiveInfinity); }
internal double Apply(IHommRobot robot) { robot.World.HommEngine.Freeze(robot.ControllerId); robot.World.HommEngine.SetPosition(robot.ControllerId, robot.Player.Location.X, robot.Player.Location.Y); if (WaitDuration != 0) { robot.World.HommEngine.SetAnimation(robot.ControllerId, Animation.Idle); return(WaitDuration); } return(new MovementHelper(robot, MovementDirection).CheckForCombatAndMovePlayer()); }
public MovementHelper(IHommRobot robot, Direction movementDirection) { this.robot = robot; this.movementDirection = movementDirection; world = robot.World; hommEngine = world.HommEngine; commonEngine = world.CommonEngine; player = robot.Player; map = world.Round.Map; newLocation = player.Location.NeighborAt(movementDirection); movementDuration = GetTravelDuration(player, map); }
private void Resolve(HommWorld world, IHommRobot first, IHommRobot second) { var currentTime = world.Clocks.CurrentTime; var combatDuration = HommRules.Current.CombatDuration; var firstAvailable = combatQueue.ContainsKey(first) ? combatQueue[first] : currentTime; var otherAvailable = combatQueue.ContainsKey(second) ? combatQueue[second] : currentTime; var thisCombatStart = Math.Max(firstAvailable, otherAvailable); var thisCombatEnd = combatQueue[first] = combatQueue[second] = thisCombatStart + combatDuration; world.Clocks.AddTrigger(new OneTimeTrigger(thisCombatStart, () => { if (first.IsDisabled || second.IsDisabled) { return; } // TODO: play combat animation world.Clocks.AddTrigger(new OneTimeTrigger(thisCombatEnd, () => { currentCombats.Remove(Tuple.Create(first, second)); currentCombats.Remove(Tuple.Create(second, first)); if (combatQueue[first] == thisCombatEnd) { combatQueue.Remove(first); } if (combatQueue[second] == thisCombatEnd) { combatQueue.Remove(second); } Combat.ResolveBattle(first.Player, second.Player); if (first.Player.HasNoArmy()) { first.Die(); } if (second.Player.HasNoArmy()) { second.Die(); } })); })); }
protected override bool TileFilter(Tile tile, IHommRobot actor, Player playerOnTile) { var scout = actor.Player.Scout; var scoutRadius = HommRules.Current.ScoutRadius; var tileIsObservableByTileScout = scout.IsScoutingTile && tile.Location.EuclideanDistance(scout.TileBeingScouted) <= scoutRadius; var tileIsObservableByHeroScout = scout.IsScoutingHero && playerOnTile != null; var tileIsObservableByScout = tileIsObservableByTileScout || tileIsObservableByHeroScout; return(tileIsObservableByScout || base.TileFilter(tile, actor, playerOnTile)); }
private void MakeTurn(IHommRobot robot) { hommEngine.SetRotation(robot.ControllerId, movementDirection.ToUnityAngle()); if (world.IsEnemySpawn(newLocation, robot.ControllerId)) { hommEngine.SetAnimation(robot.ControllerId, Animation.Idle); hommEngine.Freeze(robot.ControllerId); return; } player.DesiredLocation = newLocation; hommEngine.SetAnimation(robot.ControllerId, Animation.Gallop); hommEngine.Move(robot.Player.Name, movementDirection, movementDuration); world.Clocks.AddTrigger(new LocationTrigger(robot.World.Clocks.CurrentTime, movementDuration, robot, newLocation)); }
public double Resolve(IHommRobot actor) { var others = actor.World.Actors .Where(x => x is IHommRobot) .Cast <IHommRobot>() .Where(x => x != actor && x.Player.Location == actor.Player.Location) .Where(x => !currentCombats.Contains(Tuple.Create(actor, x))); double timeInCombat = 0; foreach (var other in others) { currentCombats.Add(Tuple.Create(actor, other)); timeInCombat += HommRules.Current.CombatDuration; if (!currentCombats.Contains(Tuple.Create(other, actor))) { Resolve(actor.World, actor, other); } } return(timeInCombat); }
public GarrisonBuilderUnit(IHommRobot actor) { this.actor = actor; }
protected virtual bool TileFilter(Tile tile, IHommRobot actor, Player playerOnTile) => tile.Location.EuclideanDistance(actor.Player.Location) <= actor.ViewRadius;
protected virtual bool PlayerFilter(Player player, IHommRobot robot) => player.Location.EuclideanDistance(robot.Player.Location) <= robot.ViewRadius;
public HexMovUnit(IHommRobot actor) { this.actor = actor; }
public ArmyInterfaceUnit(IHommRobot actor) { this.actor = actor; }
public LocationTrigger(double submitTime, double movementDuration, IHommRobot actor, Location newLocation) : base(submitTime + movementDuration, () => DoUpdateLocation(actor, newLocation)) { }
public ScoutInterfaceUnit(IHommRobot actor) { this.actor = actor; }
private static void DoUpdateLocation(IHommRobot actor, Location newLocation) { actor.World.Round.Update(actor.Player, newLocation); actor.World.HommEngine.Freeze(actor.ControllerId); }
protected override bool PlayerFilter(Player player, IHommRobot robot) { return(robot.Player.Scout.IsScoutingHero || robot.Player.Scout.IsScoutingTile || base.PlayerFilter(player, robot)); }