Ejemplo n.º 1
0
    private void SendHumanExplorer(NavNode destNavNode, int squadSize)
    {
        NavNode currentNode = GameManager.Inst.NPCManager.GetNavNodeByHousehold(this);

        if (currentNode == null || destNavNode == null)
        {
            Debug.LogError("No current node or no destNavNode");
            return;
        }

        NavNode nextNavNode = AI.FindNextNavNode(currentNode, destNavNode);

        if (nextNavNode == null)
        {
            Debug.LogError("can't find next nav node");
            return;
        }

        //Debug.Log("GOTO setting new destinatoin " + nextNavNode.name + " currentNode " + currentNode.name);

        //create a squad
        AISquad squad = GameManager.Inst.NPCManager.SpawnHumanExplorerSquad(CurrentSquad.Faction, this);

        squad.NextNavNode = nextNavNode;
        squad.DestNavNode = destNavNode;

        _explorerSquads.Add(squad);

        //decide a max participant number
        int participants = squadSize;

        //loop through all members and pick ones who don't have job
        foreach (Character c in CurrentSquad.Members)
        {
            if (participants <= 0)
            {
                break;
            }

            if (c.MyJobs.Contains(NPCJobs.None) && !c.IsEssential)
            {
                squad.Members.Add(c);
                participants--;
                c.MyJobs.Clear();
                c.MyJobs.Add(NPCJobs.Explore);
                c.MyAI.Squad = squad;
                if (squad.Commander == null)
                {
                    //Debug.Log("Assigned commander to " + c.name);
                    //assign commander job
                    squad.AssignExpCommanderRole(c, squad);
                }
                else
                {
                    //Debug.Log("Assigned follower to " + c.name);
                    squad.AssignExpFollowerRole(c, squad);
                }
            }
        }

        //Debug.LogError("Sending expedition - squad " + squad.ID + " to " + destNavNode.name + " commander " + squad.Commander.name);

        //remove squad member from current squad
        foreach (Character c in squad.Members)
        {
            if (CurrentSquad.Members.Contains(c))
            {
                CurrentSquad.RemoveMember(c);
            }

            c.MyAI.Squad = squad;
            c.SquadID    = squad.ID;
        }
    }