示例#1
0
文件: Ambulance.cs 项目: ana3A/aasma
    private void TreatEmergency()
    {
        if (Decentralized && myEmergency.NAmbulances == 1 && peopleToTransport == maxPeople && myEmergency.GetEmergencyPeopleEnvolved() > 0)
        {
            onEmergency              = false;
            goingToERC               = true;
            myEmergency.NAmbulances -= 1;
            if (!myERC.MedicalEmergenciesWaiting.Contains(myEmergency))
            {
                myERC.MedicalEmergenciesWaiting.Add(myEmergency);
            }
            if (myEmergency.NFiretrucks <= 0)
            {
                myERC.EmergenciesBeingTreated.Remove(myEmergency);
            }
            return;
        }

        if (myEmergency.GetEmergencyPeopleEnvolved() < 1)
        {
            onEmergency              = false;
            goingToERC               = true;
            myEmergency.NAmbulances -= 1;
            if (Decentralized && myEmergency.NAmbulances <= 0 && myEmergency.NFiretrucks <= 0 && myEmergency.GetEmergencyDisasterLife() <= 0)
            {
                myERC.MedicalEmergenciesWaiting.Remove(myEmergency);
                myERC.DisasterEmergenciesWaiting.Remove(myEmergency);
                myERC.EmergencyEnded(myEmergency);
            }

            //else if (Decentralized && myEmergency.NAmbulances <= 0 && myEmergency.NFiretrucks <= 0 && myEmergency.GetEmergencyDisasterLife() >= 250)
            //{
            //    myERC.EmergencyImpossible(myEmergency);
            //}

            else if (Decentralized && myEmergency.NAmbulances <= 0 && myEmergency.NFiretrucks <= 0)
            {
                myERC.EmergenciesBeingTreated.Remove(myEmergency);
            }
            return;
        }

        if (peopleToTransport == maxPeople)
        {
            onEmergency              = false;
            goingToERC               = true;
            myEmergency.NAmbulances -= 1;
            return;
        }

        if (waitTime >= myEmergency.WaitTime)
        {
            if (myEmergency.TreatEmergency(this))
            {
                peopleToTransport++;
            }
            waitTime = 0;
        }

        else
        {
            waitTime += Time.deltaTime;
        }
    }
示例#2
0
文件: Firetruck.cs 项目: ana3A/aasma
    private void TreatEmergency()
    {
        if (Decentralized && myEmergency.NFiretrucks == 1 && curWaterDeposit <= 0 && myEmergency.GetEmergencyDisasterLife() > 0)
        {
            onEmergency              = false;
            goingToERC               = true;
            myEmergency.NFiretrucks -= 1;
            if (!myERC.DisasterEmergenciesWaiting.Contains(myEmergency))
            {
                myERC.DisasterEmergenciesWaiting.Add(myEmergency);
            }
            if (myEmergency.NAmbulances <= 0)
            {
                myERC.EmergenciesBeingTreated.Remove(myEmergency);
            }
            return;
        }

        if (myEmergency.GetEmergencyDisasterLife() <= 0)
        {
            onEmergency              = false;
            goingToERC               = true;
            myEmergency.NFiretrucks -= 1;
            if (Decentralized && myEmergency.NAmbulances <= 0 && myEmergency.NFiretrucks <= 0 && myEmergency.GetEmergencyPeopleEnvolved() < 1)
            {
                myERC.MedicalEmergenciesWaiting.Remove(myEmergency);
                myERC.DisasterEmergenciesWaiting.Remove(myEmergency);
                myERC.EmergencyEnded(myEmergency);
            }

            else if (Decentralized && myEmergency.NAmbulances <= 0 && myEmergency.NFiretrucks <= 0)
            {
                myERC.EmergenciesBeingTreated.Remove(myEmergency);
            }
            return;
        }

        if (myEmergency.GetEmergencyDisasterLife() >= 250)
        {
            onEmergency              = false;
            goingToERC               = true;
            myEmergency.NFiretrucks -= 1;
            if (Decentralized && myEmergency.NAmbulances <= 0 && myEmergency.NFiretrucks <= 0 && myEmergency.GetEmergencyPeopleEnvolved() < 1)
            {
                myERC.MedicalEmergenciesWaiting.Remove(myEmergency);
                myERC.DisasterEmergenciesWaiting.Remove(myEmergency);
                myERC.EmergencyImpossible(myEmergency);
            }
            else if (Decentralized && myEmergency.NFiretrucks <= 0)
            {
                myERC.DisasterEmergenciesWaiting.Add(myEmergency);
                if (myEmergency.NAmbulances <= 0)
                {
                    myERC.EmergenciesBeingTreated.Remove(myEmergency);
                }
            }
            return;
        }

        if (curWaterDeposit <= 0)
        {
            onEmergency              = false;
            goingToERC               = true;
            myEmergency.NFiretrucks -= 1;
            return;
        }

        if (waitTime >= myEmergency.WaitTime)
        {
            if (myEmergency.TreatEmergency(this))
            {
                curWaterDeposit -= damage;
            }
            waitTime = 0;
        }

        else
        {
            waitTime += Time.deltaTime;
        }
    }