private void DeveloperCommands() { if (Input.GetKey(KeyCode.R)) { playerHealth.Die(); } }
/* void FlipPlayer(){ * facingRight = !facingRight; * Vector2 localScale = gameObject.transform.localScale; * localScale.x *= -1; * transform.localScale = localScale; * }*/ void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Enemy") { health.Die(); } }
/* * private void OnTriggerEnter2D(Collider2D collision) * { * Debug.Log("COUCOU"); * } * * private void OnCollisionEnter2D(Collision2D collision) * { * Debug.Log(collision.gameObject.tag); * } * * private void OnCollisionExit2D(Collision2D collision) * { * Debug.Log(collision.gameObject.tag); * } */ private void OnTriggerExit2D(Collider2D collision) { Debug.Log("Exit Game Area Detected"); Debug.Log(collision.gameObject.tag); if (collision.gameObject.tag == "Player") { Debug.Log("Player Out of Game Area"); PlayerHealth PV = GameObject.FindObjectOfType <PlayerHealth>(); Debug.Log(PV); if (PV != null) { Debug.Log("Player killed?"); PV.Die(); } } if (collision.gameObject.tag == "Enemy") { Debug.Log("Enemy Out of Game Area"); Enemy E = collision.gameObject.GetComponent <Enemy>(); if (E != null) { Debug.Log("Enemy killed"); E.TakeDommage(int.MaxValue); } } }
private void OnTriggerExit2D(Collider2D other) { if (other.CompareTag("Player")) { _playerHealth.Die(); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { PlayerHealth playerHealth = collision.gameObject.GetComponent <PlayerHealth>(); playerHealth.Die(); } }
public void NoRespawn() { playerHealth.canRespawn = false; respawnMenu.SetActive(false); gameOverMenu.SetActive(true); playerHealth.Die(); Time.timeScale = 0; }
void Update() { if (myHP.currentHealth > 0) { if (isPressing == false) { #region movement system Move(); Pushing(); Climbing(); Jump(); #endregion // Hanging checker. //hang.HangCheck(); PButton(); rTimer -= Time.deltaTime; } else { #region button Timer if (bTimer >= 0f) { bTimer -= Time.deltaTime; } else if (bTimer <= 0) { isPressing = false; animator.SetBool("Button", false); } #endregion } } #region Life handler and death else if (myHP.currentHealth <= 0) { myHP.Die(); } else { Debug.Log("Some error has occured"); } #endregion #region testing purposes for exp if (Input.GetKeyDown(KeyCode.K)) { // Virker kun en gang? expBar.UpdateBar(50); } #endregion }
//if character hits the collider attached private void OnTriggerEnter2D(Collider2D collision) { //trigger player death if (collision.gameObject.tag == "Player") { playerHealth.Die(transform); StartCoroutine("ReloadGame"); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { PlayerHealth ph = other.GetComponent <PlayerHealth>(); if (ph != null) { ph.Die(); } } }
private void OnTriggerStay(Collider other) { if (other.name == "Player") { healthScript.Die(); } else if (other.CompareTag("Enemy")) { Destroy(gameObject); } }
private void Check() { // if Score high enough open Next Level Portal, else Die if (Score.instance.GetScore() >= Score.instance.GetNeedScore()) { GameObject portal = Instantiate(portalPrefab, nextLevelPortal.position, Quaternion.identity); Animator portalAnim = portal.GetComponent <Animator>(); portalAnim.SetTrigger("open"); } else { health.Die(); } }
public void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "Player") { if (playerHealth != null) { playerHealth.Die(); } else { Destroy(col.gameObject); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "BH") { health.Die(); } else if (collision.tag == "Asteroid") { health.TakeDamage(); AddScore(-scoreForAsteroid); Destroy(collision.gameObject); } else if (collision.tag == "Satellite" && collision.GetComponent <SpaceObject>().GetSaved == false) // a 2-a conditie necesara pentru a evita exploit de obtinere scor. { AddScore(scoreForSatellite); } }
public void TimeUp() { PlayerHealth p1 = player1.GetComponent <PlayerHealth>(); PlayerHealth p2 = player2.GetComponent <PlayerHealth>(); if (p1.Health > p2.Health) { p1.Die(); } else if (p1.Health < p2.Health) { p2.Die(); } else { Draw(); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("BH")) { health.Die(); list.Add(Instantiate(system2, collision.transform.position, Quaternion.identity)); list[list.Count - 1].Play(); } else if (collision.CompareTag("Heart")) { health.GetHealed(); list.Add(Instantiate(system1, collision.transform.position, Quaternion.identity)); list[list.Count - 1].Play(); Destroy(collision.gameObject); } else if (collision.CompareTag("Asteroid")) { list.Add(Instantiate(system2, collision.transform.position, Quaternion.identity)); list[list.Count - 1].Play(); if (abilities.GetIsShieldOn()) { Destroy(collision.gameObject); } else { health.TakeDamage(); AddScore(-scoreForAsteroid); Destroy(collision.gameObject); } } else if (collision.CompareTag("Satellite") && collision.GetComponent <SpaceObject>().GetSaved == false) // a 2-a conditie necesara pentru a evita exploit de obtinere scor. { AddScore(scoreForSatellite); } if (list.Count != 0 && (!list[0].isPlaying)) { Destroy(list[0].gameObject); list.RemoveAt(0); } }
private void Update() { if (!GetComponent <PlayerController>().IsGrounded) { _timeFalling += Time.deltaTime; if (_playerHealth && _timeFalling >= fallSecondsToDie) { if (!_playerHealth.isDead) { _playerHealth.Die(true); } _timeFalling = 0; } } else { _timeFalling = 0; } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Collectible") { Score.playerScore += PickUp.pickUpPoints; } // Enemy Logic if (other.gameObject.CompareTag("Attack point")) { PlayerHealth.Die(); } if (other.gameObject.CompareTag("Stomp point")) { Score.playerScore += 10; // Bounce after jumping on enemy rb2d.velocity = new Vector2(rb2d.velocity.x, playerBounceForce); Debug.Log("dead"); Destroy(other.transform.parent.gameObject); } }
void DieOnExplode() { healthScript.Die(); }
// 处理响应 void ProcessJD(JsonData jd) { if (jd != null) { string msgname = (string)jd ["msgname"]; if (msgname == "CreateEnemy") { JsonData data = jd ["data"]; for (int i = 0; i < data.Count; ++i) { int id = (int)data [i] ["id"]; int type = (int)data [i] ["type"]; int HP = (int)data [i] ["HP"]; float x = (float)((double)data [i] ["x"]); float z = (float)((double)data [i] ["z"]); switch (type) { case 0: GameObject enemy0 = Instantiate(enemyType1, new Vector3(x, 0.0f, z), this.transform.rotation) as GameObject; enemy0.GetComponent <AI> ().id = id; enemy0.GetComponent <Health> ().Init(HP); enemies [id] = enemy0; break; case 1: GameObject enemy1 = Instantiate(enemyType2, new Vector3(x, 0.0f, z), this.transform.rotation) as GameObject; enemy1.GetComponent <AI> ().id = id; enemies [id] = enemy1; enemy1.GetComponent <Health> ().Init(HP); break; } } } else if (msgname == "UpdateHP") { int id = (int)jd ["id"]; int HP = (int)jd ["HP"]; if (id == -1) { if (HP > 0) { ph.UpdateHp(HP); } else { ph.UpdateHp(0); dieTime = Time.time; ShowDialog("Endless Shoot", "你已死亡,将在3秒后返回!"); ph.Die(); } } else { if (enemies.ContainsKey(id)) { if (HP > 0) { enemies [id].GetComponent <Health> ().UpdateHp(HP); } else { enemies [id].GetComponent <Health> ().Die(); killedCount += 1; killedText.text = string.Format("击杀数:{0}", killedCount); } } } } else if (msgname == "UpdateAmmunition") { int ammunition = (int)jd ["ammunition"]; ak.UpdateAmmunition(ammunition); } else if (msgname == "LevelUp") { int exp = (int)jd ["EXP"]; int nextLevelExp = (int)jd ["NextLevelExp"]; int level = (int)jd ["Level"]; int HP = (int)jd ["HP"]; ph.UpdateEXP(exp, nextLevelExp, level, HP); } else if (msgname == "CreateEquipment") { float x = (float)((double)jd ["X"]); float z = (float)((double)jd ["Z"]); Instantiate(equipment, new Vector3(x, 1.0f, z), this.transform.rotation); } else if (msgname == "UpdatePath") { int id = (int)jd ["id"]; if (enemies.ContainsKey(id)) { JsonData path = jd["path"]; enemies [id].GetComponent <AI> ().SetPath(path); } } } }
void Die() { ph.Die(); }
public void deathEnd() { playerHealth.Die(); }