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 OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "enemy") { ea = coll.gameObject.GetComponent <EnemyAttacked>(); ea.killBullet(); Destroy(gameObject); } else { Destroy(gameObject); } }
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); } }
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(); } }
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(); } }