GameMachine.NpcGroup.IsLeader C# (CSharp) Method

IsLeader() public method

public IsLeader ( Npc npc ) : bool
npc Npc
return bool
        public bool IsLeader(Npc npc)
        {
            return (leader == npc);
        }

Usage Example

示例#1
0
        private void CalculateTarget()
        {
            if (action == Action.Attack)
            {
                controller.updateAgentDestination = true;
                return;
            }


            controller.SetPlayerSpeed(0f);

            if (group != null)
            {
                if (group.IsLeader(this))
                {
                    if (group.route != null)
                    {
                        route = group.route;
                        SetTargetFromWaypoint();
                    }
                }
                else if (group.leader != null)
                {
                    if (group.formation == NpcGroup.Formation.SingleFile)
                    {
                        target = group.GetNpcList()[order - 1].transform;
                    }
                    else
                    {
                        if (group.GetFollowTargets().ElementAtOrDefault(order) != null)
                        {
                            target = group.GetFollowTargets()[order];
                        }
                        else
                        {
                            target = group.leader.transform;
                        }
                    }
                }
            }
            else
            {
                if (route != null)
                {
                    SetTargetFromWaypoint();
                }
            }
            controller.updateAgentDestination = true;
        }