当前位置: 首页>>代码示例>>C#>>正文


C# IEvent.getEventName方法代码示例

本文整理汇总了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;
            }

        }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:31,代码来源:GameStateMachine.cs

示例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;
 }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:13,代码来源:BoardStateMachine.cs

示例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());
            }
        }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:42,代码来源:BoardMovingState.cs

示例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);

                }
            }

        }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:23,代码来源:GamePlayingState.cs

示例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() + "'");
     }
 }
开发者ID:hoangchunghien,项目名称:ChineseChessLearning,代码行数:17,代码来源:PlayerStateMachine.cs


注:本文中的IEvent.getEventName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。