Пример #1
0
    public void Enter(ActionNode node)
    {
        VelocityConfig    config     = (VelocityConfig)node.config;
        IActionMachine    machine    = node.actionMachine;
        IActionController controller = (IActionController)node.actionMachine.controller;

        Vector3 velocity;

        if (config.fixDir)
        {
            if (config.useInput)
            {
                var inputData = machine.input.GetRawInput(controller.ID);
                velocity = inputData.GetRotation() * config.velocity;
            }
            else
            {
                velocity = controller.rotation * config.velocity;
            }
        }
        else
        {
            velocity = config.velocity;
        }

        if (config.useHeight)
        {
            velocity.y = MathUtility.JumpSpeed(controller.gravity, config.velocity.y);
        }

        controller.velocity = velocity;
    }
Пример #2
0
        public void OnMessage(IBot bot, Message message)
        {
            if (bot == null || message == null)
            {
                throw new ArgumentException();
            }

            AIResponse aiResponse = _aiService.TextRequest(message.Text);

            if (aiResponse.Result.Action == Data.BotAction.InputUnknown)
            {
                throw new UnrecognizableIntentException();
            }

            IAction action = MapAiResponse(aiResponse);

            action.Message = message;

            IActionController actionController = GetActionController(action);
            IActionResponse   actionResponse   = actionController?.Handle(action);

            IActionResponseController actionResponseController = GetActionResponseController(actionResponse);

            actionResponseController?.HandleAsync(bot, actionResponse);
        }
Пример #3
0
    public void Update(ActionNode node, float deltaTime)
    {
        ConditionConfig   config     = (ConditionConfig)node.config;
        IActionMachine    machine    = node.actionMachine;
        IActionController controller = (IActionController)node.actionMachine.controller;

        if (!config.delayInvoke || !config.EnableBeginEnd())
        {
            if (!Checker(config.checker, machine, controller))
            {
                return;
            }
        }
        else
        {
            int successCnt = (int)node.data;
            if (Checker(config.checker, machine, controller))
            {//为true时计数+1
                node.data = ++successCnt;
            }

            if (successCnt == 0 ||//true的次数为0
                config.allFrameCheck && successCnt != (node.updateCnt + 1) ||//每一帧都必须为true,updateCnt需要+1是因为updateCnt在Update后才会递增
                machine.GetStateFrameIndex() != config.GetEndFrame())//不是最后一帧
            {
                return;
            }
        }

        machine.ChangeState(config.stateName, config.priority);
    }
Пример #4
0
 private void btnStartRecord_Click(object sender, RoutedEventArgs e)
 {
     string strTipText = notifyIcon.BalloonTipText;
     notifyIcon.BalloonTipText = "开始动作录制。按F10键停止录制!";
     notifyIcon.ShowBalloonTip(5000);
     actionController = new ActionController(this, this.recordStrategy);            
     this.actionController.RequestStartRecordActions();
     notifyIcon.BalloonTipText = strTipText;
 }
Пример #5
0
        public bool Execute(IActionMachine machine, IActionController controller)
        {
            if (horzontalCmp != CompareType.none && !CompareUtility.Compare(new Vector2(controller.velocity.x, controller.velocity.z).magnitude, horizontalVelocity, horzontalCmp))
            {
                return(false);
            }
            if (verticalCmp != CompareType.none && !CompareUtility.Compare(controller.velocity.y, verticalVelocity, verticalCmp))
            {
                return(false);
            }

            return(true);
        }
Пример #6
0
        private void MainForm_Loaded(object sender, RoutedEventArgs e)
        {
            actionController = new ActionController(this,RecordStrategies.MouseAndKeyboard);
            

            //Recorder r = new Recorder();
            //r.WriteData("KeyDown", System.Windows.Forms.Keys.A, this.listBoxActions);
            //r.WriteData("KeyUp", System.Windows.Forms.Keys.A, this.listBoxActions);
            //r.GetData();



        }
Пример #7
0
        public CombatController(IActionController actionController,
                                CombatStateHandler combatStateHandler,
                                IViewModelController viewModelController,
                                DisplayManager displayManager,
                                ConsumablesHandler consumablesHandler,
                                ICombatAI combatAI)
        {
            _actionController   = actionController;
            CombatStateHandler  = combatStateHandler;
            _consumablesHandler = consumablesHandler;
            DisplayManager      = displayManager;
            ViewModelController = viewModelController;
            _combatAI           = combatAI;

            BindEvents();
        }
Пример #8
0
    public void AuthorController(ECreatureController _type)
    {
        m_HandleController = null;

        m_Controllers.TryGetValue(_type, out m_HandleController);

        if (m_HandleController != null)
        {
            m_HandleController.OnTakeAuthority();

            if (m_CurrentAuthorityController != null)
            {
                m_CurrentAuthorityController.OnLoseAuthority();

                m_CurrentAuthorityController = m_HandleController;
            }
        }
    }
