コード例 #1
0
        public override void update(FBActor actor, Fix64 deltaTime)
        {
            if (Movement.checkCatchingBall(actor))
            {
                return;
            }

            actor.updateMovingState();

            if (actor.m_stateActor == null && actor.m_stateBall == null)
            {
                actor.m_RunTimeMovementState = null;
                actor.setToMovementState();
                return;
            }

            FixVector2 targetPosition = actor.m_stateActor != null?actor.m_stateActor.getPosition() : actor.m_stateBall.getPosition();

            //处理旋转
            var moveDirection = targetPosition - actor.getPosition();

            moveDirection.normalize();
            processRotation(actor, moveDirection, deltaTime * actor.m_configuration.m1_angularSpeed);

            // 如果不移动,则减速
            if (actor.m_movePower == Fix64.Zero)
            {
                actor.m_particle.dampingAcceleration =
                    actor.world.ball.owner != actor ?
                    actor.m_configuration.m1_stopDampingAcceleration :
                    actor.m_configuration.m1_stopDampingAcceleration_ball;
                return;
            }

            //处理位移
            actor.m_particle.dampingAcceleration = Fix64.Zero;
            actor.defendMoveDirection            = actor.getMoveDirection();
            actor.m_particle.maxSpeed            = actor.m_configuration.dm1_maxSpeed[(int)actor.defendMoveDirection - 1];
            actor.m_particle.addForce(actor.moveDirection * (actor.m_configuration.m1_moveForce * actor.m_movePower));
        }