コード例 #1
0
        public Town(TownData T)
        {
            id                 = T.ID;
            mayor              = T.Mayor;
            day                = T.Day;
            time               = T.Time;
            totalInfected      = T.TotalInfected;
            money              = T.Money;
            baseDetalHappiness = T.BaseDeltaHappiness;
            favoriteModifier   = T.FavoriteMaidifier;

            timer.Start();
            while (timer.ElapsedMilliseconds < T.ElapsedTime)
            {
                continue;                                               // Catches the timer back up to what it should be in game
            }
            timer.Stop();
            policyImplemented = T.PolicyImplementations;

            averageHappiness     = 0;
            policyImplementation = new Dictionary <int, bool>();
            essentials           = new Collection <Supermarket>();
            recreational         = new Collection <Building>();
            emergency            = new Collection <Hospital>();
            FileManagerSystem.LoadBuildings(this);
        }
コード例 #2
0
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        fSys = new FileManagerSystem();
        GridViewRow row = GridView1.SelectedRow;
        Guid ID = new Guid(row.Cells[4].Text);
        lblResult.Text = "You have selected: " + row.Cells[1].Text;

        Session.Remove("fid");
        Session.Add("fid", ID);
    }
コード例 #3
0
        public static void RunSaveProtocol()
        {
            for (int i = 0; i < Town.citizenThreads.Length; i++) // Closing citizen threads
            {
                Town.citizenThreads[i].Join();
            }

            for (int i = 0; i < Town.buildingThreads.Length; i++) // Closing building update threads
            {
                Town.buildingThreads[i].Join();
            }

            // Note that all threads need to be closed before saves can be made

            FileManagerSystem.SaveCitizens(town, CitizenWorkerThread.citizens);
            FileManagerSystem.SaveTown(town);
            FileManagerSystem.SaveBuildings(town);
        }
コード例 #4
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Guid id = (Guid)Session["fid"];
        fSys = new FileManagerSystem();
        string name, type;
        try
        {
            System.Data.SqlClient.SqlConnection conn = null;
            System.Data.SqlClient.SqlCommand selectCommand = null;
            try
            {
                conn = new System.Data.SqlClient.SqlConnection(SqlDataSource1.ConnectionString.ToString());
                conn.Open();
                selectCommand = new System.Data.SqlClient.SqlCommand("Select BLOB_NAME From OP_BLOB Where BLOB_ID = @ID", conn);
                selectCommand.Parameters.Add("ID", SqlDbType.VarChar).Value = id.ToString();
                name = (string)selectCommand.ExecuteScalar();

                selectCommand = new System.Data.SqlClient.SqlCommand("Select BLOB_TYPE From OP_BLOB Where BLOB_ID = @ID", conn);
                selectCommand.Parameters.Add("ID", SqlDbType.VarChar).Value = id.ToString();
                type = (string)selectCommand.ExecuteScalar();

                selectCommand = new System.Data.SqlClient.SqlCommand("Select BLOB_CONTENT From OP_BLOB Where BLOB_ID = @ID", conn);
                selectCommand.Parameters.Add("ID", SqlDbType.VarChar).Value = id.ToString();
                Byte[] content = (Byte[])selectCommand.ExecuteScalar();

                if (content != null)
                {
                    download(content, name, type);
                }
                #region Catch Shit
            }
            catch (Exception ex)
            {
                lblResult.Text = "Error: " + ex.Message;
            }
        }
        catch (Exception ex)
        {
            lblResult.Text = "Error: " + ex.Message;
        }
                #endregion
    }
コード例 #5
0
        public void Start()
        {
            checkGameRules();
            TOWNREADY = false;
            loadCitizenTasks();
            string townID = "mainTown";

            town = FileManagerSystem.LoadTown(townID);
            if (town == null || ISNEWGAME)
            {
                Debug.Log("Save file does not exist. Generating new save files...");
            }
            town = new Town(townID); // If the save file doesn't exist, a new Town is constructed

            Debug.Log("Game is working");

            //town.Start(Version, numCitizenThreads); // Town generation happens here (Stuff like loading town's
            TOWNREADY = true;
            GAMESTART = true;
            town.Start(Version, numCitizenThreads);
            Building.buildingTimer.Start();
            //town.startCitizenThreads();
        }
