Ejemplo n.º 1
0
    //All groups have the player included and weighted
    private Vector2 calcGroupAvgPos(string groupName)
    {
        List <FriendlyAgent> ags = agents[groupName];

        if (ags == null || ags.Count == 0)
        {
            return(player.transform.position);
        }
        float      x = 0, y = 0;
        List <int> deletedAgents = new List <int>();

        for (int i = 0; i < ags.Count; i++)
        {
            FriendlyAgent a = ags[i];
            if (a == null)
            {
                deletedAgents.Add(i);
            }
            else
            {
                x += a.gameObject.transform.position.x;
                y += a.gameObject.transform.position.y;
            }
        }
        //add in player weight
        float pWeight = (int)((ags.Count + 1) * (playerGroupWeight * .05f));

        x += player.transform.position.x * pWeight;
        y += player.transform.position.y * pWeight;
        return(new Vector2(x / (ags.Count + 1 + pWeight), y / (ags.Count + 1 + pWeight)));
    }
Ejemplo n.º 2
0
    void OnTriggerStay2D(Collider2D col)
    {
        //Debug.Log("Something should be colliding with this building.");
        FriendlyAgent minion = col.gameObject.GetComponent <FriendlyAgent>();

        //Debug.Log("Minion = " + minion);
        if (minion != null && Time.time - timeOfLastAttack >= stats.secondsPerAttack)
        {
            //Debug.Log("Minion taking damage from building.");
            Shoot();
            minion.TakeDamage(stats.attackDamage);
            timeOfLastAttack = Time.time;
        }
    }
Ejemplo n.º 3
0
    public void registerHordeMember(string hordeGroupName, FriendlyAgent agent)
    {
        List <FriendlyAgent> ags;

        if (agents.ContainsKey(hordeGroupName))
        {
            ags = agents[hordeGroupName];
            ags.Add(agent);
            //don't try to re-add the same key that is already in there ffs
        }
        else
        {
            ags = new List <FriendlyAgent>();
            ags.Add(agent);
            agents.Add(hordeGroupName, ags);
        }
    }
Ejemplo n.º 4
0
 public void registerHordeMember(FriendlyAgent agent)
 {
     registerHordeMember(agent.groupName, agent);
 }