Пример #9
0
    public void Update(ActionNode node, float deltaTime)
    {
        MoveConfig        config     = (MoveConfig)node.config;
        IActionMachine    machine    = node.actionMachine;
        IActionController controller = (IActionController)node.actionMachine.controller;

        Vector3 velocity = controller.velocity;

        if (machine.input.HasKey(controller.ID, (int)ActionKeyCode.Axis))
        {
            InputData data = machine.input.GetRawInput(controller.ID);

            velocity            = data.GetDir() * config.moveSpeed;
            controller.rotation = data.GetRotation();
        }

        controller.velocity = new Vector3(velocity.x, controller.velocity.y, velocity.z);
    }
Пример #10
0
        private Mock <BotMessageController> MakeControllerMock(
            IAiService aiService,
            IActionController actionController,
            IActionResponseController actionResponseController
            )
        {
            var controllerMock = new Mock <BotMessageController>(aiService, null, null);

            controllerMock
            .Setup(m => m.GetActionController(It.IsAny <IAction>()))
            .Returns(actionController);
            controllerMock
            .Setup(m => m.GetActionResponseController(It.IsAny <IActionResponse>()))
            .Returns(actionResponseController);
            controllerMock
            .Setup(m => m.MapAiResponse(It.IsAny <AIResponse>()))
            .Returns(new AddPokemonFilterAction());

            return(controllerMock);
        }
        //CHANGED
        private ConnectionManager(StreamDeckToolkitOptions options, ILoggerFactory loggerFactory = null, IActionController actionController = null, IStreamDeckProxy streamDeckProxy = null) : this()
        {
            if (actionController == null)
            {
                throw new ArgumentNullException("actionManager", "ActionManager cannot be null, these should be retrieved from commandline args."); //CHANGED
            }
            _ActionController             = actionController;                                                                                       //CHANGED
            _ActionController.DeckManager = this;

            var myInfo = JsonConvert.DeserializeObject <Info>(options.Info);

            Info           = myInfo;
            _port          = options.Port;
            _uuid          = options.PluginUUID;
            _registerEvent = options.RegisterEvent;
            _proxy         = streamDeckProxy ?? new StreamDeckProxy();

            _LoggerFactory = loggerFactory ?? NullLoggerFactory.Instance;
            _logger        = loggerFactory?.CreateLogger <ConnectionManager>();
        }
Пример #12
0
    public void EnableDefaultController(EDefaultController _type, bool _enable)
    {
        m_HandleController = null;

        m_DefaultControllers.TryGetValue(_type, out m_HandleController);

        if (m_HandleController != null)
        {
            if (_enable && !m_HandleController.Enable)
            {
                m_HandleController.OnTakeAuthority();
                m_HandleController.Enable = _enable;
                return;
            }

            if (!_enable && m_HandleController.Enable)
            {
                m_HandleController.OnLoseAuthority();
                m_HandleController.Enable = _enable;
                return;
            }
        }
    }
Пример #13
0
        public bool Execute(IActionMachine machine, IActionController controller)
        {
            bool result = controller.CheckAir();

            return(isNot ? !result : result);
        }
Пример #14
0
 protected ControllerTests(IActionController <T> controller)
 {
     Controller = controller;
 }
Пример #15
0
 internal ActionController(IActionController actionController)
 {
     NativeHandle = actionController;
 }
Пример #16
0
 public void StartFreestyle()
 {
     actionController = new FreestyleAC();
 }
Пример #17
0
 public void StartLearning()
 {
     actionController = new LearningAC();
 }
Пример #18
0
 private void OnDestroy()
 {
     m_HandleController = null;
     m_HandleEnumerator.Dispose();
 }
Пример #19
0
        public bool Execute(IActionMachine machine, IActionController controller)
        {
            bool result = machine.input.HasKey(controller.ID, (int)keyCode, fullMatch);

            return(isNot ? !result : result);
        }
 //CHANGED
 public static ConnectionManager Initialize(string[] commandLineArgs, ILoggerFactory loggerFactory = null, IActionController actionController = null, IStreamDeckProxy streamDeckProxy = null)
 {
     try
     {
         var options = ParseCommandlineArgs(commandLineArgs);
         return(new ConnectionManager(options, loggerFactory, actionController, streamDeckProxy));
     }
     catch
     {
         throw new ArgumentException($"{nameof(commandLineArgs)} must be the commandline args that the StreamDeck application calls this program with.");
     }
 }
Пример #21
0
    public static bool Checker(List <ConditionConfig.IItem> checkers, IActionMachine machine, IActionController controller)
    {
        if (checkers == null || checkers.Count == 0)
        {
            return(true);
        }

        foreach (var checker in checkers)
        {
            if (!checker.Execute(machine, controller))
            {
                return(false);
            }
        }

        return(true);
    }