public override void CheckIfHackedListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { if (sender.GetType() != typeof(DataNode)) return; Player winner = CheckIfMapHacked((DataNode)sender); if (has_been_hacked) Mediator.Notify("haxxit.map.hacked", this, new HackedEventArgs(winner, EarnedSilicoins)); }
/// <summary> /// A listener for notifications to push states sent through haxxit.engine.state.push. /// </summary> /// <param name="channel">The channel the notification is being sent through (haxxit.engine.state.push).</param> /// <param name="sender">The sender object of this notification.</param> /// <param name="args">The arguments for this notification (only takes ChangeStateEventArgs).</param> public void PushStateListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { ChangeStateEventArgs event_args = (ChangeStateEventArgs)args; PushState(event_args.State); }
/// <summary> /// A listener for notifications to pop states sent through haxxit.engine.state.pop. /// </summary> /// <param name="channel">The channel the notification is being sent through (haxxit.engine.state.pop).</param> /// <param name="sender">The sender object of this notification.</param> /// <param name="args">The arguments for this notification (requires no arguments).</param> public void PopStateListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { PopState(); }
/// <summary> /// A listener for notifications to clear the state stack sent through haxxit.engine.state.clear_all /// </summary> /// <param name="channel">The channel the notification is being sent through (haxxit.engine.state.clear_all).</param> /// <param name="sender">The sender object of this notification.</param> /// <param name="args">The arguments for this notification (requires no arguments).</param> public void ClearAllStateListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { ClearStates(); }
private void TurnDoneListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { _mediator_manager.Notify("haxxit.undo_stack.clear", this, new EventArgs()); TempDialogGameState new_state; // This does not work since SimplePubSub does not guarentee any ordering of subscribers. //if (display_map_state.Map.CurrentPlayer.GetType() == typeof(PlayerAI)) if (!is_ai_turn) { new_state = new TempDialogGameState(this, "S.A.N.T.A.'s turn", 1000); is_ai_turn = true; } else { new_state = new TempDialogGameState(this, "Your turn", 1000); is_ai_turn = false; } foreach (DrawableRectangle rectangle in head_nodes.Values) { rectangle.FillColor = Color.Transparent; } _mediator_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state)); }
private void SilicoinNodeListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { SilicoinEventArgs event_args = (SilicoinEventArgs)args; TempDialogGameState new_state = new TempDialogGameState(this, "Added " + event_args.Silicoins.ToString() + " silicoins.", 500); // This breaks everything for some reason. //_mediator_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state)); }
private void MapHackedListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { Haxxit.Maps.HackedEventArgs event_args = args as Haxxit.Maps.HackedEventArgs; //WinGameState new_state = new WinGameState(event_args.EarnedSilicoins, this); WinGameState new_state = new WinGameState(display_map_state.Map.EarnedSilicoins, event_args.WinningPlayer, this); _mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state)); }
private void MapChangedListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { Haxxit.Maps.MapChangedEventArgs event_args = (Haxxit.Maps.MapChangedEventArgs)args; foreach (Haxxit.Maps.Point p in event_args.ChangedNodes) { if (head_nodes.ContainsKey(p) && !display_map_state.Map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(p)) head_nodes.Remove(p); else if (display_map_state.Map.NodeIsType<Haxxit.Maps.ProgramHeadNode>(p)) { head_nodes[p] = DrawProgramHead(p, display_map_state.Map.GetNode<Haxxit.Maps.ProgramHeadNode>(p)); } } }
public override void NewMediator(SimplePubSub.IMediator mediator) { display_map_state.Mediator = mediator; }
private void MapChangedListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { Haxxit.Maps.MapChangedEventArgs event_args = (Haxxit.Maps.MapChangedEventArgs)args; foreach (Haxxit.Maps.Point p in event_args.ChangedNodes) { map_squares[p] = MapNodeToRectangle(p); // This is needed to fix display issues with connectors for ProgramNodes foreach(Haxxit.Maps.Point neighbor in p.GetOrthologicalNeighbors()) if(Map.IsInBounds(neighbor)) map_squares[neighbor] = MapNodeToRectangle(neighbor); } }
public override void NewMediator(SimplePubSub.IMediator mediator) { Map.Mediator = mediator; UndoStack.Mediator = mediator; foreach (Player player in Map.AllPlayers) player.Notifiable = mediator; }
public override void CheckIfHackedListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { Player winner = CheckIfMapHacked(); if (has_been_hacked) Mediator.Notify("haxxit.map.hacked", this, new HackedEventArgs(winner, EarnedSilicoins)); }
public override void CheckIfHackedListener(SimplePubSub.INotifiable notifiable, string channel, object sender, EventArgs args) { }