Example #1
0
    void SetPhysicalProperties(GameObject bullet)
    {
        PhysicalProjectile physicalProjectile = bullet.GetComponent <PhysicalProjectile>();

        physicalProjectile.SetVelocityMagnitude(projectileData.velocityMagnitude);
        physicalProjectile.SetLifeSpan(projectileData.lifeSpan);
    }
    void OnTriggerStay2D(Collider2D other)
    {
        //Ignore owner
        if (other.gameObject == owner.gameObject)
        {
            return;
        }

        if (other.CompareTag("Player"))
        {
            if (!damagedPlayers.Contains(other.gameObject))
            {
                other.GetComponentInParent <PlayerData>().TakeDamage(damage, owner.GetPlayerMovement().GetPlayerAngle(), knockbackPower, owner);
                damagedPlayers.Add(other.gameObject);
            }
        }

        else if (canReflect && other.CompareTag("Bullet"))
        {
            if (!damagedPlayers.Contains(other.gameObject))
            {
                PhysicalProjectile bullet = other.GetComponent <PhysicalProjectile>();
                if (bullet.GetOwner() == owner)
                {
                    return;
                }

                bullet.ReflectBullet(owner, reflectSpeedAmp, reflectDamageAmp);
                damagedPlayers.Add(other.gameObject);
            }
        }
    }