Beispiel #1
0
    public void AssumeEmergency()
    {
        SendAmbulance(myERC.WorstMedicalEmergency());
        myERC.SendAmbulance(this);
        myEmergency.SendResources(1, 0);

        if (myEmergency.NeededAmbulances() < 1)
        {
            myERC.MedicalEmergencyControlled(myEmergency);
        }
    }
Beispiel #2
0
    public void AssumeEmergency()
    {
        SendFiretruck(myERC.WorstDisasterEmergency());
        myERC.SendFiretruck(this);
        myEmergency.SendResources(0, 1);

        if (myEmergency.NeededFiretrucks() < 1 || myEmergency.GetEmergencyDisasterLife() > 250)
        {
            myERC.DisasterEmergencyControlled(myEmergency);
        }
    }
Beispiel #3
0
    private void sendRandomResources(Emergency medEm, Emergency disEm)
    {
        if ((availableAmbulances > 0 || Multiple) && medEm != null)
        {
            int ambulancesNeeded = Random.Range(0, availableAmbulances + 1);
            ambulancesNeeded = Mathf.Min(ambulancesNeeded, availableAmbulances);

            for (int i = 0; i < ambulancesNeeded; i++)
            {
                Ambulance am = ambulances[0]; // CreateAmbulance();
                ambulances.RemoveAt(0);
                am.SendAmbulance(medEm);
                availableAmbulances--;
            }

            if (ambulancesNeeded > 0)
            {
                medEm.SendResources(ambulancesNeeded, 0);
                MedicalEmergenciesWaiting.Remove(medEm);
                if (!EmergenciesBeingTreated.Contains(medEm))
                {
                    EmergenciesBeingTreated.Add(medEm);
                }
            }
        }

        if ((availableFiretrucks > 0 || Multiple) && disEm != null)
        {
            int firetrucksNeeded = Random.Range(0, availableFiretrucks + 1);
            firetrucksNeeded = Mathf.Min(firetrucksNeeded, availableFiretrucks);

            for (int i = 0; i < firetrucksNeeded; i++)
            {
                Firetruck am = firetrucks[0]; // CreateFiretruck();
                firetrucks.RemoveAt(0);
                am.SendFiretruck(disEm);
                availableFiretrucks--;
            }

            if (firetrucksNeeded > 0)
            {
                disEm.SendResources(0, firetrucksNeeded);
                DisasterEmergenciesWaiting.Remove(disEm);
                if (!EmergenciesBeingTreated.Contains(disEm))
                {
                    EmergenciesBeingTreated.Add(disEm);
                }
            }
        }
    }
Beispiel #4
0
    private void SendResources(Emergency medEm, Emergency disEm)
    {
        if ((availableAmbulances > 0 || Multiple) && medEm != null)
        {
            int ambulancesNeeded = (int)Math.Ceiling((float)medEm.GetEmergencyPeopleEnvolved() / Ambulance.maxPeople);

            if (Multiple)
            {
                int ambulancesRemaining = Mathf.Max(ambulancesNeeded - availableAmbulances, 0);
                if (ambulancesRemaining > 0)
                {
                    CommunicationSystem.needMedHelp(medEm, ambulancesRemaining);
                }
            }


            ambulancesNeeded = Mathf.Min(ambulancesNeeded, availableAmbulances);


            for (int i = 0; i < ambulancesNeeded; i++)
            {
                Ambulance am = ambulances[0]; // CreateAmbulance();
                ambulances.RemoveAt(0);
                am.SendAmbulance(medEm);
                availableAmbulances--;
            }

            medEm.SendResources(ambulancesNeeded, 0);
            MedicalEmergenciesWaiting.Remove(medEm);
            if (!EmergenciesBeingTreated.Contains(medEm))
            {
                EmergenciesBeingTreated.Add(medEm);
            }
        }

        if ((availableFiretrucks > 0 || Multiple) && disEm != null)
        {
            int firetrucksNeeded = (int)Math.Ceiling((float)disEm.GetEmergencyDisasterLife() / Firetruck.waterDeposit);

            if (Multiple)
            {
                int firetrucksRemaining = Mathf.Max(firetrucksNeeded - availableFiretrucks, 0);
                if (firetrucksRemaining > 0)
                {
                    CommunicationSystem.needFireHelp(disEm, firetrucksRemaining);
                }
            }

            firetrucksNeeded = Mathf.Min(firetrucksNeeded, availableFiretrucks);

            for (int i = 0; i < firetrucksNeeded; i++)
            {
                Firetruck am = firetrucks[0]; // CreateFiretruck();
                firetrucks.RemoveAt(0);
                am.SendFiretruck(disEm);
                availableFiretrucks--;
            }

            disEm.SendResources(0, firetrucksNeeded);
            DisasterEmergenciesWaiting.Remove(disEm);
            if (!EmergenciesBeingTreated.Contains(disEm))
            {
                EmergenciesBeingTreated.Add(disEm);
            }
        }
    }