コード例 #6
0
        private void loadBuildings(Game.GameVersion version)
        {
            switch (version)
            {
            case Game.GameVersion.ReleaseLoad:
                HashSet <Building> buildings = FileManagerSystem.LoadBuildings(this);
                for (int i = 0; i < buildings.Count; i++)
                {
                    if (buildings.ElementAt(i).ID.Contains("recreational"))
                    {
                        recreational.Add(buildings.ElementAt(i));     // Have to pass the reference to the object
                    }
                    else if (buildings.ElementAt(i).ID.Contains("residential"))
                    {
                        residential.Add(buildings.ElementAt(i));
                    }
                }
                break;

            case Game.GameVersion.ReleaseNew:
                int numRecreational = 8;
                int numShops        = 17;
                int numHospitals    = 4;
                int numResidentials = 9;

                string id;
                for (int i = 0; i < numRecreational; i++)
                {
                    id = "recreational" + i;
                    Building b = new Building(id, Game.BASE_BUILDING_EXPOSURE_FACTOR + 5, 5000, 0, 0);
                    recreational.Add(b);
                }

                for (int i = 0; i < numShops; i++)
                {
                    id = "shop" + i;
                    Supermarket s = new Supermarket(id, Game.BASE_BUILDING_EXPOSURE_FACTOR, 100, 0, 20);
                    essentials.Add(s);
                }

                for (int i = 0; i < numHospitals; i++)
                {
                    id = "hospital" + i;
                    Hospital h = new Hospital(id, Game.BASE_BUILDING_EXPOSURE_FACTOR - 10, 5000, 0, 20, false);
                    emergency.Add(h);
                }

                for (int i = 0; i < numResidentials; i++)
                {
                    id = "residential" + i;
                    Building b = new Building(id, 0, 5000, 0, 3);
                    residential.Add(b);
                }
                break;

            case Game.GameVersion.Debug:
                Random r = new Random();

                Building    b1 = new Building("firstRes", 0, 35, 5000, 3);
                Hospital    h1 = new Hospital("firstHos", 35, 5000, 0, 30, false);
                Supermarket s1 = new Supermarket("firstSupwe", 35, 5000, 0, 20);
                Building    b2 = new Building("firstRec", 35, 35, 5000, 0);
                residential.Add(b1);
                emergency.Add(h1);
                essentials.Add(s1);
                recreational.Add(b2);
                for (int i = 0; i < 10; i++)
                {
                    int    buildingGenerator = r.Next(0, 3);
                    string buildingID        = "building" + 0;
                    if (buildingGenerator == 0)
                    {
                        Building b = new Building(buildingID, 35, 5000, 0, 0);
                        recreational.Add(b);
                    }
                    else if (buildingGenerator == 1)
                    {
                        Supermarket s = new Supermarket(buildingID, 35, 5000, 0, 20);
                        essentials.Add(s);
                    }
                    else if (buildingGenerator == 2)
                    {
                        Hospital h = new Hospital(buildingID, 35, 5000, 0, 30, false);
                        emergency.Add(h);
                    }
                    else if (buildingGenerator == 3)
                    {
                        Building b = new Building(buildingID, 0, 200, 0, 3);
                        residential.Add(b);
                    }
                }
                break;
            }
        }
コード例 #7
0
        private void initializeCitizens(Game.GameVersion version)
        {
            switch (version)
            {
            case Game.GameVersion.Debug:
                // Method that generates test citizens
                Random r = new Random();

                Stopwatch s = Stopwatch.StartNew();
                for (int i = 0; i < CITIZEN_START_COUNT_DEBUG; i++)     // Test citizens added to CitizenWorkerThread class
                {
                    int buildingType = r.Next(3);
                    CitizenWorkerThread.citizens.Add(new Citizen());
                    switch (buildingType)
                    {
                    case 0:
                        int recNum = r.Next(recreational.Count - 1);
                        CitizenWorkerThread.citizens[i].loadPreviousTask(1, 6, 13, 1, 1, 0, recreational[recNum]);
                        break;

                    case 1:
                        int essNum = r.Next(essentials.Count - 1);
                        CitizenWorkerThread.citizens[i].loadPreviousTask(1, 6, 13, 1, 1, 0, essentials[essNum]);
                        break;

                    case 2:
                        int emerNum = r.Next(emergency.Count - 1);
                        CitizenWorkerThread.citizens[i].loadPreviousTask(1, 6, 13, 1, 1, 0, emergency[emerNum]);
                        break;

                    case 3:
                        int resNum = r.Next(residential.Count - 1);
                        CitizenWorkerThread.citizens[i].loadPreviousTask(1, 6, 13, 1, 1, 0, residential[resNum]);
                        break;
                    }
                }
                int infected = r.Next(CITIZEN_START_COUNT - 1);
                CitizenWorkerThread.citizens[infected].rollHealthEvent(100);
                for (int i = 0; i < CITIZEN_START_COUNT_DEBUG; i++)
                {
                    CitizenWorkerThread.citizens[i].initiateTask();
                }
                s.Stop();
                break;

            // Case where we're loading an old save
            case Game.GameVersion.ReleaseLoad:
                Collection <Citizen> citizens = FileManagerSystem.LoadCitizens(this);
                if (citizens == null)
                {
                    Debug.Log("This game is trash. A town manager without any civilians? HAH! Get me out");
                    Application.Quit();
                    return;
                }
                CitizenWorkerThread.citizens = citizens;
                for (int i = 0; i < CITIZEN_START_COUNT; i++)
                {
                    CitizenWorkerThread.citizens[i].initiateTask();
                }
                break;

            // Case where we're creating a new save
            case Game.GameVersion.ReleaseNew:
                for (int i = 0; i < CITIZEN_START_COUNT; i++)
                {
                    CitizenWorkerThread.citizens.Add(new Citizen());    // Citizen is generated here. Need to figure out how to generate the citizen's tasks though
                }
                Random random = new Random();
                for (int i = 0; i < 25; i++)
                {
                    int infectedNew = random.Next(CitizenCount - 1);
                    CitizenWorkerThread.citizens[infectedNew].rollHealthEvent(100);
                }

                for (int i = 0; i < CITIZEN_START_COUNT; i++)
                {
                    CitizenWorkerThread.citizens[i].initiateTask();
                }
                break;
            }
        }