void OnTriggerEnter2D(Collider2D coll)
    {
        DamageableMono damageable = coll.gameObject.GetComponent <DamageableMono>();

        if (damageable && damageable.damSO.faction != myFaction)
        {
            damageable.damSO.AddAmountToHealth(-1);
        }
    }
    void OnCollisionEnter2D(Collision2D collider)
    {
        DamageableMono damageable = collider.gameObject.GetComponent <DamageableMono>();

        if (damageable && damageable.damSO.faction != DamagerSO.faction)
        {
            LastHitDamageable = damageable;
            Attack();
        }
    }
    void OnTriggerExit2D(Collider2D collider)
    {
        DamageableMono damageable = collider.GetComponent <DamageableMono>();

        if (damageable)
        {
            if (DamageablesInRange.Contains(damageable))
            {
                DamageablesInRange.Remove(damageable);
            }
        }
    }
Example #4
0
 public void RegisterDamageable(DamageableMono damageable, FactionSO faction)
 {
     if (!Damageables.Contains(damageable))
     {
         Damageables.Add(damageable);
         Factions.Add(faction);
     }
     else
     {
         Debug.LogError("damageable " + damageable.name + " already exists in set.");
     }
 }
Example #5
0
    void OnTriggerExit2D(Collider2D collider)
    {
        DamageableMono dam = collider.GetComponent <DamageableMono>();

        if (dam)
        {
            if (TargetTrans == dam.transform)
            {
                TargetTrans = null;
            }
        }
    }
Example #6
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        DamageableMono dam = collider.GetComponent <DamageableMono>();

        if (dam)
        {
            if (dam.damSO.faction != bulletMono.damagerSO.faction)
            {
                TargetTrans = dam.transform;
            }
        }
    }
Example #7
0
 public void UnregisterDamageable(DamageableMono damageable, FactionSO faction)
 {
     if (Damageables.Contains(damageable))
     {
         int i = Damageables.IndexOf(damageable);
         Damageables.Remove(damageable);
         Factions.RemoveAt(i);
     }
     else
     {
         Debug.LogError("damageable " + damageable.name + " does not exist in set.");
     }
 }
Example #8
0
    private void Awake()
    {
        if (SR == null)
        {
            Debug.Log("Yo where's my sprite renderer");
        }
        DamageableMono = GetComponent <DamageableMono>();
        FatCatAnimator = GetComponentInChildren <Animator>();
        RangedWeaponMono.onShootEvent   += OnShoot;
        DamageableMono.onDeathMonoEvent += OnSubdued;

        InitialScale  = SR.transform.localScale;
        ExpandedScale = new Vector3(InitialScale.x * 1.3f, InitialScale.y * 1.3f, 1f);
    }
Example #9
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        DamageableMono dam = collision.gameObject.GetComponent <DamageableMono>();

        if (dam)
        {
            if (dam.damSO.faction != DamagerSO.faction)
            {
                dam.damSO.AddAmountToHealth(-DamagerSO.damage);
                Attack();
            }
        }
        gameObject.SetActive(false);
    }
    void OnTriggerEnter2D(Collider2D collider)
    {
        DamageableMono damageable = collider.GetComponent <DamageableMono>();

        if (damageable != null)
        {
            if (damageable.damSO.faction != this.DamagerSO.faction)
            {
                if (!DamageablesInRange.Contains(damageable))
                {
                    DamageablesInRange.Add(damageable);
                }
                else
                {
                    Debug.LogError("Attempted to add damageable " + damageable.gameObject.name
                                   + " to damageable list, but it already exists.");
                }
            }
        }
    }
Example #11
0
 void Start()
 {
     DamageableMono = GetComponent <DamageableMono>();
     DamageableMono.onDamageMonoEvent += OnDamaged;
     DamageableMono.onDeathMonoEvent  += OnDeath;
 }