Ejemplo n.º 1
0
    // a function that once the Ai becomes low on health they will begin to move away from the fight and is they see the health kit within view then they will use it
    public bool Fleeing(AgentActions actions, AgentData data, Sensing sensing, bool HealthZone)
    {
        List <GameObject> objects = sensing.GetCollectablesInView();

        for (int i = 0; i < objects.Count; i++)
        {
            if (objects[i].name == "Health Kit")
            {
                objects[i].GetComponent <HealthKit>().Use(data);
            }
        }

        if (!HealthZone)
        {
            if (data.FriendlyTeamTag == Tags.BlueTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("HealthKit"));
            }
            else if (data.FriendlyTeamTag == Tags.RedTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("HealthKit"));
            }
        }



        return(true);
    }
Ejemplo n.º 2
0
    // a function that allows the enemy to move towards the powerup if they see it and if they are within range they will be able to use the power up
    public bool FindPowerUp(Sensing sense, AgentData data, AgentActions actions, bool PowerUpZone)
    {
        List <GameObject> objects = sense.GetCollectablesInView();

        for (int i = 0; i < objects.Count; i++)
        {
            if (objects[i].name == "Power Up")
            {
                if (sense.IsItemInReach(objects[i]))
                {
                    objects[i].GetComponent <PowerUp>().Use(data);
                }
            }
        }

        if (!PowerUpZone)
        {
            if (data.FriendlyTeamTag == Tags.BlueTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("Powerup"));
            }
            else if (data.FriendlyTeamTag == Tags.RedTeam)
            {
                actions.MoveTo(GameObject.FindGameObjectWithTag("Powerup"));
            }
        }

        return(true);
    }
Ejemplo n.º 3
0
    // a function that allows the aI to be able to find the health kit and if it is within reach range then the ai will use it. if not they will then begin to move up to it
    public bool FindHealthKit(AgentActions actions, Sensing sensing, AgentData data, GameObject HealthZone)
    {
        actions.MoveTo(HealthZone);
        //actions.PauseMovement();


        // need to make this so that it only uses move to random once so it can actually move

        List <GameObject> objects = sensing.GetCollectablesInView();

        for (int i = 0; i < objects.Count; i++)
        {
            if (objects[i].name == "Health Kit")
            {
                if (sensing.IsItemInReach(objects[i]))
                {
                    objects[i].GetComponent <HealthKit>().Use(data);
                }
            }
        }

        return(true);
    }