Example #1
0
    // Update is called once per frame
    void Update()
    {
        Collider2D[] results = new Collider2D[64];

        int nCollisions = Physics2D.OverlapCollider(damageArea, contactFilter, results);

        if (nCollisions > 0)
        {
            for (int i = 0; i < nCollisions; i++)
            {
                Collider2D otherCollider = results[i];

                HP hp = otherCollider.GetComponent <HP>();

                if (hp)
                {
                    if (gameObject.name == "Heal")
                    {
                        hp.HealDamage();
                    }
                    else
                    {
                        hp.DealDamage(damage);
                    }
                }
            }
        }
    }
Example #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (savepoint == collision.tag)
        {
            HP player = Player.GetComponent <HP>();

            if (player)
            {
                player.HealDamage();
                Player_Management.Instance.position = gameObject.transform.position;

                SaveManagement number = collision.GetComponent <SaveManagement>();
                Player_Management.Instance.save_point = number.save_points_number;

                Shoot weapon = Weapon.GetComponent <Shoot>();

                if (weapon)
                {
                    for (int i = 0; i < weapon.ammo.Length; i++)
                    {
                        Player_Management.Instance.ammo[i] = weapon.ammo[i];
                    }
                    for (int i = 0; i < weapon.weapon.Length; i++)
                    {
                        Player_Management.Instance.weapon[i] = weapon.weapon[i];
                    }
                }
            }
        }
    }