/// <summary>
        /// Выполняет новую команду, затирая отмененные.
        /// </summary>
        /// <param name="command">Command to execute.</param>
        public void ExecuteNewCommand(Command command)
        {
            if (command == null)
                return;

            _undone.Clear();
            MovesUndone = 0;

            command.Do();
            _done.Push(command);

            if (command is MoveEndCommand)
                MovesDone++;

            OnCommandEvent(command, CommandStatus.Done);
        }
 protected void ExecuteNewCommand(Command command)
 {
     _commandManager.ExecuteNewCommand(command);
 }
 protected virtual void OnCommandEvent(Command cmd, CommandStatus status)
 {
     var handler = CommandEvent;
     if (handler != null)
         handler(cmd, status);
 }
예제 #4
0
        private void HandleCommand(Command cmd, CommandStatus status)
        {
            OnLogEvent(string.Format("{0}: {1}", status, cmd));

            ActionCommand actionCmd = cmd as ActionCommand;

            if (cmd.Status != CommandStatus.Undone)
            {
                if (actionCmd != null)
                {
                    if (actionCmd.IsDeadly)
                    {
                        OnDeathEvent(actionCmd.Target.Changed);
                    }

                    if (actionCmd is SpecialActionCommand)
                    {
                        OnSpecialActionEvent(actionCmd.ToString());
                    }

                    return;
                }

                GameOverCommand overCmd = cmd as GameOverCommand;

                if (overCmd != null)
                {
                    OnGameOverEvent(overCmd.ToString());
                }
            }
        }