void Dead() { //Give player resource and prepare for reset //health = original_health; //reset_time = original_reset_time; audioS.PlayOneShot(collect, 1f); BarController barcontroller = GameObject.Find("Captain").GetComponent <BarController>(); int resourceAmount = 2 + Random.Range(0, CloudVariables.Values[7] + 2); barcontroller.resource_points += resourceAmount; barcontroller.SetScore(barcontroller.GetScore() + Random.Range(2, 7)); if (barcontroller.GetHorseShoe() == true) { resourceAmount += 2; barcontroller.resource_points += 2; } barcontroller.challengeCounters[3] += resourceAmount; this.gameObject.SetActive(false); }