void Awake() { // START GREEN INITIALLY - WORLD 1 Large_Prefab.GetComponent <Image>().sprite = large_green; Mid_Prefab.GetComponent <Image>().sprite = mid_green; Small_Prefab.GetComponent <Image>().sprite = small_green; Set_GameSounds(); }
public void Change_World_Settings(int world_no) { // Yellow if (world_no == 0) { // New generated blocks will be correct. Large_Prefab.GetComponent <Image>().sprite = large_orange; Mid_Prefab.GetComponent <Image>().sprite = mid_orange; Small_Prefab.GetComponent <Image>().sprite = small_orange; // Background Change GameObject.Find("Background").transform.GetChild(0).GetComponent <Image>().sprite = Orange_Background; // Current block's image change. for (int i = 0; i < GenerateBlocks.BlockList.Count; i++) { if (GenerateBlocks.BlockList[i].gameObject.tag == "largeblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = large_orange; } if (GenerateBlocks.BlockList[i].gameObject.tag == "midblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = mid_orange; } if (GenerateBlocks.BlockList[i].gameObject.tag == "smallblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = small_orange; } if (GenerateBlocks.BlockList[i].gameObject.tag == "orangespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = true; } if (GenerateBlocks.BlockList[i].gameObject.tag == "bluespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = false; } if (GenerateBlocks.BlockList[i].gameObject.tag == "purplespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = false; } } } // Blue else if (world_no == 1) { // New generated blocks will be correct. Large_Prefab.GetComponent <Image>().sprite = large_green; Mid_Prefab.GetComponent <Image>().sprite = mid_green; Small_Prefab.GetComponent <Image>().sprite = small_green; // Background Change GameObject.Find("Background").transform.GetChild(0).GetComponent <Image>().sprite = Green_Background; // Current block's image change. for (int i = 0; i < GenerateBlocks.BlockList.Count; i++) { if (GenerateBlocks.BlockList[i].gameObject.tag == "largeblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = large_green; } if (GenerateBlocks.BlockList[i].gameObject.tag == "midblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = mid_green; } if (GenerateBlocks.BlockList[i].gameObject.tag == "smallblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = small_green; } if (GenerateBlocks.BlockList[i].gameObject.tag == "orangespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = false; } if (GenerateBlocks.BlockList[i].gameObject.tag == "bluespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = true; } if (GenerateBlocks.BlockList[i].gameObject.tag == "purplespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = false; } } } else if (world_no == 2) { // New generated blocks will be correct. Large_Prefab.GetComponent <Image>().sprite = large_purple; Mid_Prefab.GetComponent <Image>().sprite = mid_purple; Small_Prefab.GetComponent <Image>().sprite = small_purple; // Background Change GameObject.Find("Background").transform.GetChild(0).GetComponent <Image>().sprite = Purple_Background; // Current block's image change. for (int i = 0; i < GenerateBlocks.BlockList.Count; i++) { if (GenerateBlocks.BlockList[i].gameObject.tag == "largeblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = large_purple; } if (GenerateBlocks.BlockList[i].gameObject.tag == "midblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = mid_purple; } if (GenerateBlocks.BlockList[i].gameObject.tag == "smallblock") { GenerateBlocks.BlockList[i].GetComponent <Image>().sprite = small_purple; } if (GenerateBlocks.BlockList[i].gameObject.tag == "orangespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = false; } if (GenerateBlocks.BlockList[i].gameObject.tag == "bluespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = false; } if (GenerateBlocks.BlockList[i].gameObject.tag == "purplespecialblock") { GenerateBlocks.BlockList[i].GetComponent <BoxCollider2D>().enabled = true; } } } }