Exemplo n.º 1
0
    private void CheckBehaviour(GameObject npc, NPC.BehaviourType bhv)
    {
        bool leaderOrder = false;

        foreach (NPCInfo inf in NPCInfos)
        {
            if (inf.GetGameObject() == npc)
            {
                leaderOrder = inf.IsLeader();
                break;
            }
        }

        if ((bhv > generalBehavior && bhv != NPC.BehaviourType.Bush) || leaderOrder)
        {
            generalBehavior = bhv;
            foreach (NPCInfo inf in NPCInfos)
            {
                if (inf.GetGameObject() == npc)
                {
                    SetFormation(inf);
                }
            }
        }
        else if (bhv != NPC.BehaviourType.Bush)
        {
            ResetFormation();
        }
    }
Exemplo n.º 2
0
 public void SetNPCBehavior(GameObject npc, NPC.BehaviourType newBehaviour)
 {
     foreach (NPCInfo inf in NPCInfos)
     {
         if (inf.GetGameObject() == npc)
         {
             inf.SetBehaviour(newBehaviour);
             CheckBehaviour(npc, newBehaviour);
             return;
         }
     }
 }
Exemplo n.º 3
0
    void Start()
    {
        GameObject[] NPCs = GameObject.FindGameObjectsWithTag("NPC");

        foreach (GameObject obj in NPCs)
        {
            NPCInfo temp = new NPCInfo();
            temp.SetGameObject(obj);
            temp.SetLeader(false);
            temp.SetBehaviour(NPC.BehaviourType.Wander);
            NPCInfos.Add(temp);
        }
        generalBehavior = NPC.BehaviourType.Wander;

        SetFormation(GetMiddleNPC());
    }
Exemplo n.º 4
0
 public void SetBehaviour(NPC.BehaviourType newBehaviour)
 {
     behaviour = newBehaviour;
 }