Esempio n. 1
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);
    }
Esempio n. 2
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);
        }
    }
Esempio n. 3
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);
        }
    }
Esempio n. 4
0
 private void PickUp()
 {
     if (Input.GetButtonDown("grab"))
     {
         /*
          * {
          * if (!isHolding)
          * {
          *  CheckObject();
          *
          *  if (isHolding)
          *  {
          *
          *      AnalyzeObject();
          *
          *      SetTargetIK();
          *
          *      StartCoroutine(distanceChecker());
          *
          *
          *  }
          *  else return;
          * }
          * else if (isHolding)
          * {
          *  Drop();
          * }
          * }
          *
          * if (isHolding && isInCover)
          * {
          * Drop(); */
         grabAction.ChangeState(new PickUp(this.gameObject, this.GetComponent <IKRef>(), this.GetComponent <InfoBuffer>(), isGrabbable, grabRange, playerHeight, 2.0f /*animation time*/));
         Debug.Log("It's running pickup");
     }
 }