// Update is called once per frame public static void hit(int index) { //Debug.Log("snow_ball_uis"); //Debug.Log(snow_ball_uis.Length); //int index = Character.score % 10; //Debug.Log(index); // for (int i = 0; i < 10; i++) { // if (i != index){ // snow_ball_uiss[i].SetActive(false); // } // } GameObject obj = GameObject.Find("snowballs"); Snow_balls_ui sbui = obj.GetComponent <Snow_balls_ui>(); for (int i = 0; i < 11; i++) { if (i != index) { sbui.snow_ball_uis.ElementAt(i).SetActive(false); } } sbui.snow_ball_uis.ElementAt(index).SetActive(true); }
void OnTriggerEnter(Collider other) { if (other.tag == "music_note") { score += 1; // energy_txt.text = "Snowballs collected: " + score/10; Music_Note_scpt mns = other.gameObject.GetComponent <Music_Note_scpt>(); mns.hit(); int index = Character.score % 11; if (score % 10 == 0) { AudioSource snow_ball = GameObject.Find("MusicSnowBall").GetComponent <AudioSource>(); snow_ball.Play(); } else { AudioSource snow_flake = GameObject.Find("MusicSnowFlake").GetComponent <AudioSource>(); snow_flake.Play(); } // AudioSource ice_break_long = GameObject.Find("MusicSnowFlake").GetComponent<AudioSource>(); Snow_balls_ui.hit(index); } else if (other.tag == "breakable_ice") { charAnim.Play("Die"); Debug.Log("breakable_ice"); // if (score < 10) // { Debug.Log("You die"); GameOverTime = Time.time; isGameOver = true; // other.transform.parent.gameObject.GetComponent<GameController>().EndGame(false); move_logic = 1; // } else // { // Debug.Log("breakable_ice: break"); // score -= 10; // Destroy(other.gameObject); //GameObject Tree_w_Icicles= other.gameObject.transform.Find("Tree_w_Icicles").gameObject; //Destroy(Tree_w_Icicles); // } } else if (other.tag == "unbreakable_barrier") { //Debug.Log("unbreakable_barrier"); charAnim.Play("Die"); Debug.Log("You die"); GameOverTime = Time.time; isGameOver = true; // other.gameObject.GetComponent<GameController>().EndGame(false); move_logic = 1; } }