示例#1
0
    public void attack()
    {
        //broń palna
        if (gun == true)
        {
            Bullet  bl = bullet.GetComponent <Bullet>();
            Vector3 bulletDir;
            bulletDir.x = Vector2.right.x;
            bulletDir.y = Vector2.right.y;
            bulletDir.z = 0;
            bl.setVals(bulletDir, "player");;
            Instantiate(bullet, bulletSpawnPoint.transform.position, bulletSpawnPoint.rotation);
            timer = timerReset;
        }
        //meele
        else
        {
            RaycastHit2D ray = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.up.x * 100, transform.up.y * 100));
            Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.up.x * 100, transform.up.y * 100), Color.green);

            if (ray.collider != null)
            {
                if (ray.collider.gameObject.tag == "enemy")
                {
                    EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked>();
                    ea.killMeele();
                }
            }

            /*if(curWeapon == null && ray.collider.gameObject.tag == "enemy")
             * {
             *
             * }*/
        }
    }
示例#2
0
    void OnCollisionEnter2D(Collision2D col)
    {
        Debug.Log(creator + "-" + col.gameObject.tag);
        if (col.gameObject.tag == "Enemy")
        {
            attacked = col.gameObject.GetComponent <EnemyAttacked>();
            attacked.killBullet();

            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
        //		else if(col.gameObject.tag != "Bullet")
        //        {
        //            Instantiate(wallImpact, this.transform.position, this.transform.rotation);
        //            Destroy(this.gameObject);
        //        }
        else if (col.gameObject.tag == "Enemy" && creator == "Enemy")
        {
        }
        else if (col.gameObject.tag == "Player")
        {
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            PlayerHealth.dead = true;
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag != "Enemy" && col.gameObject.tag != "Player" && col.gameObject.tag != "Bullet") //add "col.gameObject.tag != "Bullet"". Because when player and enemy shot, bullets can destroy each other
        {
            Instantiate(wallImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
    }
 void OnTriggerEnter2D(Collider2D other)
 {
     if (Vector3.Distance(player.transform.position, this.gameObject.transform.position) < 1.1f && other.gameObject.tag == "Enemy")
     {
         EnemyAttacked ea = other.gameObject.GetComponent <EnemyAttacked> ();
         ea.knockDownEnemy();
     }
 }
示例#4
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Enemy")
     {
         if (Vector3.Distance(player.transform.position, this.transform.position) < 1.0)
         {
             EnemyAttacked ea = coll.gameObject.GetComponent <EnemyAttacked> ();
             // ea.knockDownEnemy ();
         }
     }
 }
示例#5
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "enemy")
     {
         ea = coll.gameObject.GetComponent <EnemyAttacked>();
         ea.killBullet();
         Destroy(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
示例#6
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            attacked = col.gameObject.GetComponent <EnemyAttacked> ();
            attacked.knockDownEnemy();
            int level;
            if (sceneName == "Tutorial")
            {
                level = 0;
            }
            else
            {
                level = Utils.LevelFromSceneName(sceneName);
            }

            Debug.Log("nivel de Noquear: " + level);
            Debug.Log("Enemigo de Noquear con arma: " + attacked.nombreEnemigo);
            Debug.Log("tiempo de Noquear: " + Time.timeSinceLevelLoad);
            Debug.Log("Insertar evento de noquear");

            /* PROBLEMA EN EL COLLIDER PORQUE LO TOMA MAS DE UNA VEZ
             * Analytics.CustomEvent("Noquear", new Dictionary<string, object>
             * {   { "nivel", level },
             *  { "enemigo", attacked.nombreEnemigo },
             *  { "tiempo", Time.timeSinceLevelLoad }
             * }
             * );
             */
            rid.isKinematic = true;
            Destroy(this);
        }
        else if (col.gameObject.tag == "Player")
        {
        }
        else if (col.gameObject.tag == "Dog")
        {
            col.gameObject.GetComponent <DogHealth> ().killDog();
        }
        else if (col.gameObject.tag == "Wall")
        {
            rid.velocity = new Vector3(0, 0, 0);
        }
        else
        {
            rid.isKinematic = true;
            Destroy(this);
        }
    }
    public void attack()
    {
        pa.attack();
        if (gun == true)
        {
            //Bullet bl = bullet.GetComponent<Bullet> ();//creation of bullet with own direction set
            Vector3 dir;
            dir.x = Vector2.right.x;             //rotation of bullet
            dir.y = Vector2.right.y;
            dir.z = 0;
            bl.setVals(dir, "Player");              //knows who created the bullet
            if (oneHanded == true)
            {
                Instantiate(bl, oneHandSpawn.transform.position, this.transform.rotation);
            }
            else
            {
                Instantiate(bl, twoHandSpawn.transform.position, this.transform.rotation);
            }
            this.GetComponent <AudioController> ().fireSmg();

            timer = timerReset;
        }
        else
        {
            //melee attack
            int layerMask = 1 << 9;
            layerMask = ~layerMask;
            pa.attack();
            RaycastHit2D ray = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), 1.5f, layerMask); //create a line from the player wich can hit an enemy
            Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), Color.green);
            if (curWeapon == null && ray.collider.gameObject.tag == "Enemy")                                                                                                             // if player doesn't hold any weapon and the player sight line (ray) hits enemy,
            {
                EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked> ();
                ea.knockDownEnemy();
                this.GetComponent <AudioController> ().meleeAttack();
            }
            else if (ray.collider != null)
            {
                if (ray.collider.gameObject.tag == "Enemy")                   //if player have meelee weapon -> instant kill
                {
                    EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked> ();
                    ea.killMelee();
                    this.GetComponent <AudioController> ().meleeAttack();
                }
            }
        }
    }
