Beispiel #1
0
    // +--------------+-------------------------------------------------------------------------------------------------------------------------------------------
    // | Display Data |
    // +--------------+                                                         COULD USE SOME SIMPLIFICATION

    void SetDisplayData(string label)
    {
        List <float> points     = null;
        int          startPoint = 0;

        if (label.ToLower() == "budget")
        {
            // Get the budget list
            points = GameControllerScript.budgetList;
        }
        else if (label.Length == 1 || label.Substring(0, 9).ToLower() == "treatment")
        {
            // Set the treatment name
            treatmentName = (label.Length == 1) ? label : label.Split(' ')[1];

            TreatmentScript script = GameObject.Find("Treatment" + treatmentName).GetComponent <TreatmentScript>();
            startPoint = script.startingUpdate;

            // Get the efficacyList of the treatment we are looking at
            points = script.efficacyList;
        }
        else if (label.ToLower() == "total population")
        {
            // Get the total population list
            points = GameControllerScript.totalPopList;
        }
        else if (label.Substring(0, 10).ToLower() == "population")
        {
            // Get the population list we are looking at
            points = (label.Substring(11, 2).ToLower() == "un") ?
                     GameControllerScript.uninfectedPopList : GameControllerScript.infectedPopList;
        }

        if (points != null)
        {
            // Add the points to the graphInfo
            int index = startPoint;
            foreach (float p in points)
            {
                if (index >= displayData.Length)
                {
                    break;
                }
                displayData[index] = p;
                index++;
            }
        }
        else
        {
            for (int i = 0; i < totalUpdates; i++)
            {
                displayData[i] = i;
            }
        }
    }
Beispiel #2
0
    // Called when a person visits a hospital using this treatment as the first dose
    void DoubleTreatAuto(GameObject[] param)
    {
        GameObject      person     = param[0];
        TreatmentScript treatment2 = param[1].GetComponent <TreatmentScript>();

        // Use both of the treatments
        int firstSuccess  = OnTreat(person, false, false);
        int secondSuccess = treatment2.OnTreat(person, false, false);

        // Check if the first treatment succeeded
        if (firstSuccess != 1)
        {
            // Check if the second treatment succeeded
            if (secondSuccess != 1)
            {
                int strain  = person.GetComponent <PersonBehaviourScript>().strainNumber;
                int mutated = 0;

                // The disease might mutate
                if (firstSuccess != 2 && Random.value < 0.5f)
                {
                    // Mutate resistance against the first treatment

                    mutated = NextStrain(strain, person);
                    if (mutated != 0)
                    {
                        resistantStrain = (mutated == 2) ? strain + 1 : resistantStrain;
                    }
                }
                else if (secondSuccess != 2)
                {
                    // Mutate resistance against the second treatment

                    mutated = treatment2.NextStrain(strain, person);
                    if (mutated != 0)
                    {
                        treatment2.resistantStrain = (mutated == 2) ? strain + 1 : treatment2.resistantStrain;
                    }
                }
            }
        }
    }
    // Adds the new treatment to the game
    void AddTreatment(string treatmentName)
    {
        // Create a new inactive toggle
        GameObject newToggle = Instantiate(togglePrefab);

        // Set the script variables
        TreatmentScript script = newToggle.GetComponent <TreatmentScript>();

        script.treatmentName   = treatmentName;
        script.cost            = newTreatment.cost;
        script.chanceOfSuccess = newTreatment.efficacy;
        script.startingUpdate  = GameControllerScript.totalUpdates;
        script.mouseAttach     = GameObject.Find("MouseAttach").gameObject;

        // Set the toggle properties
        newToggle.transform.name = "Treatment" + treatmentName;
        newToggle.transform.SetParent(treatmentToggles.transform, false);
        newToggle.GetComponent <Toggle>().group = treatmentToggles.GetComponent <ToggleGroup>();

        // Create a new management menu button
        int numButtons = 0;

        foreach (Transform menuButton in treatmentMenu.transform)
        {
            numButtons++;
        }

        // Reset newTreatment
        newTreatment = null;
        GameControllerScript.newTreatment = null;
        gameObject.SetActive(false);

        // Open the treatment data window for the new treatment
        transform.parent.SendMessage(
            "OpenTreatmentData",
            transform.parent.GetComponent <CenterWindowScript>().InstantiateMenuButton(treatmentName, numButtons, false)
            );
    }
    public void AddData()
    {
        GameControllerScript gc = GameObject.Find("Game Controller").GetComponent <GameControllerScript>();

        Debug.Log("AddData called: Day " + gc.TOTALUPDATES / 10);

        this.day.Add(gc.TOTALUPDATES / 10);
        this.population.Add(GameControllerScript.totalPopulation);
        this.budget.Add(GameControllerScript.budget);
        this.healthy.Add(GameControllerScript.numUninfected);
        this.sick.Add(GameControllerScript.totalPopulation - GameControllerScript.numUninfected);
        this.dailyIncome.Add(GameControllerScript.dailyIncome);

        TreatmentScript trtA       = GameObject.Find("TreatmentA").GetComponent <TreatmentScript>();
        TreatmentScript trtB       = GameObject.Find("TreatmentB").GetComponent <TreatmentScript>();
        TreatmentScript trtC       = GameObject.Find("TreatmentC").GetComponent <TreatmentScript>();
        int             trtATreats = trtA.dailyTreated;
        int             trtBTreats = trtB.dailyTreated;
        int             trtCTreats = trtC.dailyTreated;

        int totalTreats = trtATreats + trtBTreats + trtCTreats;

        this.trtANum.Add(trtATreats);
        this.trtBNum.Add(trtBTreats);
        this.trtCNum.Add(trtCTreats);


        this.curedA.Add(trtA.dailySuccesses);
        this.curedB.Add(trtB.dailySuccesses);
        this.curedC.Add(trtC.dailySuccesses);

        this.trtAPercent.Add(totalTreats == 0 ? 0.0 : trtATreats / totalTreats);
        this.trtBPercent.Add(totalTreats == 0 ? 0.0 : trtBTreats / totalTreats);
        this.trtCPercent.Add(totalTreats == 0 ? 0.0 : trtCTreats / totalTreats);

        this.curedDay.Add(trtA.successes + trtB.successes + trtC.successes);

        if (this.newSick.Count == 0)
        {
            this.newSick.Add(GameControllerScript.totalPopulation - GameControllerScript.numUninfected);
        }
        else
        {
            this.newSick.Add((GameControllerScript.totalPopulation - GameControllerScript.numUninfected) - this.newSick[this.newSick.Count - 1]);
        }

        int costA = trtA.dailyTreated * trtA.cost;
        int costB = trtB.dailyTreated * trtB.cost;
        int costC = trtC.dailyTreated * trtC.cost;

        this.costTrtA.Add(costA);
        this.costTrtB.Add(costB);
        this.costTrtC.Add(costC);

        this.costDay.Add(costA + costB + costC + GameControllerScript.totalSpentOnResearch);

        this.sickCost.Add(GameControllerScript.sickPenalty);

        if (this.costResearch.Count == 0)
        {
            this.costResearch.Add(GameControllerScript.totalSpentOnResearch);
        }
        else
        {
            this.costResearch.Add(GameControllerScript.totalSpentOnResearch - this.costResearch[this.costResearch.Count - 1]);
        }

        count++;
    }
