private void Start()
        {
            noAgents = StaticContainerService.NoAgents - 1;
            //get the third person character (should never be null due to require component)
            agent               = GetComponent <NavMeshAgent>();
            m_Character         = GetComponent <ThirdPersonCharacter>();
            m_Model             = GetComponent <PhysiologicalModel>();
            timeSinceUpdate     = Time.time;
            timeSincePopulating = Time.time;
            agent.isStopped     = true;

            foodSpots = new List <Vector3>()
            {
                GameObject.Find("FoodSpot_0").transform.position,
                GameObject.Find("FoodSpot_1").transform.position
            };

            waterSpots = new List <Vector3>()
            {
                GameObject.Find("waterSpot_0").transform.position,
                GameObject.Find("waterSpot_1").transform.position
            };

            sleepSpots = new List <Vector3>()
            {
                GameObject.Find("sleepSpot_0").transform.position,
                GameObject.Find("sleepSpot_1").transform.position,
                GameObject.Find("sleepSpot_2").transform.position,
                GameObject.Find("sleepSpot_3").transform.position,
                GameObject.Find("sleepSpot_4").transform.position,
                GameObject.Find("sleepSpot_5").transform.position,
                GameObject.Find("sleepSpot_6").transform.position,
                GameObject.Find("sleepSpot_7").transform.position,
                GameObject.Find("sleepSpot_8").transform.position,
                GameObject.Find("sleepSpot_9").transform.position
            };

            sexSpots = new List <Vector3>()
            {
                GameObject.Find("sexSpot_0").transform.position,
                GameObject.Find("sexSpot_1").transform.position
            };

            toiletSpots = new List <Vector3>()
            {
                GameObject.Find("toiletSpot_0").transform.position,
                GameObject.Find("toiletSpot_1").transform.position
            };

            highSpots = new List <Vector3>()
            {
                GameObject.Find("highSpot_0").transform.position,
                GameObject.Find("highSpot_1").transform.position
            };

            agent.isStopped    = false;
            isPositionAcquired = false;
        }
Exemplo n.º 2
0
 private void GetNeeds(RaycastHit hitInfo)
 {
     characterPhysiologicalModel = hitInfo.transform.GetComponent <PhysiologicalModel>();
     charackterName.text         = hitInfo.transform.name;
     arrow = hitInfo.transform.GetComponent <Arrow>();
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        i++;
        if (i == 1000)
        {
            try
            {
                Directory.CreateDirectory(Application.dataPath + "/Data");
            }
            catch
            {
            }

            time     = 0;
            agents   = GameObject.FindGameObjectsWithTag("Agent");
            filePath = Application.dataPath + "/Data/" + "Needs_" + DateTime.Now.ToString("yyyyMMdd_HHmm") + ".csv";
            StreamWriter writer = new StreamWriter(filePath);
            writer.Close();
        }

        if (i > 1000)
        {
            int covidCounter = 0;
            int covidIllWithNoSypmtomsCounter = 0;
            int covidIllWithSypmtomsCounter   = 0;
            int covidSeriouslyIllCounter      = 0;

            IFormatProvider iFormatProvider = new System.Globalization.CultureInfo("en");

            if ((time += Time.deltaTime) >= 30)
            {
                try
                {
                    StreamWriter writer = new StreamWriter(filePath, true);

                    writer.WriteLine("#TIMESTAMP");
                    writer.WriteLine(DateTimeService.CurrentDateTime);

                    writer.WriteLine("#NEEDS");

                    foreach (GameObject agent in agents)
                    {
                        PhysiologicalModel need = agent.GetComponent <PhysiologicalModel>();
                        Covid covid             = agent.GetComponent <Covid>();
                        writer.WriteLine(String.Format(iFormatProvider, "{0:0.###}", need.FoodNeed.Value) + ","
                                         + String.Format(iFormatProvider, "{0:0.###}", need.WaterNeed.Value) + ","
                                         + String.Format(iFormatProvider, "{0:0.###}", need.DreamNeed.Value) + ","
                                         + String.Format(iFormatProvider, "{0:0.###}", need.LibidoNeed.Value) + ","
                                         + String.Format(iFormatProvider, "{0:0.###}", need.ToiletNeed.Value) + ","
                                         + String.Format(iFormatProvider, "{0:0.###}", need.HigherOrderNeeds.Value));

                        if (covid.Infected)
                        {
                            covidCounter++;
                        }
                        if (covid.CovidInfection.InfectionType == Assets.Scripts.Models.Enums.InfectionType.InfectedWithoutSymptoms)
                        {
                            covidIllWithNoSypmtomsCounter++;
                        }
                        if (covid.CovidInfection.InfectionType == Assets.Scripts.Models.Enums.InfectionType.InfectedWithSymptoms)
                        {
                            covidIllWithSypmtomsCounter++;
                        }
                        if (covid.CovidInfection.InfectionType == Assets.Scripts.Models.Enums.InfectionType.SeriouslyIll)
                        {
                            covidSeriouslyIllCounter++;
                        }
                    }

                    writer.WriteLine("#INFECTED");
                    writer.WriteLine(covidCounter.ToString());
                    writer.WriteLine("#INFECTED_NO_SYMPTOMS");
                    writer.WriteLine(covidIllWithNoSypmtomsCounter.ToString());
                    writer.WriteLine("#INFECTED_MILD_SYMPTOMS");
                    writer.WriteLine(covidIllWithSypmtomsCounter.ToString());
                    writer.WriteLine("#INFECTED_SERIOUSLY_ILL");
                    writer.WriteLine(covidSeriouslyIllCounter.ToString());
                    writer.WriteLine("");
                    writer.Flush();
                    writer.Close();
                }
                catch { }
                time = 0;
            }
        }
    }