Ejemplo n.º 1
0
    public void AddTargetToRecentlyHitList(CombatEvent combatEvent)
    {
        var trackable = combatEvent.Target.GetComponent <Trackable>();

        if (!trackable || !trackable.Health)
        {
            return;
        }

        if (RecentlyHit.TryAdd(trackable, Time.time))
        {
            ChangedRecentlyHitList?.Invoke();
        }
        else
        {
            RecentlyHit[trackable] = Time.time;
        }
    }
Ejemplo n.º 2
0
    private void UpdateRecentlyHitList()
    {
        var toRemove = new List <Trackable>();

        foreach (var pair in RecentlyHit)
        {
            if (Time.time >= pair.Value + ShowHealthOnHitDuration)
            {
                toRemove.Add(pair.Key);
            }
        }

        foreach (var trackable in toRemove)
        {
            RecentlyHit.Remove(trackable);
        }
        if (toRemove.Count > 0)
        {
            ChangedRecentlyHitList?.Invoke();
        }
    }