public void Start_me(string window_message, ads_master.ad_reward kind_of_reward, int quantity) { if (normal_height == 0) normal_height = my_window_rect.rect.height; //start pause currentTimeScale = Time.timeScale; Time.timeScale = 0; if (my_game_master.use_pad) EventSystem_obj.SetActive(false);//in order to avoid pad input out the of the window if (my_game_master.show_debug_messages) Debug.Log("gift_manager - Start_me("+kind_of_reward+","+quantity+")"); //setup window proprieties window_text_message.text = window_message; child_buttons = this.transform.childCount; my_game_master.a_window_is_open = true; //reset variables selected_button = -1; gift_buttons_is_active = 0; if (my_game_master.my_ads_master.current_ad.my_special_ad_reward == ads_master.special_ad_reward.none) { my_window_rect.sizeDelta = new Vector2(my_window_rect.rect.width,normal_height); if (buy_button) buy_button.SetActive(false); switch(kind_of_reward) { case ads_master.ad_reward.virtual_money: //be sure to not break the cap if ((my_game_master.current_virtual_money[my_game_master.current_profile_selected] + quantity) > my_game_master.virtual_money_cap) { quantity = my_game_master.virtual_money_cap-my_game_master.current_virtual_money[my_game_master.current_profile_selected]; my_game_master.my_ads_master.current_quantity_reward_selected = quantity; } window_text_item_name.text = my_game_master.virtual_money_name; window_text_item_description.text = "";// quantity.ToString("N0"); Single_reward_setup(virtual_money_ico,quantity); break; case ads_master.ad_reward.new_live: //be sure to not break the cap if ((my_game_master.current_lives[my_game_master.current_profile_selected] + quantity) > my_game_master.live_cap) { quantity = my_game_master.live_cap-my_game_master.current_lives[my_game_master.current_profile_selected]; my_game_master.my_ads_master.current_quantity_reward_selected = quantity; } window_text_item_name.text = my_game_master.lives_name; window_text_item_description.text = "";// quantity.ToString("N0"); Single_reward_setup(live_ico,quantity); break; case ads_master.ad_reward.consumable_item: if ((my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].avaible_from_world <= my_game_master.play_this_stage_to_progress_in_the_game_world[my_game_master.current_profile_selected]) //world && (my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].avaible_from_stage <= my_game_master.play_this_stage_to_progress_in_the_game_stage[my_game_master.current_profile_selected]))//stage { //be sure to not break the cap if ((my_game_master.consumable_item_current_quantity[my_game_master.current_profile_selected][my_game_master.my_ads_master.current_item_id_reward_selected] + quantity) > my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].quantity_cap) { quantity = my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].quantity_cap - my_game_master.consumable_item_current_quantity[my_game_master.current_profile_selected][my_game_master.my_ads_master.current_item_id_reward_selected]; my_game_master.my_ads_master.current_quantity_reward_selected = quantity; } window_text_item_name.text = my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].name; window_text_item_description.text = my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].description; Single_reward_setup(my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].icon,quantity); } else { if (my_game_master.show_debug_messages) Debug.Log(my_game_master.my_store_item_manager.consumable_item_list[my_game_master.my_ads_master.current_item_id_reward_selected].name + " not is avaible yet"); } break; case ads_master.ad_reward.select_by_the_player: //deactivate the single reward ico single_reward.SetActive(false); //activate the choices for (int i = 0; i < child_buttons; i++) { if (i < my_game_master.my_ads_master.current_ad.player_choices) { gift_button child_script = this.transform.GetChild(i).GetComponent<gift_button>(); this.transform.GetChild(i).GetComponent<Image>().sprite = not_select_button_sprite; //setup quantity if (my_game_master.my_ads_master.current_ad.player_choice_random_quantity[i]) quantity = UnityEngine.Random.Range(my_game_master.my_ads_master.current_ad.player_choice_random_quantity_min[i], my_game_master.my_ads_master.current_ad.player_choice_random_quantity_max[i]); else quantity = my_game_master.my_ads_master.current_ad.player_choice_quantity[i]; //setup kind switch(my_game_master.my_ads_master.current_ad.ad_reward_by_player_choice_selected[i]) { case ads_master.ad_reward_by_player_choice.virtual_money: child_script.give_this_selected = ads_master.ad_reward.virtual_money; //cap quantity if ((my_game_master.current_virtual_money[my_game_master.current_profile_selected] + quantity) > my_game_master.virtual_money_cap) quantity = my_game_master.virtual_money_cap-my_game_master.current_virtual_money[my_game_master.current_profile_selected]; break; case ads_master.ad_reward_by_player_choice.new_live: child_script.give_this_selected = ads_master.ad_reward.new_live; //cap quantity if ((my_game_master.current_lives[my_game_master.current_profile_selected] + quantity) > my_game_master.live_cap) quantity = my_game_master.live_cap-my_game_master.current_lives[my_game_master.current_profile_selected]; break; case ads_master.ad_reward_by_player_choice.consumable_item: child_script.give_this_selected = ads_master.ad_reward.consumable_item; if (my_game_master.my_ads_master.current_ad.player_choice_random_item_id[i]) child_script.item_id = UnityEngine.Random.Range(my_game_master.my_ads_master.current_ad.player_choice_random_item_id_min[i], my_game_master.my_ads_master.current_ad.player_choice_random_item_id_max[i]+1); else child_script.item_id = my_game_master.my_ads_master.current_ad.player_choice_consumable_item_id[i]; //cap quantity if ((my_game_master.consumable_item_current_quantity[my_game_master.current_profile_selected][child_script.item_id] + quantity) > my_game_master.my_store_item_manager.consumable_item_list[child_script.item_id].quantity_cap) quantity = my_game_master.my_store_item_manager.consumable_item_list[child_script.item_id].quantity_cap - my_game_master.consumable_item_current_quantity[my_game_master.current_profile_selected][child_script.item_id]; break; } child_script.quantity = quantity; if (quantity > 0) child_script.Start_me(i); else this.transform.GetChild(i).gameObject.SetActive(false); } else this.transform.GetChild(i).gameObject.SetActive(false); } break; } //if there is some gift to give, active the gift window if (gift_buttons_is_active > 0) gift_screen.SetActive(true); } else //special reward { Debug.Log(my_game_master.my_ads_master.current_ad.my_special_ad_reward); //setup window appearance: //deactivate all buttons for (int i = 0; i < child_buttons; i++) this.transform.GetChild(i).gameObject.SetActive(false); //deactivate the single reward ico single_reward.SetActive(false); window_text_item_name.text = ""; window_text_item_description.text = ""; my_window_rect.sizeDelta = new Vector2(my_window_rect.rect.width,small_height); if(buy_button) { if (my_game_master.my_ads_master.buy_button_cost > 0) { buy_button.SetActive(true); buy_button_text.text = my_game_master.my_ads_master.buy_button_cost.ToString("N0"); if (my_game_master.my_ads_master.buy_button_cost <= my_game_master.current_virtual_money[my_game_master.current_profile_selected])//you have enough money buy_button.GetComponent<Image>().sprite = buy_button_on; else//you can't effort this purchase buy_button.GetComponent<Image>().sprite = buy_button_off; } else buy_button.SetActive(false); } gift_screen.SetActive(true); } Check_internet(); }
void Unity_ads_options_setup(ads_master.ad_options target_ad, string my_name) { target_ad.this_ad_is_enabled = EditorGUILayout.Toggle(my_name,target_ad.this_ad_is_enabled); if (target_ad.this_ad_is_enabled) { EditorGUI.indentLevel++; target_ad.show_custom_settings_in_inspector = EditorGUILayout.Foldout(target_ad.show_custom_settings_in_inspector, "Settings:"); if (target_ad.show_custom_settings_in_inspector) { EditorGUI.indentLevel++; target_ad.chance_to_open_an_ad_here = EditorGUILayout.IntSlider("% chance to show this ad",target_ad.chance_to_open_an_ad_here, 1 , 100); if (target_ad.when_app_start) { EditorGUILayout.LabelField("wait for:"); EditorGUI.indentLevel++; target_ad.start_app_ad_wait_for_days = EditorGUILayout.IntSlider("days",target_ad.start_app_ad_wait_for_days,0,365); target_ad.start_app_ad_wait_for_hours = EditorGUILayout.IntSlider("hours",target_ad.start_app_ad_wait_for_hours,0,23); target_ad.start_app_ad_wait_for_minutes = EditorGUILayout.IntSlider("minutes",target_ad.start_app_ad_wait_for_minutes ,0,59); EditorGUI.indentLevel--; } else target_ad.ignore_minimum_time_interval_between_ads = EditorGUILayout.Toggle("ignore minimum time interval between ads",target_ad.ignore_minimum_time_interval_between_ads); target_ad.ask_to_player_if_he_want_to_watch_an_ad_before_start_it = EditorGUILayout.Toggle("ASK to player if he want to watch an ad before start it",target_ad.ask_to_player_if_he_want_to_watch_an_ad_before_start_it); EditorGUI.indentLevel++; if (target_ad.ask_to_player_if_he_want_to_watch_an_ad_before_start_it) { target_ad.asking_text = EditorGUILayout.TextField("what say:",target_ad.asking_text); target_ad.my_rule = ads_master.ad_main_rule.rewarded_but_not_skip; } else target_ad.my_rule = ads_master.ad_main_rule.skipable_but_not_reward; EditorGUI.indentLevel--; if (target_ad.my_rule == ads_master.ad_main_rule.rewarded_but_not_skip) { EditorGUI.indentLevel++; target_ad.randrom_reward = EditorGUILayout.Toggle("random reward",target_ad.randrom_reward); if (target_ad.randrom_reward) { EditorGUI.indentLevel++; float chance_total = 0; bool chance_total_error = false; target_ad.random_slots = EditorGUILayout.IntSlider("slots",target_ad.random_slots, 2 , 10); if (target_ad.chance_to_give_this_reward.Length != target_ad.random_slots || target_ad.kind_of_randrom_reward.Length != target_ad.random_slots || target_ad.min_item_id_randrom_reward.Length != target_ad.random_slots || target_ad.max_item_id_randrom_reward.Length != target_ad.random_slots || target_ad.randrom_reward_quantity_for_random_reward.Length != target_ad.random_slots || target_ad.min_reward_quantity_for_random_reward.Length != target_ad.random_slots || target_ad.max_reward_quantity_for_random_reward.Length != target_ad.random_slots || target_ad.reward_quantity_for_random_reward.Length != target_ad.random_slots) { target_ad.chance_to_give_this_reward = new float[target_ad.random_slots]; target_ad.kind_of_randrom_reward = new ads_master.ad_reward[target_ad.random_slots]; target_ad.min_item_id_randrom_reward = new int[target_ad.random_slots]; target_ad.max_item_id_randrom_reward = new int[target_ad.random_slots]; target_ad.randrom_reward_quantity_for_random_reward = new bool[target_ad.random_slots]; target_ad.min_reward_quantity_for_random_reward = new int[target_ad.random_slots]; target_ad.max_reward_quantity_for_random_reward = new int[target_ad.random_slots]; target_ad.reward_quantity_for_random_reward = new int[target_ad.random_slots]; } //check % sum for (int i = 0; i < target_ad.random_slots; i++) chance_total += target_ad.chance_to_give_this_reward[i]; if (chance_total != 100) { chance_total_error = true; EditorGUILayout.LabelField(" - ERROR - the chance total is "+chance_total+" but it MUST be 100"); } for (int i = 0; i < target_ad.random_slots; i++) { //kind of reward if (target_ad.kind_of_randrom_reward[i] == ads_master.ad_reward.select_by_the_player) GUI.color = Color.red; else GUI.color = Color.white; target_ad.kind_of_randrom_reward[i] = (ads_master.ad_reward)EditorGUILayout.EnumPopup("reward",target_ad.kind_of_randrom_reward[i]); GUI.color = Color.white; EditorGUI.indentLevel++; if (chance_total_error) GUI.color = Color.red; else GUI.color = Color.white; target_ad.chance_to_give_this_reward[i] = EditorGUILayout.Slider("% chance",target_ad.chance_to_give_this_reward[i], 0 , 100); GUI.color = Color.white; if (target_ad.kind_of_randrom_reward[i] == ads_master.ad_reward.consumable_item) { target_ad.min_item_id_randrom_reward[i] = EditorGUILayout.IntField("min item id",target_ad.min_item_id_randrom_reward[i]); target_ad.max_item_id_randrom_reward[i] = EditorGUILayout.IntField("max item id",target_ad.max_item_id_randrom_reward[i]); } //quantity target_ad.randrom_reward_quantity_for_random_reward[i] = EditorGUILayout.Toggle("random quantity",target_ad.randrom_reward_quantity_for_random_reward[i]); EditorGUI.indentLevel++; if (target_ad.randrom_reward_quantity_for_random_reward[i]) { target_ad.min_reward_quantity_for_random_reward[i] = EditorGUILayout.IntField("min quantity",target_ad.min_reward_quantity_for_random_reward[i]); target_ad.max_reward_quantity_for_random_reward[i] = EditorGUILayout.IntField("max quantity",target_ad.max_reward_quantity_for_random_reward[i]); } else target_ad.reward_quantity_for_random_reward[i] = EditorGUILayout.IntField("quantity",target_ad.reward_quantity_for_random_reward[i]); EditorGUI.indentLevel--; EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } else //always same reward { target_ad.my_ad_reward = (ads_master.ad_reward)EditorGUILayout.EnumPopup("reward",target_ad.my_ad_reward); if (target_ad.my_ad_reward == ads_master.ad_reward.consumable_item) { EditorGUI.indentLevel++; target_ad.choose_a_random_consumable = EditorGUILayout.Toggle("choose a random consumable",target_ad.choose_a_random_consumable); EditorGUI.indentLevel++; if (target_ad.choose_a_random_consumable) { if (target_ad.min_random_consumable_item_id < 0) GUI.color = Color.red; else GUI.color = Color.white; target_ad.min_random_consumable_item_id = EditorGUILayout.IntField("min item id",target_ad.min_random_consumable_item_id ); GUI.color = Color.white; target_ad.max_random_consumable_item_id = EditorGUILayout.IntField("max item id",target_ad.max_random_consumable_item_id ); } else { if (target_ad.consumable_item_id < 0) GUI.color = Color.red; else GUI.color = Color.white; target_ad.consumable_item_id = EditorGUILayout.IntField("item id",target_ad.consumable_item_id); GUI.color = Color.white; } EditorGUI.indentLevel--; EditorGUI.indentLevel--; } if (target_ad.my_ad_reward != ads_master.ad_reward.select_by_the_player) { target_ad.randrom_reward_quantity = EditorGUILayout.Toggle("random quantity",target_ad.randrom_reward_quantity); if (target_ad.randrom_reward_quantity) { EditorGUI.indentLevel++; if (target_ad.min_reward_quantity < 1) GUI.color = Color.red; else GUI.color = Color.white; target_ad.min_reward_quantity = EditorGUILayout.IntField("min",target_ad.min_reward_quantity); GUI.color = Color.white; if (target_ad.max_reward_quantity < 2) GUI.color = Color.red; else GUI.color = Color.white; target_ad.max_reward_quantity = EditorGUILayout.IntField("max",target_ad.max_reward_quantity); GUI.color = Color.white; EditorGUI.indentLevel--; } else //always same quantity { if (target_ad.reward_quantity < 1) GUI.color = Color.red; else GUI.color = Color.white; target_ad.reward_quantity = EditorGUILayout.IntField("quantity",target_ad.reward_quantity); GUI.color = Color.white; } } else //reward selected by the player { EditorGUI.indentLevel++; target_ad.player_choices = EditorGUILayout.IntSlider("choices",target_ad.player_choices,2,4); EditorGUI.indentLevel++; for (int i = 0; i < target_ad.player_choices; i++) { EditorGUILayout.LabelField("button " + (i+1).ToString()); EditorGUI.indentLevel++; target_ad.ad_reward_by_player_choice_selected[i] = (ads_master.ad_reward_by_player_choice)EditorGUILayout.EnumPopup("reward",target_ad.ad_reward_by_player_choice_selected[i]); //consumable item id if (target_ad.ad_reward_by_player_choice_selected[i] == ads_master.ad_reward_by_player_choice.consumable_item) { EditorGUILayout.BeginHorizontal(); string t_id = ""; if (!target_ad.player_choice_random_item_id[i]) { if (target_ad.player_choice_consumable_item_id[i] < 0) GUI.color = Color.red; else GUI.color = Color.white; target_ad.player_choice_consumable_item_id[i] = EditorGUILayout.IntField("item id",target_ad.player_choice_consumable_item_id[i]); GUI.color = Color.white; } else t_id = " id"; target_ad.player_choice_random_item_id[i] = EditorGUILayout.Toggle("random" + t_id,target_ad.player_choice_random_item_id[i]); EditorGUILayout.EndHorizontal(); if (target_ad.player_choice_random_item_id[i]) { EditorGUI.indentLevel++; if (target_ad.player_choice_random_item_id_min[i] < 0 || target_ad.player_choice_random_item_id_min[i] >= target_ad.player_choice_random_item_id_max[i]) GUI.color = Color.red; else GUI.color = Color.white; target_ad.player_choice_random_item_id_min[i] = EditorGUILayout.IntField("min",target_ad.player_choice_random_item_id_min[i]); GUI.color = Color.white; if (target_ad.player_choice_random_item_id_max[i] <= target_ad.player_choice_random_item_id_min[i] ) GUI.color = Color.red; else GUI.color = Color.white; target_ad.player_choice_random_item_id_max[i] = EditorGUILayout.IntField("max",target_ad.player_choice_random_item_id_max[i]); GUI.color = Color.white; EditorGUI.indentLevel--; } } //quantity EditorGUILayout.BeginHorizontal(); string tq = ""; if (!target_ad.player_choice_random_quantity[i]) { if (target_ad.player_choice_quantity[i] < 1) GUI.color = Color.red; else GUI.color = Color.white; target_ad.player_choice_quantity[i] = EditorGUILayout.IntField("quantity",target_ad.player_choice_quantity[i]); GUI.color = Color.white; } else tq = " quantity"; target_ad.player_choice_random_quantity[i] = EditorGUILayout.Toggle("random" + tq,target_ad.player_choice_random_quantity[i]); EditorGUILayout.EndHorizontal(); if (target_ad.player_choice_random_quantity[i]) { EditorGUI.indentLevel++; if (target_ad.player_choice_random_quantity_min[i] < 0 || target_ad.player_choice_random_quantity_min[i] >= target_ad.player_choice_random_quantity_max[i]) GUI.color = Color.red; else GUI.color = Color.white; target_ad.player_choice_random_quantity_min[i] = EditorGUILayout.IntField("min",target_ad.player_choice_random_quantity_min[i]); GUI.color = Color.white; if (target_ad.player_choice_random_quantity_max[i] <= target_ad.player_choice_random_quantity_min[i] ) GUI.color = Color.red; else GUI.color = Color.white; target_ad.player_choice_random_quantity_max[i] = EditorGUILayout.IntField("max",target_ad.player_choice_random_quantity_max[i]); GUI.color = Color.white; EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; EditorGUI.indentLevel--; } } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } }
public void Start_me_with_ad(ads_master.ad_options target_ad) { if (game_master.game_master_obj) my_game_master = (game_master)game_master.game_master_obj.GetComponent("game_master"); else { if (my_game_uGUI.show_debug_warnings) Debug.LogWarning("You need to open this stage from Home scene in order to see continue with ads"); return; } if (target_ad.ignore_minimum_time_interval_between_ads || (my_game_master.my_ads_master.minimum_time_interval_between_ads+my_game_master.my_ads_master.time_of_latest_ad_showed) < Time.realtimeSinceStartup) { if (my_game_uGUI.show_debug_messages) Debug.Log("ad pass time check"); if (UnityEngine.Random.Range(1,100) <= target_ad.chance_to_open_an_ad_here) { my_game_master.my_ads_master.current_ad = target_ad; yes_button.SetActive(false); watch_button.SetActive(true); initial_time_scale = Time.timeScale; Time.timeScale = 1 * time_scale_multiplier; Update_heading(); game_uGUI.in_pause = true; game_uGUI.allow_game_input = false; can_take_input = true; this.gameObject.SetActive(true); if (my_game_master.continue_menu_have_countdown) { my_timer.text = my_game_master.continue_menu_countdown_seconds.ToString(); stop_timer = false; StartCoroutine(Countdown(my_game_master.continue_menu_countdown_seconds)); my_timer.gameObject.SetActive(true); } else my_timer.gameObject.SetActive(false); } else { if (my_game_uGUI.show_debug_messages) Debug.Log("ad - random fail"); Continue_no(true); } } else { if (my_game_uGUI.show_debug_messages) Debug.Log("ad don't pass time check"); Continue_no(true); } }
// Use this for initialization void Awake () { GoogleCloudMessageService.ActionCMDRegistrationResult += HandleActionCMDRegistrationResult; GoogleCloudMessageService.ActionCouldMessageLoaded += OnMessageLoaded; GoogleCloudMessageService.ActionGCMPushLaunched += HandleActionGCMPushLaunched; GoogleCloudMessageService.ActionGCMPushReceived += HandleActionGCMPushReceived; GoogleCloudMessageService.Instance.Init(); if ( !game_is_started ) { keep_me = true; home_scene_name = Application.loadedLevelName; my_store_item_manager = this.gameObject.GetComponent<store_item_manager>(); my_ads_master = GetComponent<ads_master>(); if (my_ads_master) my_ads_master.Initiate_ads(); } if (keep_me) { game_master_obj = this.gameObject; DontDestroyOnLoad(game_master_obj);//this prefab will be used as reference from the others, so don't destry it when load a new scene //sum the stages in every world to know the total number of stages in the game for(int w = 0; w < total_stages_in_world_n.Length; w++) { total_number_of_stages_in_the_game += total_stages_in_world_n[w]; if (total_stages_in_world_n[w] > max_stages_in_a_world) max_stages_in_a_world = total_stages_in_world_n[w]; } if (show_debug_messages) Debug.Log("total_number_of_stages_in_the_game = " + total_number_of_stages_in_the_game + " max_stages_in_a_world = " + max_stages_in_a_world ); //create multy arrays for multy profile saves this_profile_have_a_save_state_in_it = new bool[number_of_save_profile_slot_avaibles]; profile_name = new string[number_of_save_profile_slot_avaibles]; music_on = new bool[number_of_save_profile_slot_avaibles]; music_volume = new float[number_of_save_profile_slot_avaibles]; sfx_on = new bool[number_of_save_profile_slot_avaibles]; sfx_volume = new float[number_of_save_profile_slot_avaibles]; voice_on = new bool[number_of_save_profile_slot_avaibles]; voice_volume = new float[number_of_save_profile_slot_avaibles]; if (!infinite_lives) { current_lives = new int[number_of_save_profile_slot_avaibles]; target_time = new DateTime[number_of_save_profile_slot_avaibles]; recharge_live_countdown_active = new bool[number_of_save_profile_slot_avaibles]; } if(continue_rule_selected == continue_rule.continue_cost_a_continue_token) current_continue_tokens = new int[number_of_save_profile_slot_avaibles]; world_playable = new bool[number_of_save_profile_slot_avaibles][]; world_purchased = new bool[number_of_save_profile_slot_avaibles][]; current_world = new int[number_of_save_profile_slot_avaibles]; stage_playable = new bool[number_of_save_profile_slot_avaibles][,]; total_number_of_stages_in_the_game_solved = new int[number_of_save_profile_slot_avaibles]; stage_solved = new bool[number_of_save_profile_slot_avaibles][,]; all_stages_solved = new bool[number_of_save_profile_slot_avaibles]; dot_tail_turn_on = new bool[number_of_save_profile_slot_avaibles][,]; play_this_stage_to_progress_in_the_game_world = new int[number_of_save_profile_slot_avaibles]; play_this_stage_to_progress_in_the_game_stage = new int[number_of_save_profile_slot_avaibles]; latest_stage_played_world = new int[number_of_save_profile_slot_avaibles]; latest_stage_played_stage = new int[number_of_save_profile_slot_avaibles]; stage_stars_score = new int[number_of_save_profile_slot_avaibles][,]; star_score_in_this_world = new int[number_of_save_profile_slot_avaibles][]; stars_total_score = new int[number_of_save_profile_slot_avaibles]; best_int_score_in_this_stage = new int[number_of_save_profile_slot_avaibles][,]; best_int_score_for_current_player = new int[number_of_save_profile_slot_avaibles]; //int funds = StoreInventory.GetItemBalance("Coins"); current_virtual_money = new int[number_of_save_profile_slot_avaibles]; //current_virtual_money = current_virtual_money +=funds; if (my_store_item_manager) { incremental_item_current_level = new int[number_of_save_profile_slot_avaibles][]; consumable_item_current_quantity = new int[number_of_save_profile_slot_avaibles][]; } for (int i = 0; i < number_of_save_profile_slot_avaibles; i++) { world_playable[i] = new bool[total_stages_in_world_n.Length]; world_purchased[i] = new bool[total_stages_in_world_n.Length]; stage_playable[i] = new bool[total_stages_in_world_n.Length,max_stages_in_a_world]; stage_solved[i] = new bool[total_stages_in_world_n.Length,max_stages_in_a_world]; stage_stars_score[i] = new int[total_stages_in_world_n.Length,max_stages_in_a_world]; star_score_in_this_world[i] = new int[total_stages_in_world_n.Length]; best_int_score_in_this_stage[i] = new int[total_stages_in_world_n.Length,max_stages_in_a_world]; dot_tail_turn_on[i] = new bool[total_stages_in_world_n.Length,max_stages_in_a_world]; this_profile_have_a_save_state_in_it[i] = Convert.ToBoolean(PlayerPrefs.GetInt("profile_"+i.ToString()+"_have_a_save_state_in_it")) ; if (my_store_item_manager) { incremental_item_current_level[i] = new int[my_store_item_manager.incremental_item_list.Length]; consumable_item_current_quantity[i] = new int[my_store_item_manager.consumable_item_list.Length]; } } exist_a_save_state = Convert.ToBoolean(PlayerPrefs.GetInt("savestate")) ; current_profile_selected = PlayerPrefs.GetInt("last_profile_used"); music_on[current_profile_selected] = true; music_volume[current_profile_selected] = 1; sfx_on[current_profile_selected] = true; sfx_volume[current_profile_selected] = 1; voice_on[current_profile_selected] = true; voice_volume[current_profile_selected] = 1; if (exist_a_save_state)//copy the saves in the arrays { if (PlayerPrefs.GetInt("total_number_of_stages_in_the_game") == total_number_of_stages_in_the_game) //if the _total_stages number not is the same of last time, erase save data to avoid broken array (the _total_stages don't cange in the game, so the player don't chance to lose his saves. This is useful when you decide to change the total stage number through the making of the game and avoid errors because previous save data refer to a old version) { if (show_debug_messages) { Debug.Log("same total_stages from the last time"); Debug.Log("current_profile_selected "+ current_profile_selected); } //check if the last profile used have can be load if (this_profile_have_a_save_state_in_it[current_profile_selected]) Load(current_profile_selected); else //I can't find the last profile used { //so ask to select/create a profile show_new_profile_window = true; } } else //you have changed the total_stages from the last time, sto the old save data have a different array_length. { if (show_debug_messages) Debug.Log("different total_stages from the last time"); if (this_profile_have_a_save_state_in_it[current_profile_selected]) { if (total_number_of_stages_in_the_game > PlayerPrefs.GetInt("total_number_of_stages_in_the_game")) //you have add stages from last time { if (show_debug_messages) Debug.Log("there are more stages that in the previous save data"); PlayerPrefs.SetInt("total_number_of_stages_in_the_game", total_number_of_stages_in_the_game); for (int i = 0; i < number_of_save_profile_slot_avaibles; i++) { all_stages_solved[i] = false; PlayerPrefs.SetInt("all_stages_solved",Convert.ToInt32(all_stages_solved[i])); } Load(current_profile_selected); } else //you have remove stages from last time { if (show_debug_messages) Debug.Log("there are less stages that in the previous save data"); //delete the old data Erase_saves(); for (int i = 0; i < number_of_save_profile_slot_avaibles; i++) { world_playable[i][0] = true; stage_playable[i][0,0] = true; Save(i); } } } else //I can't find the last profile used { //so ask to select/create a profile show_new_profile_window = true; } } } else //no save data, so start the game from zero { current_profile_selected = 0; if (number_of_save_profile_slot_avaibles == 1) //if no multiple profiles are allowed, start new game { if (show_debug_messages) Debug.Log("no save data and only one profile slot allowed"); Create_new_profile("Player"); } //else request to activate a new empty profile if (show_debug_messages) Debug.Log("no save data and multi profile slot allowed"); show_new_profile_window = true; } } else { //this avoid duplication of this istance Destroy(this.gameObject); } }