Example #1
0
    public void UpdateSquadMembers() //updates members and sets up manager
    {
        SquadMembers.Clear();

        GameObject squadParent    = null;
        float      squadSpeedTemp = 100000f; //declare a temp speed

        foreach (var go in GetComponentsInChildren <Transform>())
        {
            if (go.name == "SquadMembers")
            {
                squadParent = go.gameObject;
            }
        }

        foreach (var member in squadParent.GetComponentsInChildren <Transform>())
        {
            if (member.GetComponent <SquadMemberManager>() != null)
            {
                SquadMembers.Add(member.gameObject);
            }
        }

        int i = 0;

        foreach (var member in SquadMembers) //search for slowest man in squaad and setup members
        {
            SquadMemberManager memberManager = member.GetComponent <SquadMemberManager>();

            if (memberManager.speed < squadSpeedTemp) //is it slower than others?
            {
                squadSpeedTemp = memberManager.speed;
            }
            memberManager.SetPlaceholder(Placeholders[i]); //set default positin
            memberManager.GoPosition();                    //send him to position
            memberManager.Team = Team;
            memberManager.SetMyManager(gameObject);        //set his manager

            i++;
        }

        SetSquadSpeed(squadSpeedTemp); //set everyones speed to slowest man in squad
        SetSquadTeam(Team);
        manCount = squadMembers.Count;
        Alive    = true;
    }
Example #2
0
    private void UpdateSquadMembers() //updates members and sets up manager
    {
        squadMembers.Clear();

        GameObject squadParent    = null;
        float      squadSpeedTemp = 100000f; //declare a temp speed

        foreach (var go in GetComponentsInChildren <Transform>())
        {
            if (go.name == "SquadMembers")
            {
                squadParent = go.gameObject;
            }
        }

        foreach (var member in squadParent.GetComponentsInChildren <Transform>())
        {
            if (member.GetComponent <SquadMemberManager>() != null)
            {
                squadMembers.Add(member.gameObject);
            }
        }

        int i = 0;

        foreach (var member in squadMembers) //search for slowest man in squaad and setup members
        {
            SquadMemberManager memberManager = member.GetComponent <SquadMemberManager>();

            if (memberManager.speed < squadSpeedTemp) //is it slower than others?
            {
                squadSpeedTemp = memberManager.speed;
            }
            memberManager.SetPlaceholder(placeholders[i]); //set default positin
            memberManager.GoPosition();                    //send him to position
            memberManager.SetTeam(team);                   // TODO: remove it later FOR TESTING. Use SetSquadTeam() from player when squad spawned

            i++;
        }

        SetSquadSpeed(squadSpeedTemp); //set everyones speed to slowest man in squad
    }