本文整理汇总了C#中IEvent.getEventName方法的典型用法代码示例。如果您正苦于以下问题:C# IEvent.getEventName方法的具体用法?C# IEvent.getEventName怎么用?C# IEvent.getEventName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEvent
的用法示例。
在下文中一共展示了IEvent.getEventName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: consumeEvent
public bool consumeEvent(IEvent e)
{
if (currentState.getTransitionableState().Keys.Contains(e.getEventName()))
{
LOG.Info("Consuming game event name=" + e.getEventName());
this.currentState = (IGameState)this.currentState.getTransitionableState()[e.getEventName()];
this.currentState.run(e);
return true;
}
else if (currentState.isSubmachineEvent(e))
{
// Transport event to submachine like PlayerMachine or BoardMachine
LOG.Info("Transport submachine event with name=" + e.getEventName());
try
{
currentState.submachineConsumeEvent(e);
}
catch (EventNotAcceptableException ex)
{
return false;
}
return true;
}
else
{
// Reject unvalid event
LOG.Info("Unvalid event in current state (" + this.currentState.getStateName() + ") event name=" + e.getEventName());
return false;
}
}
示例2: consumeEvent
public bool consumeEvent(IEvent e)
{
if (currentState.getTransitionableState().Keys.Contains(e.getEventName()))
{
currentState = currentState.getTransitionableState()[e.getEventName()];
currentState.run(e);
}
else
{
LOG.Error("Unexcepted event occur: " + e.getEventName());
}
return true;
}
示例3: run
public void run(IEvent e)
{
MovingNotify notify = new MovingNotify();
this.boardMachine.fireStateChangedNotification(notify);
LOG.Info(NAME);
if (e.GetType().Equals(typeof(BoardMoveEvent)))
{
bool accepted = false;
Position cPos = ((BoardMoveEvent)e).getCurrentPosition();
Position nPos = ((BoardMoveEvent)e).getNextPosition();
Piece p = this.boardMachine.getBoard().getPieces()[cPos.getRow(), cPos.getCol()];
if (p != null && p.getValidNextPositions().Contains(nPos))
{
accepted = true;
}
if (accepted)
{
LOG.Info("Old: \n" + this.boardMachine.getBoard().ToString());
// Set current Position is null after moved
this.boardMachine.getBoard().getPieces()[cPos.getRow(), cPos.getCol()] = null;
// Move piece selected to new position
this.boardMachine.getBoard().getPieces()[nPos.getRow(), nPos.getCol()] = p;
LOG.Info("New: \n" + this.boardMachine.getBoard().ToString());
// Also process "movedEvent" (don't reject) to change to state "moved"
this.boardMachine.consumeEvent(new BoardMovedEvent());
}
else // Different casual, consume event "RejectEvent" to comeback to ready event
{
this.boardMachine.consumeEvent(new BoardRejectEvent());
LOG.Info("Rejected move from: " + cPos.ToString() + " to: " + nPos.ToString());
}
}
else
{
LOG.Error("Receive unexpected event, name: " + e.getEventName());
}
}
示例4: submachineConsumeEvent
public void submachineConsumeEvent(IEvent e)
{
LOG.Info("Consuming event '" + e.getEventName() + "'");
if (e.GetType().Equals(typeof(BoardMoveEvent)))
{
LOG.Info("Processing move event");
BoardMoveEvent _e = ((BoardMoveEvent)e);
int pid = _e.getPid();
Position currentPosition = _e.getCurrentPosition();
Position nextPosition = _e.getNextPosition();
Piece selectionPiece = this.gameStateMachine.getBoardMachine().getBoard().
getPieces()[currentPosition.getRow(), currentPosition.getCol()];
LOG.Info("Selection piece: " + selectionPiece.getColor());
if (this.gameStateMachine.getPlayers()[pid].getListPieces().Contains(selectionPiece))
{
this.gameStateMachine.getBoardMachine().consumeEvent(e);
}
}
}
示例5: consumeEvent
public bool consumeEvent(IEvent e)
{
if (currentState.getTransitionableState().Keys.Contains(e.getEventName()))
{
LOG.Info("Consume event '" + e.getEventName() + "'");
// Get next state
currentState = currentState.getTransitionableState()[e.getEventName()];
currentState.run(e);
return true;
}
else
{
LOG.Error("Unexpected event occur: " + e.getEventName());
throw new EventNotAcceptableException(e.getEventName()
+ " not acceptable in '" + currentState.getStateName() + "'");
}
}