コード例 #1
0
ファイル: FBActor_Logic.cs プロジェクト: CookiRui/script
    public bool checkSlidingTarget(FBActor actor)
    {
        if (actor == this || actor.ignoreCollision)
        {
            return(false);
        }
        if (actor.team == this.team)
        {
            return(false);
        }
        if (actor.isDoorKeeper())
        {
            return(false);
        }

        if (m_slidingTargets.Contains(actor))
        {
            return(false);
        }
        //var s = actor.m_particle.radius + m_particle.radius;
        var s = actor.m_particle.radius + m_particle.radius + (Fix64)0.1f;

        if (m_particle.position.squareDistance(actor.m_particle.position) <= s * s)
        {
            m_slidingTargets.Add(actor);
            return(true);
        }
        return(false);
    }
コード例 #2
0
ファイル: FBBall.cs プロジェクト: CookiRui/script
    // 球被某个球员直接获得
    public void transfer(FBActor actor)
    {
        if (actor == null || actor == m_owner)
        {
            return;
        }
        var old = m_owner;

        m_owner = actor;

        if (old != null)
        {
            world.onOwnerDetached(old);
            if (old.team != actor.team)
            {
                setEnergy(energy.changeTarget);
            }
        }
        else
        {
            world.world.removeParticle(m_particle);
            m_particle.notify_catched();
            if (m_kicker != null && m_kicker.team != actor.team)
            {
                setEnergy(energy.changeTarget);
            }
        }

        m_willBeCatched      = false;
        m_willBeCatchedActor = null;
        transferTarget       = null;
        m_kicker             = null;
        world.onOwnerAttached(m_owner);
        ballState = m_owner.isDoorKeeper() ? BallState.GoalKeeper : BallState.Player;
    }
コード例 #3
0
    public void aiTakeOver(bool value)
    {
        if (actor.AIing == value)
        {
            return;
        }

        actor.AIing = value;
        if (value)
        {
            if (actor.isDoorKeeper())
            {
                if (agent == null)
                {
                    agent = new FBGKAgent(actor, btWorkspace);
                }
                world.addGK(agent as FBGKAgent, actor.team);
            }
            else
            {
                if (agent == null)
                {
                    agent = new FBPlayerAgent(actor, btWorkspace);
                }
                world.addAgent(agent, actor.team);
            }
        }
        else
        {
            if (agent != null)
            {
                if (actor.isDoorKeeper())
                {
                    world.removeGK(actor.team);
                }
                else
                {
                    world.removeAgent(agent, actor.team);
                }
                agent.stop();
            }
        }
    }
コード例 #4
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);
        }
    }
コード例 #5
0
 public void onActorCreated(FBActor actor)
 {
     fbGame.generateRenderActionToTargetList <RAL.CreateActorAction>(FBGame.RenderActionListType.kLogicBefore,
                                                                     actor.id,
                                                                     actor.roleId,
                                                                     actor.team,
                                                                     actor.name,
                                                                     actor.getPosition().toVector2(),
                                                                     actor.isDoorKeeper(),
                                                                     actor.configuration.element,
                                                                     (float)actor.configuration.bodyHeight,
                                                                     actor.configuration.normalSpeed.ToFloatArray());
 }
コード例 #6
0
ファイル: FBWorld_Logic.cs プロジェクト: CookiRui/script
 // 处理球员铲球
 void _processActorSliding(FBActor actor)
 {
     if (m_ball.owner == actor && !actor.isDoorKeeper())
     {
         return;
     }
     foreach (var p in m_actors)
     {
         if (actor.checkSlidingTarget(p))
         {
             if (m_ball.owner == p)
             {
                 // 铲到持球队员
                 //int rnd = randomValue;
                 //if (rnd % 100 > 50)
                 //{
                 //    p.beSlid_dropBall();
                 //    m_ball.transfer(actor);
                 //}
                 //else if (rnd % 100 > 50)
                 if (true)
                 {
                     _processAttack(actor, m_ball.owner);
                 }
                 else
                 {
                     p.beSlid_keepBall();
                 }
             }
             else
             {
                 // 铲到无球队员
                 _processAttack(actor, p);
             }
         }
     }
 }
コード例 #7
0
 public void onOwnerAttached(FBActor owner)
 {
     //UnityEngine.Debug.LogError("onOwnerAttached fire onChangeCampState " + owner.team);
     LogicEvent.fire("onChangeCampState", owner.team);
     fbGame.generateRenderAction <RAL.BallAttachAction>(owner.id, owner.isDoorKeeper());
 }