Esempio n. 1
0
        //creates a number of instructors
        public static void CreateInstructors(int count)
        {
            List <Town> towns = Towns.GetTowns();

            Random rnd = new Random();

            for (int i = 0; i < count; i++)
            {
                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-Pilot.RetirementAge), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(), Names.GetInstance().getRandomLastName(), birthdate, town);

                Dictionary <Pilot.PilotRating, int> rankings = new Dictionary <Pilot.PilotRating, int>();
                rankings.Add(Pilot.PilotRating.A, 10);
                rankings.Add(Pilot.PilotRating.B, 20);
                rankings.Add(Pilot.PilotRating.C, 40);
                rankings.Add(Pilot.PilotRating.D, 20);
                rankings.Add(Pilot.PilotRating.E, 10);

                Pilot.PilotRating ranking = AIHelpers.GetRandomItem <Pilot.PilotRating>(rankings);

                Instructor instructor = new Instructor(profile, ranking);

                Instructors.AddInstructor(instructor);
            }
        }
Esempio n. 2
0
        //creates a number of pilots
        public static void CreatePilots(int count)
        {
            List <Town> towns = Towns.GetTowns();

            Random rnd = new Random();

            for (int i = 0; i < count; i++)
            {
                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-Pilot.RetirementAge), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(), Names.GetInstance().getRandomLastName(), birthdate, town);

                Dictionary <Pilot.PilotRating, int> rankings = new Dictionary <Pilot.PilotRating, int>();
                rankings.Add(Pilot.PilotRating.A, 10);
                rankings.Add(Pilot.PilotRating.B, 20);
                rankings.Add(Pilot.PilotRating.C, 40);
                rankings.Add(Pilot.PilotRating.D, 20);
                rankings.Add(Pilot.PilotRating.E, 10);

                Pilot.PilotRating ranking = AIHelpers.GetRandomItem <Pilot.PilotRating>(rankings);

                int fromYear = Math.Min(GameObject.GetInstance().GameTime.Year - 1, birthdate.AddYears(23).Year);
                int toYear   = Math.Min(GameObject.GetInstance().GameTime.Year, birthdate.AddYears(Pilot.RetirementAge).Year);

                DateTime educationTime = MathHelpers.GetRandomDate(birthdate.AddYears(23), new DateTime(toYear, 1, 1));
                Pilot    pilot         = new Pilot(profile, educationTime, ranking);

                Pilots.AddPilot(pilot);
            }
        }
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            Random rnd = new Random();

            ComboBox cbInstructor = new ComboBox();

            cbInstructor.SetResourceReference(ComboBox.StyleProperty, "ComboBoxTransparentStyle");
            cbInstructor.Width = 200;
            cbInstructor.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            cbInstructor.DisplayMemberPath   = "Profile.Name";
            cbInstructor.SelectedValuePath   = "Profile.Name";

            foreach (Instructor instructor in this.FlightSchool.Instructors.Where(i => i.Students.Count < FlightSchool.MaxNumberOfStudentsPerInstructor))
            {
                cbInstructor.Items.Add(instructor);
            }

            cbInstructor.SelectedIndex = 0;

            if (PopUpSingleElement.ShowPopUp(Translator.GetInstance().GetString("PanelFlightSchool", "1005"), cbInstructor) == PopUpSingleElement.ButtonSelected.OK && cbInstructor.SelectedItem != null)
            {
                List <Town> towns = Towns.GetTowns(this.FlightSchool.Airport.Profile.Country);

                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-55), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(), Names.GetInstance().getRandomLastName(), birthdate, town);

                PilotStudent student = new PilotStudent(profile, GameObject.GetInstance().GameTime, (Instructor)cbInstructor.SelectedItem);

                this.FlightSchool.addStudent(student);
                ((Instructor)cbInstructor.SelectedItem).addStudent(student);

                showStudents();

                this.ParentPage.updatePage();

                txtStudents.Text = this.FlightSchool.NumberOfStudents.ToString();

                double studentPrice = GeneralHelpers.GetInflationPrice(PilotStudent.StudentCost);

                int studentsCapacity = Math.Min(this.FlightSchool.Instructors.Count * FlightSchool.MaxNumberOfStudentsPerInstructor, this.FlightSchool.TrainingAircrafts.Sum(f => f.Type.MaxNumberOfStudents));

                btnHire.IsEnabled = studentsCapacity > this.FlightSchool.Students.Count && GameObject.GetInstance().HumanAirline.Money > studentPrice;

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -studentPrice);
            }
        }
        private void InitCampaign_Click(object sender, RoutedEventArgs e)
        {
            AllNations nation = (AllNations)comboBox.SelectedItem;

            PilotProfile       profile = new PilotProfile();
            PilotProfileReader preader;

            try
            {
                preader = new PilotProfileReader(profile, nation.Config);
                preader.ReadAll();
            }
            catch
            {
                profile.FirstName = "Black";
                profile.LastName  = "Raider";
                profile.Language  = "ENG";
                profile.Directory = @"missions\campaign\de\DGen_C_Lvov41doe0";
                profile.Campaigns.Add(new Campaigns()
                {
                    Name = "Lvov41", Plane = "BF_109F2"
                });
            }

            // TODO SetGlobal
            CampaignGenerator cgen = new CampaignGenerator();

            lstOutput.Items.Clear();

            lstOutput.Items.Add("Piloto: " + profile.FirstName + " " + profile.LastName);
            lstOutput.Items.Add("Dir: " + profile.Directory);
            lstOutput.Items.Add("Lang:" + profile.Language);

            //txtoutput.Text += "=======================================";
            foreach (Campaigns c in profile.Campaigns)
            {
                lstOutput.Items.Add("Campaña:" + c.Name + " - " + c.Plane);
            }

            cgen.MakeID(profile.Directory);
            cgen.Language       = profile.Language;
            cgen.InstantVictory = profile.Instant;

            //TODO Misc.ReadSettings -> CampaignsSettingsReader
        }