示例#8
0
    public void attack()
    {
        pa.Attack();
        if (gun == true && curWepScr.ammo > 0)
        {
            pa.Attack();
            Bullet  bul        = bullet.GetComponent <Bullet>();
            Bullet  shotGunBul = bullet.GetComponent <Bullet>();
            Vector3 direction;
            direction.x = Vector2.right.x;
            direction.y = Vector2.right.y;
            direction.z = 0;

            bul.SetValues(direction, "Player");

            if (oneHanded)
            {
                Instantiate(bullet, oneHandSpawn.transform.position, this.transform.rotation);
                curWeapon.GetComponent <WeaponPickUp>().ammo--;
            }
            else
            {
                Instantiate(shotgunBullet, twoHandSpawn.transform.position, this.transform.rotation);
                curWeapon.GetComponent <WeaponPickUp>().ammo--;
            }
            timer = timerReset;
        }
        else
        {
            int layerMask = 1 << 9;
            layerMask = ~layerMask;
            pa.Attack();
            RaycastHit2D rayCast = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), layerMask);

            Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), Color.green);


            if (curWeapon == null && rayCast.collider.gameObject.tag == "Enemy")
            {
                Debug.Log("hit");
                EnemyAttacked enemyAttacked = rayCast.collider.gameObject.GetComponent <EnemyAttacked>();
                enemyAttacked.KnockDownEnemy();
            }
            timer = timerReset;
        }
    }
示例#9
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         attacked = col.gameObject.GetComponent <EnemyAttacked>();
         attacked.knockDownEnemy();
         rid.isKinematic = true;
         Destroy(this);
     }
     else if (col.gameObject.tag == "Player")
     {
     }
     else
     {
         rid.isKinematic = true;
         Destroy(this);
     }
 }
示例#10
0
文件: Bullet.cs 项目: romanvoyt/game
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Enemy")
     {
         attacked = collision.gameObject.GetComponent <EnemyAttacked>();
         collision.gameObject.tag = "Dead";
         attacked.KillBullet();
         Destroy(this.gameObject);
     }
     else if (collision.gameObject.tag == "Player")
     {
         PlayerHealth.dead = true;
         Destroy(this.gameObject);
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
示例#11
0
    void OnCollisionEnter2D(Collision2D col)     //if it hits gameobject it will get enemyattacked script  ant then killed them by the bullet
    {
        if (col.gameObject.tag == "Enemy")
        {
            attacked = col.gameObject.GetComponent <EnemyAttacked> ();
            attacked.killBullet();
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);              //create blood sprite and destroy the bullet
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag == "Player")
        {
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            PlayerHealth.dead = true;            //new for 10
            Destroy(this.gameObject);
        }

        else
        {
            Instantiate(wallImpact, this.transform.position, this.transform.rotation);              //if it hit not the enemy  it will just create wall impact
            Destroy(this.gameObject);
        }
    }
