Exemplo n.º 1
0
        public override void ProjectileOnImpact(ProjectileBehaviour projectileBehaviour, Collider other)
        {
            if (!activeLayers.HasLayer(other.gameObject.layer))
            {
                return;
            }

            PlayerHandler otherPlayer;
            Rigidbody     otherRigidBody;

            otherRigidBody = other.GetComponent <Rigidbody>();
            if (otherRigidBody)
            {
                otherRigidBody.AddForce(projectileBehaviour.gameObject.transform.forward * explosionForce);
            }

            otherPlayer = other.GetComponent <PlayerHandler>();
            if (otherPlayer)
            {
                if (otherPlayer.GetPlayerNumber() != playerNumber)
                {
                    otherPlayer.TakeDamage(Random.Range(minDamage, maxDamage));
                }
            }

            ParticleSystem particle = Instantiate(explosionEffect, projectileBehaviour.gameObject.transform);

            particle.gameObject.transform.parent = null;
            particle.Play();
            Destroy(particle.gameObject, particle.main.duration);

            RemoveProjectile();
        }
Exemplo n.º 2
0
        public override void SetupProjectile(int playerNumber, float playerVelocity, Transform fireTransform, ProjectileModificators projectileModificators = null)
        {
            base.SetupProjectile(playerNumber, playerVelocity, fireTransform, projectileModificators);

            if (projectileInstance != null)
            {
                Vector3 projectileVelocity;
                if (playerVelocity > 0)
                {
                    projectileVelocity = (startingSpeed + playerVelocity) * fireTransform.forward;
                }
                else
                {
                    projectileVelocity = startingSpeed * fireTransform.forward;
                }
                ProjectileBehaviour projectileBehaviour = projectileInstance.GetComponent <ProjectileBehaviour>();

                projectileBehaviour.SetupProjectileBehaviour(this, projectileVelocity, ProjectileCallback.PROJECTILE_CALLBACK_ON_IMPACT);
            }
        }
Exemplo n.º 3
0
        public override void ProjectileOnImpact(ProjectileBehaviour projectileBehaviour, Collider other)
        {
            if (!activeLayers.HasLayer(other.gameObject.layer))
            {
                return;
            }

            Collider[]    colliders = Physics.OverlapSphere(projectileBehaviour.transform.position, explosionRadius, activeLayers);
            PlayerHandler otherPlayer;
            Rigidbody     otherRigidBody;

            for (int i = 0; i < colliders.Length; i++)
            {
                otherRigidBody = null;
                otherPlayer    = null;

                otherRigidBody = other.GetComponent <Rigidbody>();
                if (otherRigidBody)
                {
                    otherRigidBody.AddExplosionForce(explosionForce, projectileBehaviour.gameObject.transform.position, explosionRadius);
                }

                otherPlayer = other.GetComponent <PlayerHandler>();
                if (otherPlayer)
                {
                    if (otherPlayer.GetPlayerNumber() != playerNumber)
                    {
                        otherPlayer.TakeDamage(CalculateDamage(projectileBehaviour.gameObject.transform.position, colliders[i].gameObject.transform.position));
                    }
                }
            }
            ParticleSystem particle = Instantiate(explosionEffect, projectileBehaviour.gameObject.transform);

            particle.gameObject.transform.parent = null;
            particle.Play();
            Destroy(particle.gameObject, particle.main.duration);

            RemoveProjectile();
        }