Esempio n. 5
0
        private void btnHire_Click(object sender, RoutedEventArgs e)
        {
            var aircraftsTypesFree = this.FlightSchool.Aircrafts.Select(a => a.Type);

            Dictionary <TrainingAircraftType, int> types = this.FlightSchool.Aircrafts.GroupBy(a => a.Type).
                                                           Select(group =>
                                                                  new
            {
                Type  = group.Key,
                Count = group.Sum(g => g.Type.MaxNumberOfStudents)
            }).ToDictionary(g => g.Type, g => g.Count);;


            foreach (PilotStudent student in this.FlightSchool.Students)
            {
                var firstAircraft = student.Rating.Aircrafts.OrderBy(a => a.TypeLevel).FirstOrDefault(a => types.ContainsKey(a) && types[a] > 0);

                if (firstAircraft != null && types.ContainsKey(firstAircraft))
                {
                    types[firstAircraft]--;
                }
            }

            List <PilotRating> possibleRatings = new List <PilotRating>();

            foreach (PilotRating rating in PilotRatings.GetRatings())
            {
                if (rating.Aircrafts.Exists(a => types.ContainsKey(a) && types[a] > 0))
                {
                    possibleRatings.Add(rating);
                }
            }

            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2811"), string.Format(Translator.GetInstance().GetString("MessageBox", "2811", "message")), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                List <Town> towns = Towns.GetTowns(this.FlightSchool.FlightSchool.Airport.Profile.Country);

                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-35), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(town.Country), Names.GetInstance().getRandomLastName(town.Country), birthdate, town);

                Instructor instructor     = (Instructor)cbInstructor.SelectedItem;
                string     airlinerFamily = cbTrainAircraft.SelectedItem.ToString();

                PilotStudent student = new PilotStudent(profile, GameObject.GetInstance().GameTime, instructor, GeneralHelpers.GetPilotStudentRating(instructor, possibleRatings), airlinerFamily);

                TrainingAircraft aircraft = getStudentAircraft(student);

                student.Aircraft = aircraft;

                this.FlightSchool.addStudent(student);
                instructor.addStudent(student);

                setHireStudentsStatus();

                double studentPrice = GeneralHelpers.GetInflationPrice(PilotStudent.StudentCost);

                AirlineHelpers.AddAirlineInvoice(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Airline_Expenses, -studentPrice);
            }
        }