示例#1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (canDmg)
        {
            canDmg = false;
            IDamageable dmg = collision.collider.GetComponent <IDamageable>();
            if (dmg != null)
            {
                //print("damn");
                dmg.Daniar(5);
            }
            else
            {
                foreach (var c in FindObjectsOfType <IA_Enemigo>())
                {
                    c.IniciarInvestigacion(transform.position);
                    StopAllCoroutines();
                }
            }
        }
        gameObject.SetActive(false);
        GameObject part = pool.SpawnFromPool("bulletparticles", transform.position, Quaternion.identity);

        part.GetComponent <ParticleSystem>().Play();
    }
示例#2
0
 private void LanzarGranada()
 {
     if (puedelanzar && nGran > 0)
     {
         puedelanzar = false;
         nGran--;
         grenadeText.text = nGran.ToString();
         GameObject bala       = pool.SpawnFromPool("Grenade", shootPoint.position, Quaternion.identity);
         Rigidbody  bulletbody = bala.GetComponent <Rigidbody>();
         bulletbody.velocity = Vector3.zero;
         bulletbody.AddForce(shootPoint.forward * shootForce * 0.5f, ForceMode.Impulse);
         updateAmmoCount();
         StartCoroutine(launchTimer(1.5f));
     }
 }
示例#3
0
 // Update is called once per frame
 void Update()
 {
     if (Spawncounter < SpawnLimit)
     {
         SpawnTimer += Time.deltaTime;
         if (SpawnTimer > SpawnJumps)
         {
             Transform point = SpawnPoints[Random.Range(0, SpawnPoints.Length)];
             Enemy     enemy = pool.SpawnFromPool(enemytag, point.position, point.rotation, false).GetComponent <Enemy>();
             enemy.OnObjectSpawn();
             Spawncounter++;
             SpawnTimer = 0;
         }
     }
 }
    void Disparar(int _estado)
    {
        if (puedeDisparar)
        {
            puedeDisparar = false;
            GameObject bala       = pool.SpawnFromPool("Bullet", shootPoint.position, Quaternion.identity);
            Rigidbody  bulletbody = bala.GetComponent <Rigidbody>();
            bulletbody.velocity = Vector3.zero;
            float   randomAmount = _estado == 0 ? UnityEngine.Random.Range(-angleShoot.x, angleShoot.x) : UnityEngine.Random.Range(-angleShoot.y, angleShoot.y);
            Vector3 shootDir     = Quaternion.Euler(0, randomAmount, 0) * shootPoint.forward;

            bulletbody.AddForce(shootDir * 5, ForceMode.Impulse);

            StartCoroutine(shootTimer());
        }
    }
示例#5
0
    IEnumerator lifetimeRoutine()
    {
        yield return(new WaitForSeconds(lifeTime));

        Collider[] explodables = Physics.OverlapSphere(transform.position, 5, explodable);
        foreach (var item in explodables)
        {
            item.GetComponent <IDamageable>().Daniar(30);
            Rigidbody rb = item.GetComponent <Rigidbody>();
            if (rb != null)
            {
                rb.AddForce((item.transform.position - transform.position).normalized * 10.0f + Vector3.up * 5.0f);
            }
        }
        SoundFX.miSFX.PlaySFX(3);
        GameObject part = pool.SpawnFromPool("grenadeparticles", transform.position, Quaternion.identity);

        part.GetComponent <ParticleSystem>().Play();
        gameObject.SetActive(false);
    }
示例#6
0
 void Shoot()
 {
     pool.SpawnFromPool("Bullet", gunpoint.position, transform.rotation, false);
 }