コード例 #1
0
ファイル: ERCAgent.cs プロジェクト: ana3A/aasma
    private Firetruck CreateFiretruck()
    {
        Vector3 pos = this.transform.position;

        pos.y = 1;
        GameObject ft = Instantiate(FiretruckObject, pos, Quaternion.Euler(new Vector3(0f, 0f, 0f)));
        Firetruck  f  = ft.GetComponent <Firetruck>();

        f.myERC         = this;
        f.Decentralized = Decentralized;
        return(f);
    }
コード例 #2
0
ファイル: ERCAgent.cs プロジェクト: ana3A/aasma
    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);
                }
            }
        }
    }
コード例 #3
0
        //
        // GET: /Chapter4/
        public ActionResult Index()
        {
            Firetruck truckOne = new Firetruck();
            //隊員
            Firefighter joe = new Firefighter() { Name = "Joe" };
            Firefighter frank = new Firefighter() { Name = "Frank" };
            //隊長,繼承Firefighter
            FireChief bigChiefHarry = new FireChief() { Name = "Harry"};
            //
            truckOne.Driver = bigChiefHarry;
            bigChiefHarry.Drive(truckOne, new Point(100, 300));
            bigChiefHarry.TellFirefighterToExtinguishFire(joe);
            //return Content(bigChiefHarry.ExtinguishFire());
            //
            //取代Base Class裡的ExtinguishFire方法
            FireChief harry = new FireChief() { Name = "Harry", NumberOne = joe };

            return Content(harry.ExtinguishFire());
        }
コード例 #4
0
ファイル: ERCAgent.cs プロジェクト: ana3A/aasma
    private void SendHelp(Emergency helpMedEm, Emergency helpDisEm)
    {
        if (Multiple)
        {
            if (availableAmbulances > (nAmbulances / 2))
            {
                Emergency emh;
                bool      helping;
                CommunicationSystem.checkMedHelps(this, out helping, out emh);
                if (helping)
                {
                    //Debug.Log(this + "borrowed ambulance to" + emh.MyArea);
                    Ambulance am = ambulances[0];
                    ambulances.RemoveAt(0);
                    am.SendAmbulance(emh);
                    availableAmbulances--;
                    emh.SendResources(1, 0);
                }
            }

            if (availableFiretrucks > (nFiretruck / 2))
            {
                Emergency emh;
                bool      helping;
                CommunicationSystem.checkFireHelps(this, out helping, out emh);
                if (helping)
                {
                    //Debug.Log(this + "borrowed firetruck to" + emh.MyArea);
                    Firetruck am = firetrucks[0];
                    firetrucks.RemoveAt(0);
                    am.SendFiretruck(emh);
                    availableFiretrucks--;
                    emh.SendResources(0, 1);
                }
            }
        }
    }
コード例 #5
0
ファイル: ERCAgent.cs プロジェクト: ana3A/aasma
 public void SendFiretruck(Firetruck f)
 {
     this.availableFiretrucks--;
     firetrucks.Remove(f);;
 }
コード例 #6
0
ファイル: ERCAgent.cs プロジェクト: ana3A/aasma
 public void ReturnFiretruck(Firetruck f)
 {
     this.availableFiretrucks++;
     firetrucks.Add(f);
 }
コード例 #7
0
ファイル: ERCAgent.cs プロジェクト: ana3A/aasma
    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);
            }
        }
    }
コード例 #8
0
 public MainWindow()
 {
     InitializeComponent();
     fr          = new Firetruck();
     DataContext = fr;
 }
コード例 #9
0
 public override bool TreatEmergency(Firetruck f)
 {
     DevastationLife -= Firetruck.damage;
     return(true);
 }
コード例 #10
0
ファイル: Emergency.cs プロジェクト: ana3A/aasma
 public virtual bool TreatEmergency(Firetruck f)
 {
     return(false);
 }
コード例 #11
0
 public void Drive(Firetruck truckToDrive, Point coordinates)
 {
     if (truckToDrive.Driver != this)
     {
         return;
     }
     truckToDrive.Drive(coordinates);
 }