public string attack(PlayerAttributes player) { GetComponent<Animator>().SetBool("Attacking", true); player.lastDamage = Time.time; PlayerAttributes.giveAlarm = true; float ran = Random.value; string message = "Monster Miss! "; if (ran <= hitChance){ message = "Monster Hit! "; GameObject.Find("Player").GetComponent<Sounds>().playMonsterSound(Sounds.MONSTER_HIT, this); int tmpDamage = damage; if (ran <= critChance) { tmpDamage *= 2; message = "Monster Critical Hit! "; GameObject.Find("Player").GetComponent<Sounds>().playMonsterSound(Sounds.MONSTER_CRIT, this); } player.loseHP(tmpDamage); if(message == "Monster Miss! "){ GameObject.Find("Player").GetComponent<Sounds>().playMonsterSound(Sounds.MONSTER_MISS, this); } } if (GameObject.Find ("Player").GetComponent<PlayerAttributes> ().isDead ()) { GameObject.Find("Player").GetComponent<Sounds>().playDeathSound(Sounds.DEAD_MONSTER); message += "You died."; } else { message += player.hp + "/" + player.maxHP(); } //print(message); //PlayerLog.addStat (message); return message; }