Exemple #1
0
    // Start is called before the first frame update
    void Start()
    {
        SimulationModelInit();

        houseManager    = GameObject.Find("Residence").GetComponent <HouseManager>();
        gameManager     = GameObject.Find("Game Manager").GetComponent <GameManager>();
        strategy        = GameObject.Find("Game Manager").GetComponent <Strategy>();
        hospitalManager = GameObject.Find("Hospitals").GetComponent <HospitalManager>();
        agentMoveScript = GetComponent <AgentMove>();

        int randHospitalIdx = Random.Range(0, hospitalManager.hospitals.Count);

        hospitalToGo   = hospitalManager.hospitals[randHospitalIdx];
        hospitalScript = hospitalToGo.GetComponent <Hospital>();

        if (Random.Range(0.0f, 1.0f) < initalInfectedRate)
        {
            status = health_status.infected;
            GetComponent <MeshRenderer>().material = orange;
            infectedTimeStamp = 0;
            houseManager.IncreInfected();
        }
        else
        {
            status = health_status.healthy;
        }

        sympOnsetTime = Random.Range(5, 10);
    }
Exemple #2
0
    void OnTriggerEnter(Collider other)
    {
        if (!other.gameObject.CompareTag("Person"))
        {
            return;
        }

        if (numOfContacts > 0)
        {
            numOfContacts--;
        }
        else
        {
            return;
        }

        if (status != health_status.healthy)
        {
            return;
        }

        health_status other_status = other.gameObject.GetComponent <Health>().status;

        if (other_status == health_status.infected || other_status == health_status.detected)
        {
            if (strategy.HasPutOnMask())
            {
                infectionP = normInfectionPWithMask;
            }
            else
            {
                infectionP = normInfectionP;
            }

            if (Random.Range(0.0f, 1.0f) < infectionP)
            {
                status = health_status.infected;
                gameObject.GetComponent <MeshRenderer>().material = orange;
                infectedTimeStamp = gameManager.GetCurTime();
                houseManager.IncreInfected();
            }
        }
    }