// Sends all of the planned AI actions to the engine private void SendActions() { if (waitingToSend) { if (System.Environment.TickCount > departureTime) { // We're ready to send an action to the engine waitingToSend = false; NotifyArgs args = turnActions.Peek(); // If we have an AI move, we need to push the MapMovementGameState so that the player has an indication before the actual move is issued if (!pushedState && args.ArgsType == NotifyArgs.ArgType.Move) { pushedState = true; Haxxit.Maps.MoveEventArgs moveEventArgs = (Haxxit.Maps.MoveEventArgs)args.EventArgsItem; GameStates.MapMovementGameState new_state = new GameStates.MapMovementGameState(backgroundState, moveEventArgs.Start); new_state.MoveAI = true; _notifiable_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state)); } // If we have an AI command, we need to push the MapAttackGameState so that the player has an indication before the actual command is issued else if (!pushedState && args.ArgsType == NotifyArgs.ArgType.Command) { pushedState = true; Haxxit.Maps.CommandEventArgs commandEventArgs = (Haxxit.Maps.CommandEventArgs)args.EventArgsItem; GameStates.MapAttackGameState new_state = new GameStates.MapAttackGameState(backgroundState, commandEventArgs.AttackerPoint, commandEventArgs.Command); new_state.CommandAI = true; _notifiable_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state)); } // We're either following up an overlayed state push with the actual event (move or command) or we're signalying the end of the AI's turn else { pushedState = false; args = turnActions.Dequeue(); _notifiable_manager.Notify(args.EventItem, args.ObjectItem, args.EventArgsItem); } } } else if (turnActions.Any()) { // We're ready to retrieve the next action waitingToSend = true; // Now handled A.S.A.P. since ACTIONSTALLTIME is used in move/command states departureTime = System.Environment.TickCount + 0; } else { // We've sent all the actions state = AIState.Waiting; } }
public void OnAttackClick(DrawableRectangle rectangle) { Haxxit.Maps.Map map = user_map_state.display_map_state.Map; foreach (Tuple<DrawableRectangle, string> attack in attacks) { if (attack.Item1 == rectangle) { if (!map.GetNode<Haxxit.Maps.ProgramHeadNode>(selected_program).Program.HasCommand(attack.Item2)) break; MapAttackGameState new_state = new MapAttackGameState(user_map_state, selected_program, attack.Item2); _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state)); } } }