// Update is called once per frame void Update() { //if the player has not possessed an object if (!possessedObject) { if (Input.GetMouseButton(0)) { Vector2 rayPos = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y); RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, Mathf.Infinity, acceptMask); if (hit.collider != null) { //Debug.Log("Hit " + hit.collider.transform.gameObject.name); if (hit.collider.transform.gameObject.tag == "Spirit") { //Debug.Log("It's working!"); GameObject target = hit.collider.transform.gameObject; audio.PlayOneShot(swoosh); Possess(target); } } else { //Debug.Log("No hit"); } } } else { if (Input.GetKey(KeyCode.B)) { if (!isRecalling) { isRecalling = true; } } } if (isRecalling) { if (recallTimer > 0) { recallTimer--; } else { Recall(newPlayer); dollah.ResetCombo(); dollah.SubtractDollah(10f); } } }
public void DecreaseHealth() { //if ghost is a player if (this.gameObject.tag == "Player") { dollah.SubtractDollah(1f); currentHealth -= 7f; if (currentHealth <= 0f) { //End Game Procedures Debug.Log("Player Died"); SceneManager.LoadScene(1); } } //if ghost is a scrub else { currentHealth -= 30.0f; dollah.IncreaseCombo(); emotions.SetEmotion(Emotions.SAD); Instantiate(dollahParticles, gameObject.transform.position, Quaternion.identity); if (currentHealth <= 0f) { audio.PlayOneShot(money); dollah.AddDollah(false, this.GetComponent <Ghost>().goldInventory); Debug.Log("Spirit Died"); Destroy(gameObject); } } //scales numbers for healthbar float calculateHealth = currentHealth / maxHealth; SetHealthBar(calculateHealth); }