コード例 #1
0
ファイル: FBWorld_Logic.cs プロジェクト: CookiRui/script
    public void doSliding(FBActor actor)
    {
        FBActor        controlBallActor = null;
        List <FBActor> temp             = new List <FBActor>();

        for (int i = 0; i < m_actors.Count; ++i)
        {
            FBActor target = m_actors[i];
            if (target == actor || target.ignoreCollision)
            {
                continue;
            }
            if (target.team == actor.team)
            {
                continue;
            }
            if (target.isDoorKeeper())
            {
                continue;
            }

            FixVector2 relativePos = target.getPosition() - actor.getPosition();
            if (relativePos.squareLength > actor.configuration.st_maxSlidingTargetDistance.square)
            {
                continue;
            }

            if (FixVector2.dot(actor.direction, relativePos.normalized) < Fix64.Cos(actor.configuration.st_maxSlidingTargetAngle))
            {
                continue;
            }

            if (target.isCtrlBall())
            {
                controlBallActor = target;
                break;
            }
            temp.Add(target);
        }

        if (controlBallActor != null)
        {
            actor.doSliding((controlBallActor.getPosition() - actor.getPosition()).normalized);
        }
        else if (temp.Count == 0)
        {
            actor.doSliding(actor.direction);
        }
        else
        {
            FixVector2 preferPoint = actor.getPosition();
            temp.Sort(new FBActorTargetFindCompare(preferPoint));
            actor.doSliding((temp[0].getPosition() - actor.getPosition()).normalized);
        }
    }