Exemplo n.º 1
0
    //this is a function that looks for the flag and checks to see if it is within thier home base
    public bool CheckflagAtBase(Sensing sense, AgentData data, GameObject FriendBase)
    {
        //gets a list of the items within view
        List <GameObject> temp = new List <GameObject>();

        //finds all items with the flag tag
        foreach (GameObject g in sense.GetObjectsInViewByTag("Flag"))
        {
            temp.Add(g);
        }

        for (int i = 0; i < temp.Count; ++i)
        {
            if (temp[i].name == data.EnemyFlagName)
            {
                Debug.Log("Found Flag");
                if (temp[i].transform.position.x == FriendBase.transform.position.x || (temp[i].transform.position.x == FriendBase.transform.position.x - 50) || (temp[i].transform.position.x == FriendBase.transform.position.x + 50))
                {
                    return(true);
                }
            }
        }


        return(false);
    }
Exemplo n.º 2
0
    // a function that allows the ai to pick up a flag if they are close enough and see it within view
    public bool PickUpFlag(Sensing sight, AgentActions actions, AgentData data)
    {
        List <GameObject> temp = new List <GameObject>();

        foreach (GameObject g in sight.GetObjectsInViewByTag("Flag"))
        {
            temp.Add(g);
        }

        for (int i = 0; i < temp.Count; ++i)
        {
            if (temp[i].name == "Red Flag") //checks to make sure the item within range is the red flag
            {
                if (data.FriendlyTeamTag == Tags.BlueTeam)
                {
                    //when the Ai is within view distance
                    actions.MoveTo(temp[i]);
                    // then it collects the item
                    actions.CollectItem(temp[i]);
                }
            }
            else if (temp[i].name == "Blue Flag") //checks to make sure the item within range is the blue flag
            {
                if (data.FriendlyTeamTag == Tags.RedTeam)
                {
                    //when the Ai is within view distance
                    actions.MoveTo(temp[i]);
                    // then it collects the item
                    actions.CollectItem(temp[i]);
                }
            }
        }

        if (data.HasEnemyFlag)
        {
            return(true);
        }



        return(false);
    }
Exemplo n.º 3
0
    // a function that gets the ai to try and get thier own flag back and return it to thier base
    public bool RetrieveFlag(Sensing sight, AgentActions actions, AgentData data, AI theai)
    {
        List <GameObject> Temp = new List <GameObject>();

        foreach (GameObject G in sight.GetObjectsInViewByTag("Flag"))
        {
            Temp.Add(G);
        }

        for (int i = 0; i < Temp.Count; ++i)
        {
            if (Temp[i].name == "Red Flag") //checks to make sure the item within range is the red flag
            {
                if (data.FriendlyTeamTag == "Red Team")
                {
                    //when the Ai is within view distance
                    actions.MoveTo(Temp[i]);
                    // then it collects the item
                    actions.CollectItem(Temp[i]);
                }
            }
            else if (Temp[i].name == "Blue Flag") //checks to make sure the item within range is the blue flag
            {
                if (data.FriendlyTeamTag == "Blue Team")
                {
                    //when the Ai is within view distance
                    actions.MoveTo(Temp[i]);
                    // then it collects the item
                    actions.CollectItem(Temp[i]);
                }
            }
        }

        if (data.HasFriendlyFlag)
        {
            theai.GotFriendlyFlag = true;
        }

        return(true);
    }
Exemplo n.º 4
0
    // a function that checks all objects in view and trys to find all of them that are classified as an enemy
    public bool FindEnemyflag(Sensing sight, AgentData data)
    {
        //gets a list of the items within view
        List <GameObject> temp = new List <GameObject>();

        //finds all items with the flag tag
        foreach (GameObject g in sight.GetObjectsInViewByTag("Flag"))
        {
            temp.Add(g);
        }

        for (int i = 0; i < temp.Count; ++i)
        {
            if (temp[i].name == data.EnemyFlagName)
            {
                return(true);
            }
        }


        return(false);
    }