Ejemplo n.º 1
0
    void CheckThreat()
    {
        if (threat_table.Count == 0)
        {
            return;
        }
        Sort();
        ThreatEntry current = FindEntry(current_target);
        ThreatEntry top     = threat_table[0];

        if (top.threat == 0)
        {
            return;
        }
        float distance = Vector3.Distance(transform.position, top.unit.transform.position);

        if (current.unit != top.unit)
        {
            if (distance > MeleeRange && top.threat >= current.threat * 1.3)
            {
                current_target = top.unit;
            }
            else if (distance <= MeleeRange && top.threat >= current.threat * 1.1)
            {
                current_target = top.unit;
            }
        }
    }
Ejemplo n.º 2
0
 void ReplaceEntry(ThreatEntry entry)
 {
     for (int i = 0; i < threat_table.Count; i++)
     {
         if (threat_table[i].unit == entry.unit)
         {
             threat_table[i] = entry;
         }
     }
 }
Ejemplo n.º 3
0
    public void AddNewThreat(Creature newThreat, uint amount = 0)
    {
        var entry = new ThreatEntry(newThreat.Guid)
        {
            Threat = amount
        };

        ThreatTableByCreature.Add(newThreat.Guid, entry);
        ThreatTableByThreat.Add(entry, newThreat.Guid);
    }
Ejemplo n.º 4
0
 void CheckTarget()
 {
     if (current_target == null)
     {
         return;
     }
     if (current_target.hp == 0)
     {
         ThreatEntry temp = FindEntry(current_target);
         temp.threat = 0;
         ReplaceEntry(temp);
         CheckThreat();
     }
 }
Ejemplo n.º 5
0
    void Taunt(Unit unit)
    {
        ThreatEntry entry = FindEntry(unit);

        if (entry.unit == null)
        {
            return;
        }

        ThreatEntry top = threat_table[0];

        entry.threat = top.threat * 1.3f;

        CheckThreat();
    }
Ejemplo n.º 6
0
    public void AddThreat(Unit unit, float threat)
    {
        ThreatEntry entry = FindEntry(unit);

        if (entry.unit == null)
        {
            Debug.Log("No entry for unit");
            return;
        }

        entry.threat += threat;
        ReplaceEntry(entry);


        CheckThreat();
    }
Ejemplo n.º 7
0
    int CompareThreatEntry(ThreatEntry x, ThreatEntry y)
    {
        if (x.threat == y.threat)
        {
            return(0);
        }

        else if (x.threat < y.threat)
        {
            return(1);
        }

        else
        {
            return(-1);
        }
    }