示例#12
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         attacked = col.gameObject.GetComponent <EnemyAttacked> ();
         attacked.killBullet();
         Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
         Destroy(this.gameObject);
     }
     else if (col.gameObject.tag == "Enemy" && creator == "Enemy")
     {
     }
     else if (col.gameObject.tag == "Heavy")
     {
         ha = col.gameObject.GetComponent <HeavyAttacked> ();
         ha.hitByBullet();
         Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
         Destroy(this.gameObject);
     }
     else if (col.gameObject.tag == "Player")
     {
         Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
         PlayerHealth.dead = true;            //new for 10
         Destroy(this.gameObject);
     }
     else if (col.gameObject.tag != "Enemy" && col.gameObject.tag != "Player" && col.gameObject.tag != "Dog" && col.gameObject.tag != "Heavy")
     {
         //Debug.Log ("hit");
         Instantiate(wallImpact, this.transform.position, this.transform.rotation);
         Destroy(this.gameObject);
     }
     else if (col.gameObject.tag == "Dog")
     {
         Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
         col.gameObject.GetComponent <DogHealth> ().killDog();
     }
 }
示例#13
0
    public void attack()
    {
        int layerMask = 1 << 9;

        layerMask = ~layerMask;
        pa.attack();
        RaycastHit2D ray = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.up.x, transform.up.y), 1.5f, layerMask);

        Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.up.x, transform.up.y));
        if (curWeapon == null && ray.collider.gameObject.tag == "Enemy")
        {
            EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked>();
            ea.knockDownEnemy();
        }
        else if (ray.collider != null)
        {
            Debug.Log(ray.collider.gameObject.tag);
            if (ray.collider.gameObject.tag == "Enemy")
            {
                EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked>();
                ea.killMelee();
            }
        }
    }
示例#14
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            attacked = col.gameObject.GetComponent <EnemyAttacked> ();
            attacked.knockDownEnemy();
            int level;
            if (sceneName == "Tutorial")
            {
                level = 0;
            }
            else
            {
                level = Utils.LevelFromSceneName(sceneName);
            }

            if (GameManager.ultimoEnemigoNoqueadoConArma != attacked.nombreEnemigo)
            {
                Debug.Log("nivel de Noquear: " + level);
                Debug.Log("Nombre de enemigo noqueado: " + attacked.nombreEnemigo);
                Debug.Log("tiempo de Noquear: " + Time.timeSinceLevelLoad);
                WeaponPickup weapon = this.GetComponent <WeaponPickup>();
                Debug.Log("arma de Noquear: " + weapon.name);
                Debug.Log("Insertar evento de noquear arrojando arma");


                switch (weapon.name)
                {
                case "Bowie":
                    GameManager.noquearBowie += 1;
                    break;

                case "Colt":
                    GameManager.noquearColt += 1;
                    break;

                case "Mac10":
                    GameManager.noquearMac10 += 1;
                    break;

                case "Bat":
                    GameManager.noquearBat += 1;
                    break;

                case "Thompson":
                    GameManager.noquearThompson += 1;
                    break;

                case "SawnOff":
                    GameManager.noquearSawnOff += 1;
                    break;

                case "Winchester":
                    GameManager.noquearWinchester += 1;
                    break;

                case "Matute":
                    GameManager.noquearMatute += 1;
                    break;

                default:
                    break;
                }

                Analytics.CustomEvent("Noquear", new Dictionary <string, object>
                {
                    { "nivel", level },
                    { "enemigo", attacked.nombreEnemigo },
                    { "tiempo", Time.timeSinceLevelLoad }
                }
                                      );
                GameManager.ultimoEnemigoNoqueadoConArma = attacked.nombreEnemigo;
            }
            rid.isKinematic = true;
            Destroy(this);
        }
        else if (col.gameObject.tag == "Player")
        {
        }
        else if (col.gameObject.tag == "Dog")
        {
            col.gameObject.GetComponent <DogHealth> ().killDog();
        }
        else if (col.gameObject.tag == "Wall")
        {
            rid.velocity = new Vector3(0, 0, 0);
        }
        else
        {
            rid.isKinematic = true;
            Destroy(this);
        }
    }
