Ejemplo n.º 1
0
    void Shoot()
    {
        RaycastHit hitInfo;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hitInfo, 1000f))         // this will return true if the ray hits something

        // References of the scripts that the ray could hit
        {
            Enemy        enemyHit        = hitInfo.transform.GetComponent <Enemy>();
            DreamKFly    dreamKillerHit  = hitInfo.transform.GetComponent <DreamKFly>();
            Shot         shotHit         = hitInfo.transform.GetComponent <Shot>();
            PowerCarrier powerCarrierHit = hitInfo.transform.GetComponent <PowerCarrier>();
            FirstBoss    firstBossHit    = hitInfo.transform.GetComponent <FirstBoss>();
            Spawn        spawnHit        = hitInfo.transform.GetComponent <Spawn>();
            SpawnShot    spawnShotHit    = hitInfo.transform.GetComponent <SpawnShot>();

            if (enemyHit != null)
            {
                enemyHit.TakeDamage(damage);
            }
            if (dreamKillerHit != null)
            {
                dreamKillerHit.TakeDamage(damage);
            }
            if (shotHit != null)
            {
                shotHit.TakeDamage(damage);
            }
            if (powerCarrierHit != null)
            {
                powerCarrierHit.TakeDamage();
            }
            if (firstBossHit != null)
            {
                firstBossHit.TakeDamage(damage);
            }
            if (spawnHit != null)
            {
                spawnHit.TakeDamage();
            }
            if (spawnShotHit != null)
            {
                spawnShotHit.TakeDamage();
            }
        }

        //Instantiate(shotGraphics, fpsCam.transform.position, fpsCam.transform.rotation);
        //Instantiate(impactEffect, hitInfo.point, Quaternion.LookRotation(hitInfo.normal));
    }
Ejemplo n.º 2
0
 public void InvokeSpawnShot(Vector3 pos, Quaternion rot)
 {
     SpawnShot.Invoke(pos, rot);
 }