Beispiel #1
0
    //load existing game
    public static void load()
    {
        clear_out();
        current_day                = SaveGame.Load <int>("current_day");
        seconds_since_start        = SaveGame.Load <float>("second_since_start");
        min_energy_needs           = SaveGame.Load <int>("min_energy_needs");
        current_energy_needs       = SaveGame.Load <int>("current_energy_needs");
        added_energy_needs         = SaveGame.Load <int>("added_energy_needs");
        min_energy_increase_amount = SaveGame.Load <int>("min_energy_increase_amount");
        min_energy_increase_time   = SaveGame.Load <int>("min_energy_increase_time");
        current_popularity         = SaveGame.Load <double>("current_popularity");
        energy_pop_min             = SaveGame.Load <double>("energy_pop_min");
        energy_pop_max             = SaveGame.Load <double>("energy_pop_min");
        co2_pop_min                = SaveGame.Load <double>("co2_pop_min");
        co2_pop_max                = SaveGame.Load <double>("co2_pop_min");
        total_money                = SaveGame.Load <int>("total_money");

        world_energy_production = SaveGame.Load <int>("world_energy_production");
        world_co2_production    = SaveGame.Load <int>("co2_energy_production");
        world_co2_total         = SaveGame.Load <int>("world_co2_total");

        energy_restrictions = SaveGame.Load <Dictionary <string, float> >("energy_restrictions");
        regions             = SaveGame.Load <Dictionary <string, Region> >("regions");
        research_levels     = SaveGame.Load <Dictionary <string, int> >("research_levels");

        player_lost     = false;
        player_won      = false;
        is_time_passing = true;
        can_policy      = true;

        //create new money drop timer
        add_new_money_timer();

        //create new min energy increse timer
        add_new_energy_increase_timer();

        //create first disater timer
        Disaster.add_disaster_timer();

        //update energy, co2 and other important varriables
        update_world();

        //loads main scene
        SceneManager.LoadScene("MainScene");
    }
Beispiel #2
0
    //runs when start buttton is clicked
    //reset variables, add starting timers and loads main screen
    static public void start_game()
    {
        Debug.Log("starting");
        clear_out();
        //sets up game when start is pressed

        //reset all changing
        current_day         = 0;
        seconds_since_start = 0;
        is_time_passing     = true;

        min_energy_needs     = 0;
        current_energy_needs = 0;
        added_energy_needs   = 0;

        min_energy_increase_time   = 10;
        min_energy_increase_amount = 3;

        current_popularity      = 0.8;
        Research.toggles_active = true;
        energy_pop_min          = 0.2;
        co2_pop_min             = 0.3;
        energy_pop_max          = 0.5;
        co2_pop_max             = 0.5;

        player_lost = false;
        player_won  = false;

        world_co2_production    = 0;
        world_energy_production = 0;
        world_co2_total         = 0;

        can_policy = true;

        //reset energy_restriction dictionary
        energy_restrictions.Clear();
        foreach (string i in energy_names)
        {
            for (int n = 1; n < 4; n++)
            {
                string restriction_name = i + "/" + n.ToString();
                energy_restrictions.Add(restriction_name, 1);
            }
        }

        //set staring money to be just enough to build a coal plant
        total_money = energy_research_cost["Coal"][0] + energy_build_cost["Coal"][1];

        //create new money drop timer
        add_new_money_timer();

        //create new min energy increse timer
        add_new_energy_increase_timer();

        //create first disater timer
        Disaster.add_disaster_timer();


        //creates region objects, intializes them, and adds them to region list
        regions.Clear();
        foreach (var i in region_names)
        {
            GameObject new_region_ob     = Instantiate(blank_region_object_copy);
            Region     new_region_script = new_region_ob.GetComponent <Region>();
            new_region_script.name          = i;
            new_region_script.advantage     = region_advantage[i];
            new_region_script.advantage_pts = advantage_pts;
            new_region_script.initalize(energy_names);
            regions.Add(i, new_region_script);
        }

        //reset research levels
        research_levels.Clear();
        foreach (string i in energy_names)
        {
            research_levels.Add(i, 0);
        }

        //start off with researching coal level 1
        research_levels["Coal"] = 1;

        //build starting energy
        for (int i = 0; i < starting_energy_plants; i++)
        {
            int    random_num  = Random.Range(0, region_names.Length);//get random index for region
            string region_name = region_names[random_num];
            buy_energy_plant("Coal", 1, region_name);
        }

        //update energy, co2 and other important varriables
        update_world();


        //loads main scene
        SceneManager.LoadScene("MainScene");
    }