示例#15
0
    public void attack()
    {
        if (gun == true && curWepScr.ammo > 0)
        {
            //NEW STUFF FOR 16
            pa.attack();
            Vector3 dir;
            dir.x = Vector2.right.x;
            dir.y = Vector2.right.y;
            dir.z = 0;


            if (oneHanded == true)
            {
                if (Shotgun == false)
                {    //new for new weapons
                    Bullet bl = Instantiate(bullet, oneHandSpawn.transform.position, this.transform.rotation).GetComponent <Bullet>();
                    bl.arma = curWepScr.name;
                    ContarMuertos.armaPlayer = bl.arma;     //Pasa el arma para el evento Matar
                    Debug.Log("El arma del player es: " + bl.arma);
                }

                else
                {
                    //Instantiate (shotgunBullet, oneHandSpawn.transform.position, this.transform.rotation); Linea comentada para prueba
                    //Comienzo prueba
                    GameObject go      = Instantiate(shotgunBullet, oneHandSpawn.transform.position, this.transform.rotation);
                    Bullet[]   bullets = go.GetComponentsInChildren <Bullet>();

                    foreach (Bullet b in bullets)
                    {
                        b.arma = curWepScr.name; // o el arma que sea
                        Debug.Log("El arma del player es: " + b.arma);
                        ContarMuertos.armaPlayer = b.arma;
                    }
                    //Finaliza prueba
                }

                curWeapon.GetComponent <WeaponPickup> ().ammo--;
                //FindObjectOfType<LevelEscapeController> ().shotFired (); Comentado para que se pueda disparar
            }
            else
            {
                if (Shotgun == false)
                {
                    //new for new weapons
                    Bullet bl = Instantiate(bullet, twoHandSpawn.transform.position, this.transform.rotation).GetComponent <Bullet>();
                    bl.arma = curWepScr.name;
                    Debug.Log("El arma del player es: " + bl.arma);
                }
                else
                {
                    //Instantiate (shotgunBullet, twoHandSpawn.transform.position, this.transform.rotation);
                    //Comienzo prueba
                    GameObject go      = Instantiate(shotgunBullet, oneHandSpawn.transform.position, this.transform.rotation);
                    Bullet[]   bullets = go.GetComponentsInChildren <Bullet>();

                    foreach (Bullet b in bullets)
                    {
                        b.arma = curWepScr.name;     // o el arma que sea
                        Debug.Log("El arma del player es: " + b.arma);
                        ContarMuertos.armaPlayer = b.arma;
                    }
                    //Finaliza prueba
                }
                curWeapon.GetComponent <WeaponPickup> ().ammo--;
                FindObjectOfType <LevelEscapeController> ().shotFired();
            }
            decideSFX();
            timer = timerReset;

            //if (Input.GetMouseButtonUp (0)) {
            //pa.resetCounter ();
            //}
        }

        else if (gun == true && curWepScr.ammo == 0)
        {
            //NEW STUFF FOR 16
        }
        else
        {
            pa.attack();             //NEW STUFF FOR 16
            //melee attack
            int layerMask = 1 << 9;
            layerMask = ~layerMask;
            pa.attack();
            RaycastHit2D ray = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), 1.5f, layerMask);
            Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), Color.green);

            if (ray.collider == null)
            {
            }

            else
            {
                if (curWeapon == null && ray.collider.gameObject.tag == "Enemy")
                {
                    if (ray.collider.isTrigger == true && ray.collider.gameObject.tag == "Enemy")
                    {
                        //new for execute
                        ray.collider.gameObject.GetComponent <EnemyAttacked> ().execute();
                        if (curWepScr == null)
                        {
                            ContarMuertos.armaPlayer = "sin arma";
                            Debug.Log("Enemigo murio " + ContarMuertos.armaPlayer);
                        }
                        else if (curWepScr != null)
                        {
                            ContarMuertos.armaPlayer = curWepScr.name;
                            Debug.Log("Enemigo murio con arma: " + ContarMuertos.armaPlayer);
                        }


                        decideSFX();
                    }
                    else
                    {
                        EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked> ();
                        ea.knockDownEnemy();

                        int level;
                        if (sceneName == "Tutorial")
                        {
                            level = 0;
                        }
                        else
                        {
                            level = Utils.LevelFromSceneName(sceneName);
                        }

                        Debug.Log("nivel de Noquear: " + level);
                        Debug.Log("Enemigo de Noquear sin arma: " + ea.nombreEnemigo);
                        Debug.Log("tiempo de Noquear: " + Time.timeSinceLevelLoad);
                        Debug.Log("Insertar evento de noquear");

                        Analytics.CustomEvent("Noquear", new Dictionary <string, object>
                        {
                            { "nivel", level },
                            { "enemigo", ea.nombreEnemigo },
                            { "tiempo", Time.timeSinceLevelLoad }
                        }
                                              );

                        decideSFX();
                    }
                }

                else if (curWeapon == null && ray.collider.gameObject.tag == "Dog")
                {                                                                  ////
                    ray.collider.gameObject.GetComponent <DogHealth> ().killDog(); //
                }                                                                  //
                else if (curWeapon == null && ray.collider.gameObject.tag == "Wall" && ray.collider.gameObject.GetComponent <Window> () != null)
                {
                    ray.collider.gameObject.GetComponent <Window> ().breakWindow();
                }
                else if (ray.collider != null)
                {
                    //Debug.Log (ray.collider.gameObject.tag);
                    if (ray.collider.gameObject.tag == "Enemy")
                    {
                        if (ray.collider.isTrigger == true && ray.collider.gameObject.tag == "Enemy")
                        {
                            ray.collider.gameObject.GetComponent <EnemyAttacked> ().execute();
                            if (curWepScr == null)
                            {
                                ContarMuertos.armaPlayer = "sin arma";
                                Debug.Log("Enemigo murio " + ContarMuertos.armaPlayer);
                            }
                            else if (curWepScr != null)
                            {
                                ContarMuertos.armaPlayer = curWepScr.name;
                                Debug.Log("Enemigo murio con arma: " + ContarMuertos.armaPlayer);
                            }
                        }

                        else
                        {
                            EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked> ();
                            ea.killMelee();
                            if (curWepScr == null)
                            {
                                ContarMuertos.armaPlayer = "sin arma";
                                Debug.Log("Enemigo murio " + ContarMuertos.armaPlayer);
                            }
                            else if (curWepScr != null)
                            {
                                ContarMuertos.armaPlayer = curWepScr.name;
                                Debug.Log("Enemigo murio con arma: " + ContarMuertos.armaPlayer);
                            }
                            decideSFX();
                        }
                    }
                    else if (ray.collider.gameObject.tag == "Dog")
                    {
                        ray.collider.gameObject.GetComponent <DogHealth> ().killDog();
                    }

                    if (ray.collider.gameObject.tag == "Wall" && ray.collider.gameObject.GetComponent <Window> () != null)
                    {
                        ray.collider.gameObject.GetComponent <Window> ().breakWindow();
                    }
                }
            }
            timer = timerReset;
        }
    }
 private void OnEnemyAttacked(AttackEventArgs e)
 {
     EnemyAttacked?.Invoke(this, e);
 }
