private void OnTriggerEnter(Collider other)
        {
            Collider[] colliders = Physics.OverlapSphere(transform.position, c_Radius, TankLayerMask);
            for (int i = 0; i < colliders.Length; i++)
            {
                Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody>();
                if (!targetRigidbody)
                {
                    continue;
                }

                targetRigidbody.AddExplosionForce(c_Force, transform.position, c_Radius);

                TankControls tankControls = targetRigidbody.GetComponent <TankControls>();
                if (tankControls != null)
                {
                    tankControls.CurrentHealth -= CalculateDamage(targetRigidbody.position);
                }
            }

            ExplosionParticles.transform.parent = null;
            ExplosionParticles.Play();

            ParticleSystem.MainModule mainModule = ExplosionParticles.main;
            Destroy(ExplosionParticles.gameObject, mainModule.duration);

            Destroy(gameObject);
        }
Exemple #2
0
        private void OnTriggerEnter(Collider other)
        {
            TankControls tankControls = other.gameObject.GetComponent <TankControls>();

            if (tankControls != null)
            {
                tankControls.AddModifier(Modifier);

                gameObject.SetActive(false);

                Invoke("Respawn", RespawnTime);
            }
        }
        public void Apply(TankControls tankControls)
        {
            switch (ModifierType)
            {
            case ModifierType.Health:
                tankControls.CurrentHealth += 20f;
                break;

            case ModifierType.Speed:
                tankControls.SpeedModifier             = 10f;
                tankControls.TankRotationSpeedModifier = 30f;
                break;

            case ModifierType.Fire:
                tankControls.ShellVelocityModifier = 40f;
                tankControls.FireCooldownModifier  = 1f;
                break;
            }
            Duration -= Time.deltaTime;
        }
Exemple #4
0
 private void Awake()
 {
     m_TankControls = GetComponent <TankControls>();
     m_TankTurret   = transform.Find("Renderers/Turret").gameObject;
     m_TankBarrel   = transform.Find("Renderers/Turret/Barrel").gameObject;
 }
 private void Awake()
 {
     m_TankControls = GetComponent <TankControls>();
     m_TankBarrel   = transform.Find("Renderers/Turret/Barrel").gameObject;
     m_FiringArc    = transform.Find("Renderers/Turret/Barrel/ShellOriginTransform/FiringArc").GetComponent <LineRenderer>();
 }