示例#1
0
    public override void OnUpdate()
    {
        if (!isJumpBack)
        {
            return;
        }

        controller.Move(new Vector2(JumpBackFlySpeed * -faceDirectionComponent.FaceDirection * CupheadTime.Delta[CupheadTime.Layer.Enemy], -0.01f));
    }
示例#2
0
        public override void OnUpdate()
        {
            if (dynamicMove)
            {
                var relDir = Util.GetPlayerDirectionRelative(target.position, platformController.transform.position);
                moveTargetX = target.position.x - relDir * statCollection.GetStatValue(KEY_RANGE_X);
            }

            if (dynamicFaceTo)
            {
                faceDirectionComponent.SetFaceDirection(faceToTarget
                                        ? Util.GetPlayerDirectionRelative(target.position, platformController.transform.position)
                                        : -Util.GetPlayerDirectionRelative(target.position, platformController.transform.position));
            }

            var distance = moveTargetX - platformController.transform.position.x;

            if (Mathf.Abs(distance) <= okDistance)
            {
                // Debug.Log ( $"Action_MoveToRange: 已移动到指定范围 distance = {distance} moveTargetX = {moveTargetX} self = {platformController.transform.position.x}" );
                Fsm.Event(finishEvent);
                return;
            }

            if (distance > 0f && platformController.controller.collisionState.right ||
                distance < 0f && platformController.controller.collisionState.left)
            {
                // Debug.Log ( $"Action_MoveToRange: 移动遇到障碍物" );
                Fsm.Event(finishEvent);
                return;
            }

            if (distance < 0f)
            {
                platformController.Move(new Vector2(-statCollection.GetStatValue(Key_MOVE_SPEED) * CupheadTime.Delta[CupheadTime.Layer.Enemy], -0.01f));
            }
            else
            {
                platformController.Move(new Vector2(statCollection.GetStatValue(Key_MOVE_SPEED) * CupheadTime.Delta[CupheadTime.Layer.Enemy], -0.01f));
            }
        }
        public override void OnUpdate()
        {
            _timer += CupheadTime.Delta[CupheadTime.Layer.Enemy];

            if (_timer > _dashDuration)
            {
                Fsm.Event(finishEvent);
                return;
            }

            var movementX = _dashDirection * statCollection.GetStatValue(Key_DASH_SPEED) * CupheadTime.Delta[CupheadTime.Layer.Enemy];

            platformController.Move(new Vector2(movementX, 0f));
        }