Exemple #1
0
    void FixedUpdate()
    {
        Vector3    velocity        = Rb.velocity;
        float      raycastDistance = velocity.magnitude * Time.fixedDeltaTime; //De esta forma averiguo donde estaría el laser en el siguiente frame
        RaycastHit hitInfo;

        if (Physics.Raycast(transform.position, velocity.normalized, out hitInfo, raycastDistance))
        {
            //LifeManager lifeManager = hitInfo.transform.GetComponentInParent<LifeManager>();
            //if (lifeManager) lifeManager.RemoveLife();
            ShieldManager shieldManager = hitInfo.transform.GetComponentInParent <ShieldManager>();
            if (shieldManager)
            {
                shieldManager.DamageShield(Damage);
            }
            GameObject explosionPrefab = ProjectilePool.GetObjectFromPool("ProjectileExplosion");
            if (explosionPrefab)
            {
                explosionPrefab.transform.position = transform.position;
                ParticleSystem[] ps = explosionPrefab.GetComponentsInChildren <ParticleSystem>();
                for (int i = 0; i < ps.Length; ++i)
                {
                    ps[i].Play();
                }
                StartCoroutine(ReturnParticle(explosionPrefab));
            }
            Return();
        }
    }
Exemple #2
0
    void Return()
    {
        GameObject explosionPrefab = ProjectilePool.GetObjectFromPool("ProjectileExplosion");

        if (explosionPrefab)
        {
            explosionPrefab.transform.position = transform.position;
            ParticleSystem[] ps = explosionPrefab.GetComponentsInChildren <ParticleSystem>();
            for (int i = 0; i < ps.Length; ++i)
            {
                ps[i].Play();
            }
            StartCoroutine(ReturnParticle(explosionPrefab));
        }
        _seek.target = null;
        ProjectilePool.ReturnObjectToPool("Missile", this.gameObject);
    }
    protected override void Shoot()
    {
        if (_bOverHeat)
        {
            return;
        }
        for (int i = 0; i < ShootPoints.Length; ++i)
        {
            if (AudioS)
            {
                AudioS.Play();
            }
            GameObject shootPoint = ShootPoints[i];
            GameObject newLaser   = ProjectilePool.GetObjectFromPool("Laser");

            newLaser.transform.position = shootPoint.transform.position;
            newLaser.transform.forward  = shootPoint.transform.forward;
            newLaser.GetComponent <ProjectileBase>().Damage = Damage;

            if (CompareTag("Enemy"))
            {
                Target = FindObjectOfType <Player>().gameObject;
            }

            if (Target)
            {
                newLaser.transform.LookAt(Target.transform);
            }
            newLaser.GetComponent <Rigidbody>().velocity = newLaser.transform.forward * Speed;

            if (_particles[i])
            {
                _particles[i].Play();
            }
            if (CompareTag("Player"))
            {
                newLaser.GetComponent <LineRenderer>().startColor = Color.blue; newLaser.GetComponent <LineRenderer>().endColor = Color.blue;
            }
            if (CurrentOverHeat < MaxOverHeat)
            {
                CurrentOverHeat++;
            }
            CurrentOverHeat = Mathf.Min(CurrentOverHeat, MaxOverHeat);
        }
    }
    protected override void Shoot()
    {
        if (CurrentAmmo == 0 || !_bShootAble)
        {
            return;
        }
        if (AudioS)
        {
            AudioS.Play();
        }
        for (int i = 0; i < ShootPoints.Length; ++i)
        {
            _shootStart = Time.time;
            GameObject shootPoint = ShootPoints[i];
            GameObject newMissile = ProjectilePool.GetObjectFromPool("Missile");

            newMissile.transform.position = shootPoint.transform.position;
            newMissile.transform.forward  = shootPoint.transform.forward;
            newMissile.GetComponent <ProjectileBase>().Damage = Damage;

            if (CompareTag("Enemy"))
            {
                Target = FindObjectOfType <Player>().gameObject;
            }

            if (Target)
            {
                newMissile.GetComponent <Missile>().SetTarget(Target);
                newMissile.transform.LookAt(Target.transform);
            }

            newMissile.GetComponent <Rigidbody>().velocity = shootPoint.transform.forward * Speed;
            if (CurrentAmmo > 0)
            {
                CurrentAmmo--;
            }
            CurrentAmmo = Mathf.Max(0, CurrentAmmo);

            _bShootAble = false;
        }
    }