Example #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;
    }
Example #2
0
        public bool Execute(ActionNode node)
        {
            IActionMachine          machine    = node.actionMachine;
            ActionMachineController controller = (ActionMachineController)node.actionMachine.controller;

            return(isNot ? !controller.isGround : controller.isGround);
        }
Example #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);
    }
Example #4
0
    public void Enter(ActionNode node)
    {
        VelocityConfig          config     = (VelocityConfig)node.config;
        IActionMachine          machine    = node.actionMachine;
        ActionMachineController controller = (ActionMachineController)node.actionMachine.controller;

        controller.rigid.velocity = controller.modelRotation * config.velocity;
    }
Example #5
0
        public bool Execute(ActionNode node)
        {
            IActionMachine          machine    = node.actionMachine;
            ActionMachineController controller = (ActionMachineController)node.actionMachine.controller;
            bool result = InputData.HasEvent(events, fullMatch);

            return(isNot ? !result : result);
        }
Example #6
0
 public void Reset()
 {
     actionMachine   = null;
     beginFrameIndex = -1;
     config          = null;
     handler         = null;
     isUpdating      = false;
     updateCnt       = 0;
     data            = null;
 }
Example #7
0
    public void Update(ActionNode node, float deltaTime)
    {
        ConditionConfig         config     = (ConditionConfig)node.config;
        IActionMachine          machine    = node.actionMachine;
        ActionMachineController controller = (ActionMachineController)node.actionMachine.controller;

        if (Checker(config.checker, node))
        {
            machine.ChangeState(config.stateName, config.priority);
        }
    }
Example #8
0
    private void Start()
    {
        animatorTimer = 0;

        actionMachine = new ActionMachine();
        actionMachine.Initialize(configName, this);

        _modelRotation = modelRoot.rotation;

        InitAnimation();
    }
Example #9
0
    public void Enter(ActionNode node)
    {
        JumpConfig              config     = (JumpConfig)node.config;
        IActionMachine          machine    = node.actionMachine;
        ActionMachineController controller = (ActionMachineController)node.actionMachine.controller;

        float ySpeed = MathUtility.JumpSpeed(Physics.gravity.y, config.maxHeight);

        Vector3 velocity = controller.rigid.velocity;

        velocity.y = ySpeed;
        controller.rigid.velocity = velocity;
    }
Example #10
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);
        }
Example #11
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);
    }
Example #12
0
    public void Update(ActionNode node, float deltaTime)
    {
        MoveConfig              config     = (MoveConfig)node.config;
        IActionMachine          machine    = node.actionMachine;
        ActionMachineController controller = (ActionMachineController)node.actionMachine.controller;

        if (InputData.HasEvent(InputEvents.Moving))
        {
            var velocity = controller.rigid.velocity;
            var move     = InputData.axisValue.normalized * config.moveSpeed;

            velocity.x = move.x;
            velocity.z = move.y;

            controller.rigid.velocity = velocity;
        }
    }
Example #13
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);
    }
Example #14
0
    public void Update(ActionNode node, float deltaTime)
    {
        JumpConfig              config     = (JumpConfig)node.config;
        IActionMachine          machine    = node.actionMachine;
        ActionMachineController controller = (ActionMachineController)node.actionMachine.controller;
        Vector3 velocity = controller.rigid.velocity;

        bool velocityChanged = false;

        if (!InputData.HasEvent(InputEvents.Jumping))
        {
            float ySpeed = MathUtility.JumpSpeed(Physics.gravity.y, config.minHeight);
            if (velocity.y > ySpeed)
            {//限制到最小速度
                velocity.y      = ySpeed;
                velocityChanged = true;
            }
        }

        if (InputData.HasEvent(InputEvents.Moving))
        {//空中移动
            var move = InputData.axisValue.normalized * config.moveSpeed;
            velocity.x      = move.x;
            velocity.z      = move.y;
            velocityChanged = true;
        }

        if (velocityChanged)
        {
            controller.rigid.velocity = velocity;
        }

        if (controller.isGround)
        {//落地跳转
            machine.ChangeState(config.nextState);
        }
    }
Example #15
0
        public bool Execute(IActionMachine machine, IActionController controller)
        {
            bool result = controller.CheckAir();

            return(isNot ? !result : result);
        }
Example #16
0
        public bool Execute(IActionMachine machine, IActionController controller)
        {
            bool result = machine.input.HasKey(controller.ID, (int)keyCode, fullMatch);

            return(isNot ? !result : result);
        }
Example #17
0
 public void Exit(ActionNode node)
 {
     MoveConfig     config  = (MoveConfig)node.config;
     IActionMachine machine = node.actionMachine;
     //IActionController controller = (IActionController)node.actionMachine.controller;
 }