Beispiel #5
0
    // +----------------+-----------------------------------------------------------------------------------------------------------------------------------------
    // | Get Point Data |
    // +----------------+                                                       COULD USE SOME SIMPLIFICATION

    // Gets the list of points for the given axis label
    List <float> GetPoints(string label)
    {
        List <float> points = null;

        if (label.ToLower() != "time")
        {
            if (label.ToLower() == "budget")
            {
                // The player is viewing the budget
                // Get the budget list
                List <float> budget = GameControllerScript.budgetList;

                // Get the max value
                float max = budget[0];
                foreach (float b in budget)
                {
                    if (b > max)
                    {
                        max = b;
                    }
                }

                // Divide everything by the max and multiply by 100 for percents
                points = new List <float>();
                foreach (float b in budget)
                {
                    points.Add(b / max * 100);
                }
            }
            else if (label.Length == 1 || label.Substring(0, 9).ToLower() == "treatment")
            {
                // The player is viewing a treatment
                // Set the treatment name
                treatmentName = (label.Length == 1) ? label : label.Split(' ')[1];

                TreatmentScript script = GameObject.Find("Treatment" + treatmentName).GetComponent <TreatmentScript>();

                // Default the first treatment.startingUpdate spots in the points to 0
                points = new List <float>();
                for (int i = 0; i < script.startingUpdate; i++)
                {
                    points.Add(0);
                }

                // Get the efficacyList of the treatment we are looking at
                foreach (float f in script.efficacyList)
                {
                    points.Add(f);
                }
            }
            else if (label.ToLower() == "total population")
            {
                // The player is viewing the total population
                // Get the total population list
                List <float> pop = GameControllerScript.totalPopList;

                // Get the max value
                float max = pop[0];
                foreach (float p in pop)
                {
                    if (p > max)
                    {
                        max = p;
                    }
                }

                // Divide everything by the max and multiply by 100 for percents
                points = new List <float>();
                foreach (float p in pop)
                {
                    points.Add(p / max * 100);
                }
            }
            else if (label.Substring(0, 10).ToLower() == "population")
            {
                // The player is viewing a different population
                // Get the population list we are looking at
                points = (label.Substring(11, 2).ToLower() == "un") ?
                         GameControllerScript.uninfectedPopList : GameControllerScript.infectedPopList;
            }
        }

        return(points);
    }