IEnumerator Die() { SFCController.PlaySound("playerDeath"); yield return(new WaitForSeconds(2.0f)); SceneManager.LoadScene("LoseGame"); }
public void TakeDamage(int a) { health -= a; StartCoroutine(BlinkRed()); if (health <= 0) { SFCController.PlaySound("zombieDeath"); Destroy(gameObject); } }
void Shoot() { shootDirection = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; //lookAngle = Mathf.Atan2(shootDirection.y, shootDirection.x)*Mathf.Rad2Deg; //shootDirection.Normalize(); Vector2 direction = shootDirection; direction.Normalize(); //Debug.Log(direction); if (Input.GetMouseButtonDown(0)) { SFCController.PlaySound("attack"); GameObject fireBullet = Instantiate(sword, transform.position, transform.rotation); fireBullet.GetComponent <Rigidbody2D>().velocity = direction * shootSpeed; } }
public void TakeDamage(int damage) { // Debug.Log("Ouch! "); SFCController.PlaySound("zombieBite"); SFCController.PlaySound("hit"); health -= damage; lifeCounter.GetComponent <UnityEngine.UI.Text>().text = string.Format("{0}/{1} Lives", health, maxHealth); if (health <= 0) { //Destroy(gameObject); StartCoroutine(Die()); gameObject.GetComponent <SpriteRenderer>().enabled = false; gameObject.GetComponent <PlayerController>().enabled = false; rb.isKinematic = true; rb.constraints = RigidbodyConstraints2D.FreezePosition; } }