Пример #1
0
 public FBBall createBall(uint id, FixVector3 position, FBBall.Configuration config)
 {
     m_ball = new FBBall(config, this.config);
     (m_ball as IElement).setWorld(this);
     m_ball.id = id;
     m_ball.reset(position);
     this.onBallCreated(id, position, config.radius);
     return(m_ball);
 }
Пример #2
0
 public bool startDefend(FBBall target)
 {
     if (target == null)
     {
         return(false);
     }
     if (_setNextState(DefendMovement.instance, false))
     {
         m_stateBall  = target;
         m_stateActor = null;
         m_currentState.enter(this);
         return(true);
     }
     return(false);
 }
Пример #3
0
    bool _checkContact(FBBall ball, FBActor actor)
    {
        // TODO:
        if (ball.get3DPosition().y > actor.configuration.bodyHeight)
        {
            return(false);
        }

        if (ball.kicker == actor && actor.isKickingBall)
        {
            return(false);
        }

        ball.onCollided(actor);
        return(true);
    }
Пример #4
0
    public void clear()
    {
        Debuger.Log("World clear");
        m_actors.Clear();

        m_mainExtent = FixVector2.kZero;
        m_doorExtent = FixVector2.kZero;
        m_doorHeight = Fix64.Zero;
        config       = null;
        redCoach     = null;
        blueCoach    = null;
        redGKCoach   = null;
        blueGKCoach  = null;
        m_arena      = null;
        m_world      = null;
        m_ball       = null;
    }
Пример #5
0
    public bool checkBallCatchingWhenMoving(FBBall ball, out Fix64 weight)
    {
        weight = Fix64.Zero;
        if (!(m_currentState == Movement.instance || m_currentState == DefendMovement.instance))
        {
            return(false);
        }
        //如果没有速度的情况下,不处理此种情况的拿球
        if (particle.velocity == FixVector2.kZero)
        {
            return(false);
        }


        if (ball.get3DPosition().y > m_configuration.maxCatchingBallHeight)
        {
            return(false);
        }

        var s = this.configuration.catchingRadius;
        var d = m_particle.position.distance(ball.particlePosition);

        if (d > s)
        {
            return(false);
        }
        //jlx 2017.04.24-log:在配置角度(catchingAngle)内才能被捕获
        var dir = (ball.particlePosition - m_particle.position).normalized;
        var dot = FixVector2.dot(direction, dir);

        if (dot <= m_configuration.catchingAngle)
        {
            return(false);
        }

        if (s != Fix64.Zero)
        {
            weight = Fix64.One - d / s;
        }
        return(true);
    }