示例#17
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            attacked = col.gameObject.GetComponent <EnemyAttacked> ();
            //attacked.killBullet (); // Llama a la funcion para matar con arma

            // EL SIGUIENTE CODIGO ES PARA QUE MIRTHA TENGA MAS VIDA

            if (GameManager.lifeBoss > 0 && col.gameObject.name == "Mirtha")
            {
                GameManager.lifeBoss -= 1;
            }
            else
            {
                attacked.killBullet(this);
            }

            // AQUI TERMINA EL CODIGO PARA MIRTHA

            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag == "Enemy" && creator == "Enemy")
        {
        }
        else if (col.gameObject.tag == "Heavy")
        {
            ha = col.gameObject.GetComponent <HeavyAttacked> ();
            ha.hitByBullet();
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag == "Player")
        {
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            Debug.Log("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* Bullet");

            if (!PlayerHealth.dead)
            {
                PlayerHealth.dead = true;//new for 10
                //Debug.Log("me mato con el arma " + arma);
                int level;
                if (sceneName == "Tutorial")
                {
                    level = 0;
                }
                else
                {
                    level = Utils.LevelFromSceneName(sceneName);
                }
                Debug.Log("nivel de Morir: " + level);
                Debug.Log("enemigo de Morir: " + asesino);
                Debug.Log("tiempo de Morir: " + Time.timeSinceLevelLoad);
                Debug.Log("coordenada X de Morir: " + col.gameObject.transform.position.x);
                Debug.Log("coordenada Y de Morir: " + col.gameObject.transform.position.y);
                Debug.Log("arma de Morir: " + arma);
                Debug.Log("Insertar evento de morir");

                Analytics.CustomEvent("Morir", new Dictionary <string, object>
                {
                    { "nivel", level },
                    { "enemigo", asesino },
                    { "tiempo", Time.timeSinceLevelLoad },
                    { "CordenadasX", col.gameObject.transform.position.x },
                    { "CordenadasY", col.gameObject.transform.position.y },
                    { "Arma", arma }
                }
                                      );

                // Morir
            }

            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag != "Enemy" && col.gameObject.tag != "Player" && col.gameObject.tag != "Dog" && col.gameObject.tag != "Heavy")
        {
            //Debug.Log ("hit");
            Instantiate(wallImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag == "Dog")
        {
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            col.gameObject.GetComponent <DogHealth> ().killDog();
        }
    }
    public void attack()
    {
        if (gun == true && curWepScr.ammo > 0)          //NEW STUFF FOR 16
        {
            pa.attack();
            Bullet  bl = bullet.GetComponent <Bullet> ();
            Vector3 dir;
            dir.x = Vector2.right.x;
            dir.y = Vector2.right.y;
            dir.z = 0;
            bl.setVals(dir, "Player");

            if (oneHanded == true)
            {
                if (Shotgun == false)                          //new for new weapons
                {
                    Instantiate(bullet, oneHandSpawn.transform.position, this.transform.rotation);
                }
                else
                {
                    Instantiate(shotgunBullet, oneHandSpawn.transform.position, this.transform.rotation);
                }
                curWeapon.GetComponent <WeaponPickup> ().ammo--;
                FindObjectOfType <LevelEscapeController> ().shotFired();
            }
            else
            {
                if (Shotgun == false)                          //new for new weapons
                {
                    Instantiate(bullet, twoHandSpawn.transform.position, this.transform.rotation);
                }
                else
                {
                    Instantiate(shotgunBullet, twoHandSpawn.transform.position, this.transform.rotation);
                }
                curWeapon.GetComponent <WeaponPickup> ().ammo--;
                FindObjectOfType <LevelEscapeController> ().shotFired();
            }
            decideSFX();
            timer = timerReset;

            //if (Input.GetMouseButtonUp (0)) {
            //pa.resetCounter ();
            //}
        }
        else if (gun == true && curWepScr.ammo == 0)
        {
            //NEW STUFF FOR 16
        }
        else
        {
            pa.attack();             //NEW STUFF FOR 16
            //melee attack
            int layerMask = 1 << 9;
            layerMask = ~layerMask;
            pa.attack();
            RaycastHit2D ray = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), 1.5f, layerMask);
            Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), Color.green);

            if (ray.collider == null)
            {
            }
            else
            {
                if (curWeapon == null && ray.collider.gameObject.tag == "Enemy")
                {
                    if (ray.collider.isTrigger == true && ray.collider.gameObject.tag == "Enemy")                      //new for execute
                    {
                        ray.collider.gameObject.GetComponent <EnemyAttacked> ().execute();
                        decideSFX();
                    }
                    else
                    {
                        EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked> ();
                        ea.knockDownEnemy();
                        decideSFX();
                    }
                }
                else if (curWeapon == null && ray.collider.gameObject.tag == "Dog") ////
                {
                    ray.collider.gameObject.GetComponent <DogHealth> ().killDog();  //
                }                                                                   //
                else if (curWeapon == null && ray.collider.gameObject.tag == "Wall" && ray.collider.gameObject.GetComponent <Window> () != null)
                {
                    ray.collider.gameObject.GetComponent <Window> ().breakWindow();
                }
                else if (ray.collider != null)
                {
                    Debug.Log(ray.collider.gameObject.tag);
                    if (ray.collider.gameObject.tag == "Enemy")
                    {
                        if (ray.collider.isTrigger == true && ray.collider.gameObject.tag == "Enemy")
                        {
                            ray.collider.gameObject.GetComponent <EnemyAttacked> ().execute();
                        }
                        else
                        {
                            EnemyAttacked ea = ray.collider.gameObject.GetComponent <EnemyAttacked> ();
                            ea.killMelee();
                            decideSFX();
                        }
                    }
                    else if (ray.collider.gameObject.tag == "Dog")
                    {
                        ray.collider.gameObject.GetComponent <DogHealth> ().killDog();
                    }

                    if (ray.collider.gameObject.tag == "Wall" && ray.collider.gameObject.GetComponent <Window> () != null)
                    {
                        ray.collider.gameObject.GetComponent <Window> ().breakWindow();
                    }
                }
            }
            timer = timerReset;
        }
    }