예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (status == health_status.infected)
        {
            int curTime = gameManager.GetCurTime();
            incubationT = curTime - infectedTimeStamp;
            if (incubationT == normIncubationT)
            {
                Debug.Log("Going to hospital");
                if (Random.Range(0.0f, 1.0f) < goForTestP)
                {
                    if (agentMoveScript.status == all_states.atHome)
                    {
                        agentMoveScript.SetOnRoad(agentMoveScript.house_startRoad, agentMoveScript.house_x, agentMoveScript.house_z, hospitalScript.addressOnRoad.x, hospitalScript.addressOnRoad.z);
                    }
                    else if (agentMoveScript.status == all_states.atWorkPlace)
                    {
                        agentMoveScript.SetOnRoad(agentMoveScript.workplace_startRoad, agentMoveScript.workplace_x, agentMoveScript.workplace_z, hospitalScript.addressOnRoad.x, hospitalScript.addressOnRoad.z);
                    }
                    else
                    {
                        agentMoveScript.SetOnRoad(agentMoveScript.curRoad, transform.position.x, transform.position.z, hospitalScript.addressOnRoad.x, hospitalScript.addressOnRoad.z);
                    }
                }
            }
        }

        if (status == health_status.detected)
        {
            int curTime    = gameManager.GetCurTime();
            int treatmentT = curTime - detectedTimeStamp;
            if (treatmentT == normCureT)
            {
                if (Random.Range(0.0f, 1.0f) < fatalityRate)
                {
                    status = health_status.dead;
                    houseManager.IncreToll();
                    Destroy(gameObject);
                }
                else
                {
                    status = health_status.recovered;
                    gameObject.GetComponent <MeshRenderer>().material = blue;
                    houseManager.IncreRecovered();
                    agentMoveScript.SetOnRoad(hospitalScript.nearestRoad, hospitalScript.addressOnRoad.x, hospitalScript.addressOnRoad.z, agentMoveScript.house_x, agentMoveScript.house_z);
                }
            }
        }

        if (gameManager.GetCurTime() % secPerHr == 0)
        {
            numOfContacts = normContactsPerHr;
        }
    }