private void ByBus_Click(object sender, RoutedEventArgs e) { transition = TransitionType.Bus; int transition_time = 3; int speed = 40000 / 60; //метров в минуту где 40000 скорость пешехода в метрах/ч, а 60 количество минут в часе int price = Convert.ToInt32(0.15 * GameEnvironment.Money.PlayerCurrency[0].Course); if (GameEnvironment.Player.House != null) { transition_time += Convert.ToInt32(Math.Floor(GameEnvironment.Player.House.Distance / (double)speed)); price += Convert.ToInt32(GameEnvironment.Player.House.Distance / 1000 * fare * GameEnvironment.Money.PlayerCurrency[0].Course); } if (GameMessageBox.Show("Оплата проезда", "Вы хотите купить билет за " + price + " " + GameEnvironment.Money.PlayerCurrency[0].Abbreviation + "?", GameMessageBox.MessageBoxType.ConfirmationWithYesNo) == MessageBoxResult.Yes) { if (!GameEnvironment.Money.PlayerCurrency[0].Withdraw("Оплата за проезд в автобусе", GameEnvironment.Player.Name, GameEnvironment.GameEvents.GameTimer.DateAndTime, price)) { GameMessageBox.Show("Оплата проезда", "У вас не хватает денег!", GameMessageBox.MessageBoxType.Information); return; } else { payment = true; } } else { payment = false; } Transition(transition_time); }
private void BuyButton_Click(object sender, RoutedEventArgs e) { if (GameEnvironment.Player.House == null) { GameMessageBox.Show("Покупка", "Вам негде это хранить, для начала обзаведитесь жильем.", GameMessageBox.MessageBoxType.Information); return; } Button button = sender as Button; if (button.Tag is BaseItem) { double price = (button.Tag as BaseItem).Price * GameEnvironment.Money.PlayerCurrency[0].Course; price += price / 100 * StorePercentage; if (price <= GameEnvironment.Money.PlayerCurrency[0].Count) { GameEnvironment.Money.PlayerCurrency[0].Withdraw("Оплата покупки: " + (button.Tag as BaseItem).Name, "Киоск с дисками", GameEnvironment.GameEvents.GameTimer.DateAndTime, price); CoinCount.Content = GameEnvironment.Money.PlayerCurrency[0].Count.ToString("N3") + " " + GameEnvironment.Money.PlayerCurrency[0].Abbreviation; if (button.Tag is OpticalDisc) { OpticalDisc opticalDisc = (button.Tag as OpticalDisc); GameEnvironment.Items.OpticalDiscs.Add(new OpticalDisc(opticalDisc.Uid, opticalDisc.Name, opticalDisc.GetTypeValue(), opticalDisc.Price, opticalDisc.ManufacturingDate, opticalDisc.Properties)); } SellerText.Text = "Спасибо за покупку " + (button.Tag as BaseItem).Name + ", держите свой компакт-диск!"; } else { SellerText.Text = "Извини, без денег я тебе его не отдам."; } } }
private void InstallProgram_Click(object sender, System.Windows.RoutedEventArgs e) { Button button = (sender as Button); if (!(button.Tag is Program)) { return; } program = (button.Tag as Program); for (int i = 0; GameEnvironment.Items.Programs.Count > i; i++) { if (GameEnvironment.Items.Programs[i].Uid == program.Uid) { GameMessageBox.Show("У вас уже установлена эта программа!"); return; } } InstallationProgress.Minimum = 0; InstallationProgress.Maximum = 100; InstallationProgress.Value = 0; InstallationName.Content = Properties.Resources.Installation + " " + program.Name; List.Visibility = Visibility.Collapsed; Install.Visibility = Visibility.Visible; int minutes = 1; GameEnvironment.GameEvents.Events.Add(new GameEvent("InstallProgram", GameEnvironment.GameEvents.GameTimer.DateAndTime.AddMinutes(minutes), Periodicity.Minute, minutes, InstallProgram, true)); }
private void CommunalPayment(GameEvent @event) { string[] keys = @event.Name.Split(new char[] { ':' }); List <PlayerTariff> tariffs = GameEnvironment.Services.PlayerTariffs.Where(t => t.Service.UId.ToString() == keys[0] & t.UId.ToString() == keys[1] & t.Amount.ToString() == keys[2]).ToList(); if (tariffs.Count == 1) { DateTime dateTime; if (tariffs[0].StartDateOfService.Year == GameEnvironment.GameEvents.GameTimer.DateAndTime.Year && tariffs[0].StartDateOfService.Month + 1 == GameEnvironment.GameEvents.GameTimer.DateAndTime.Month) { dateTime = tariffs[0].StartDateOfService; } else { dateTime = @event.ResponseTime.AddMonths(-1); } double sum = (GameEnvironment.GameEvents.GameTimer.DateAndTime - dateTime).TotalDays * tariffs[0].Amount; if (tariffs[0].Currency.Withdraw("Оплата коммунальных платежей", "Жилищно-коммунальное хозяйство", GameEnvironment.GameEvents.GameTimer.DateAndTime, sum) == false) { GameEnvironment.Scenario.GameOver("Вы не оплатили коммунальные платежи"); } } else { GameMessageBox.Show("Обработка выплат и взысканий", "Что-то пошло не так, тариф не найден!", GameMessageBox.MessageBoxType.Error); } }
private void RentalPayment(GameEvent @event) { string[] keys = @event.Name.Split(new char[] { ':' }); List <PlayerTariff> tariffs = GameEnvironment.Services.PlayerTariffs.Where(t => t.Service.UId.ToString() == keys[0] & t.UId.ToString() == keys[1] & t.Amount.ToString() == keys[2]).ToList(); if (tariffs.Count == 1) { DateTime dateTime; if (tariffs[0].StartDateOfService.Year == GameEnvironment.GameEvents.GameTimer.DateAndTime.Year && tariffs[0].StartDateOfService.Month + 1 == GameEnvironment.GameEvents.GameTimer.DateAndTime.Month) { dateTime = tariffs[0].StartDateOfService; } else { dateTime = @event.ResponseTime.AddMonths(-1); } double sum = (GameEnvironment.GameEvents.GameTimer.DateAndTime - dateTime).TotalDays * tariffs[0].Amount; if (tariffs[0].Currency.Withdraw("Выплата аренды", "Агенство недвижимости \"Крыша над головой\"", GameEnvironment.GameEvents.GameTimer.DateAndTime, sum) == false) { GameEnvironment.Player.House = null; GameEnvironment.GameEvents.Events.Remove(@event); GameEnvironment.Messages.NewMessage("Агенство недвижимости \"Крыша над головой\"", "Вы были выселены за неуплату аренды!", GameMessages.Icon.Info); } } else { GameMessageBox.Show("Обработка выплат и взысканий", "Что-то пошло не так, тариф не найден!", GameMessageBox.MessageBoxType.Error); } }
private void OpenDisc_Click(object sender, RoutedEventArgs e) { Button button = (sender as Button); var parent = FindParent <DockPanel>(button); if (parent == null) { return; } var child = GetChildOfType <ComboBox>(parent); if (child == null) { return; } if (child.Tag is OpticalDrive) { OpticalDisc opticalDisc = (child.Tag as OpticalDrive).Properties.OpticalDisc; if (opticalDisc == null) { return; } if (opticalDisc.Properties.Programs != null) { InstallSoft.Children.Clear(); InstallSoft.Children.Add(new MCInstallSoft(GameEnvironment, opticalDisc.Properties.Programs)); DevicesAndDrives.Visibility = Visibility.Collapsed; InstallSoft.Visibility = Visibility.Visible; } else { GameMessageBox.Show("Запуск с диска", "На этом диске нет программ!", GameMessageBox.MessageBoxType.Information); } } }
public void ProcessingServices(GameEvent @event) { string[] keys = @event.Name.Split(new char[] { ':' }); List <PlayerTariff> tariffs = GameEnvironment.Services.PlayerTariffs.Where(t => t.Service.UId.ToString() == keys[0] & t.UId.ToString() == keys[1] & t.Amount.ToString() == keys[2]).ToList(); if (tariffs.Count == 1) { PlayerTariff tariff = tariffs[0]; if (tariff.Service.Type == TransactionType.TopUp) { tariff.Currency.TopUp("Выплата по услуге \"" + tariff.Service.Name + "\" (" + tariff.Name + ")", Properties.Resources.BankName, GameEnvironment.GameEvents.GameTimer.DateAndTime, (tariff.Amount * tariff.Coefficient / 100)); if (DateTime.Compare(GetDateByPeriod(tariff.StartDateOfService, tariff.TermUnit, tariff.Term), @event.ResponseTime) <= 0) { GameEnvironment.GameEvents.Events.Remove(@event); GameEnvironment.Services.PlayerTariffs.Remove(tariff); tariff.Currency.TopUp("Возврат средств в связи с истечением периода оказания услуги \"" + tariff.Service.Name + "\" (" + tariff.Name + ")", Properties.Resources.BankName, GameEnvironment.GameEvents.GameTimer.DateAndTime, tariff.Amount); } } else if (tariff.Service.Type == TransactionType.Withdraw) { int per_s = GetNumberOfPeriods(tariff.Periodicity, tariff.PeriodicityValue, tariff.StartDateOfService, GetDateByPeriod(tariff.StartDateOfService, tariff.TermUnit, tariff.Term)); if (!tariff.Currency.Withdraw("Взыскание по услуге\"" + tariff.Service.Name + "\" (" + tariff.Name + ")", Properties.Resources.BankName, GameEnvironment.GameEvents.GameTimer.DateAndTime, (tariff.Amount + (tariff.Amount * tariff.Coefficient / 100) * tariff.Term) / per_s)) { if (tariff.PropertyPledged != null) { if (tariff.PropertyPledged is House) { GameEnvironment.Services.PlayerTariffs.Remove(GameEnvironment.Player.House.PlayerCommunalPayments); GameEnvironment.Player.House = null; GameEnvironment.Services.PlayerTariffs.Remove(tariff); GameEnvironment.GameEvents.Events.Remove(@event); GameEnvironment.Messages.NewMessage("Банк", "У вас изъяли недвижимость в связи с отсутствием средств для выплаты задолженности!", GameMessages.Icon.Info); } } else { GameEnvironment.Scenario.GameOver("Нет денег для выплаты по услуге \"" + tariff.Service.Name + "\" тарифный план \"" + tariff.Name + "\""); } } //ВЫЗОВ СОБЫТИЯ GAME_OVER если не хватает денег (Игрок банкрот), исключение если есть залог if (DateTime.Compare(GetDateByPeriod(tariff.StartDateOfService, tariff.TermUnit, tariff.Term), @event.ResponseTime) <= 0) { if (tariff.PropertyPledged != null) { if (tariff.PropertyPledged is House) { GameEnvironment.Player.House.IsPurchasedOnCredit = false; GameEnvironment.Player.House.IsPurchased = true; } } GameEnvironment.GameEvents.Events.Remove(@event); GameEnvironment.Services.PlayerTariffs.Remove(tariff); } } } else { GameMessageBox.Show("Обработка выплат и взысканий", "Что-то пошло не так, тариф не найден!", GameMessageBox.MessageBoxType.Error); } }
private void Formatting_Click(object sender, RoutedEventArgs e) { if (FileSystems.SelectedItem != null) { SelectedHDDPartition.Partition.FileSystem = (FileSystem)FileSystems.SelectedItem; GameMessageBox.Show("Форматирование", "Раздел успешно отформатирован в файловую систему " + (FileSystem)FileSystems.SelectedItem, GameMessageBox.MessageBoxType.Information); } }
private void SelectedComputerStart() { DiscPanel.Visibility = Visibility.Collapsed; OutputFromComputer.Visibility = Visibility.Visible; OutputFromComputer.Text = string.Empty; if (SelectedComputer != null) { if (SelectedComputer.IsEnable == true) { SelectedComputer.IsEnable = false; return; } ComputersList.IsEnabled = false; if (SelectedComputer.Case != null) { foreach (ErrorСodes errorCode in SelectedComputer.Diagnostics()) { if (errorCode == ErrorСodes.Ok) { if (SelectedComputer.Monitors.Count == 0) { GameMessageBox.Show("Запуск компьютера", "У вас нет монитора, это не критично для работы компьютера, но вам не начем будет посмотреть выводимую информацию.", GameMessageBox.MessageBoxType.Information); ComputersList.IsEnabled = true; } else { OutputFromComputer.Text += new BIOS().GetBIOSText(MotherboardBIOS.AMI) + Environment.NewLine + SelectedComputer.Motherboard.Name + " BIOS Date:" + GameEnvironment.GameEvents.GameTimer.DateAndTime.ToString("MM/dd/yy") + Environment.NewLine + "CPU : " + SelectedComputer.CPU.Name + " @ " + SelectedComputer.CPU.Properties.MinCPUFrequency + "MHz"; GameEnvironment.GameEvents.Events.Add(new GameEvent("", GameEnvironment.GameEvents.GameTimer.DateAndTime.AddHours(1), Periodicity.Hour, 1, LoadComputer)); SelectedComputer.IsEnable = true; } } else if (errorCode == ErrorСodes.NoCPUCooler && SelectedComputer.CPU != null) { if (SelectedComputer.Monitors.Count == 0) { GameMessageBox.Show("Запуск компьютера", "Без куллера на процесоре компьютер запуститься но процессор будет быстро перегреваться в результате чего компьютер будет быстро выключаться!", GameMessageBox.MessageBoxType.Information); } ComputersList.IsEnabled = true; } else { OutputFromComputer.Text += SelectedComputer.GetLocalizedErrorCode(errorCode) + Environment.NewLine; ComputersList.IsEnabled = true; } } } else { GameMessageBox.Show("Запуск компьютера", "Корпус отсутствует, а у вас к сожалению нет навыка включения компьютера без кнопки на корпусе!", GameMessageBox.MessageBoxType.Information); } } }
public void ShowBuilding(string obj) { switch (obj) { case "labor_exchange": if (GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour < 8 || GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour > 17 || GameEnvironment.GameEvents.GameTimer.DateAndTime.DayOfWeek == DayOfWeek.Saturday || GameEnvironment.GameEvents.GameTimer.DateAndTime.DayOfWeek == DayOfWeek.Sunday) { GameMessageBox.Show("Режим работы", "пн-пт 8:00 - 17:00 \n сб-вс выходной"); lastForm.Visibility = Visibility.Hidden; return; } NewWindow(new LaborExchange(GameEnvironment)); break; case "computer_parts_store": if (GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour < 9 || GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour > 18 || GameEnvironment.GameEvents.GameTimer.DateAndTime.DayOfWeek == DayOfWeek.Monday || GameEnvironment.GameEvents.GameTimer.DateAndTime.DayOfWeek == DayOfWeek.Sunday) { GameMessageBox.Show("Режим работы", "вт-сб 9:00 - 18:00 \n пн,вс выходной"); lastForm.Visibility = Visibility.Hidden; return; } NewWindow(new Shop(GameEnvironment)); break; case "bank": if (GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour < 9 || GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour > 18 || GameEnvironment.GameEvents.GameTimer.DateAndTime.DayOfWeek == DayOfWeek.Sunday) { GameMessageBox.Show("Режим работы", "вт-сб 9:00 - 18:00 \n вс выходной"); lastForm.Visibility = Visibility.Hidden; return; } NewWindow(new Bank(GameEnvironment)); break; case "disc_stand": if (GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour < 10 || GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour > 19) { GameMessageBox.Show("Режим работы", "ежедневно 10:00 - 19:00"); lastForm.Visibility = Visibility.Hidden; return; } NewWindow(new DiscStand(GameEnvironment)); break; case "estate_agency": if (GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour < 9 || GameEnvironment.GameEvents.GameTimer.DateAndTime.Hour > 18) { GameMessageBox.Show("Режим работы", "ежедневно 09:00 - 18:00"); lastForm.Visibility = Visibility.Hidden; return; } NewWindow(new RealEstateAgency(GameEnvironment)); break; default: MessageBox.Show("Вы прибыли к " + obj + "!"); break; } }
private bool PropertyForSale() { if (GameEnvironment.Player.House != null) { GameEvent @event; bool isBreak = false; for (int i = 0; i >= GameEnvironment.GameEvents.Events.Count - 1; i++) { if (GameEnvironment.Player.House.IsRentedOut) { if (GameEnvironment.GameEvents.Events[i].Name == (GameEnvironment.Player.House.PlayerRent.Service.UId + ":" + GameEnvironment.Player.House.PlayerRent.UId + ":" + GameEnvironment.Player.House.Rent)) { @event = GameEnvironment.GameEvents.Events[i]; double sum = (@event.ResponseTime - GameEnvironment.GameEvents.GameTimer.DateAndTime).TotalDays * GameEnvironment.Player.House.PlayerRent.Amount; if (GameEnvironment.Player.House.PlayerRent.Currency.Withdraw("Выплата аренды", "Агенство недвижимости \"Крыша над головой\"", GameEnvironment.GameEvents.GameTimer.DateAndTime, sum)) { GameMessageBox.Show("Аренда", "Вам не хватает средств на выплату задолженности по текущей аренде!", GameMessageBox.MessageBoxType.Information); return(false); } GameEnvironment.GameEvents.Events.Remove(@event); if (isBreak) { break; } isBreak = true; } } else if (GameEnvironment.GameEvents.Events[i].Name == (GameEnvironment.Player.House.PlayerCommunalPayments.Service.UId + ":" + GameEnvironment.Player.House.PlayerCommunalPayments.UId + ":" + GameEnvironment.Player.House.CommunalPayments)) { @event = GameEnvironment.GameEvents.Events[i]; double sum = (@event.ResponseTime - GameEnvironment.GameEvents.GameTimer.DateAndTime).TotalDays * GameEnvironment.Player.House.PlayerCommunalPayments.Amount; if (GameEnvironment.Player.House.PlayerCommunalPayments.Currency.Withdraw("Оплата коммунальных платежей", "Жилищно-комуунальное хозяйство", GameEnvironment.GameEvents.GameTimer.DateAndTime, sum)) { GameMessageBox.Show("Аренда", "Вам не хватает средств на выплату задолженности по коммунальным платежам!", GameMessageBox.MessageBoxType.Information); return(false); } GameEnvironment.GameEvents.Events.Remove(@event); if (isBreak) { break; } isBreak = true; } } if (GameEnvironment.Player.House.IsPurchased) { GameEnvironment.Money.PlayerCurrency[0].TopUp("Продажа недвижимости", GameEnvironment.Player.Name, GameEnvironment.GameEvents.GameTimer.DateAndTime, (GameEnvironment.Player.House.Price * 90 / 100) * GameEnvironment.Money.PlayerCurrency[0].Course); } } return(true); }
private void DefaultBuild_Click(object sender, RoutedEventArgs e) { List <Computer> currentComputer = GameEnvironment.Computers.PlayerComputers.Where(n => n.Name == AssemblyList.Text).ToList(); if (currentComputer.Count == 1) { GameEnvironment.Computers.CurrentPlayerComputer = currentComputer[0]; GameMessageBox.Show("Сборка установлена как сборка по умолчанию!"); } else { GameMessageBox.Show("Компьютер с таким именем не существует!"); } }
private void InstallProgram(GameEvent @event) { if (InstallationProgress.Value + 1 < 100) { InstallationProgress.Value++; } else { GameEnvironment.GameEvents.Events.Remove(@event); Install.Visibility = Visibility.Collapsed; List.Visibility = Visibility.Visible; program.Properties.Row = -1; program.Properties.Column = -1; GameEnvironment.Items.Programs.Add(program); GameEnvironment.Main.DrawDesktop(); GameMessageBox.Show("Установка успешно произведена!"); } }
private void Game_Click(object sender, RoutedEventArgs e) { if (gameState == GameState.newgame) { number = GameEnvironment.Random.Next(1, 101); Text.Text = "Введите число от 1 до 100 и нажмите кнопку 'Угадать'"; Game.Content = "Угадать"; Number.IsEnabled = true; gameState = GameState.game; } else if (gameState == GameState.game) { if (int.TryParse(Number.Text, out int num)) { if (num < 1 || num > 100) { GameMessageBox.Show("Введенное число не поподает в диапазон от 1 до 100"); return; } attempt++; NumberAttempt.Content = "Сделано попыток: " + attempt; if (num < number) { Text.Text = "Загаданное число больше"; } else if (num > number) { Text.Text = "Загаданное число меньше"; } else { Text.Text = "Поздравляю, Вы угадали число с " + attempt + " попыток"; GameMessageBox.Show("Поздравляю, Вы угадали число с " + attempt + " попыток"); gameState = GameState.newgame; number = 0; attempt = 0; Number.Text = string.Empty; Number.IsEnabled = false; Game.Content = "Играть"; Text.Text = "Поздравляю с победой, может сыграем еще раз?"; NumberAttempt.Content = "Сделано попыток: " + attempt; } } } }
private void AddAssemblyName(string name, bool isCleaningItemsSource = true) { for (int i = 0; i < AssemblyList.Items.Count; i++) { string item = (string)AssemblyList.Items[i]; if (item != name) { continue; } name = string.Empty; _ = GameMessageBox.Show(Properties.Resources.AddAssembly, Properties.Resources.AssemblyMessage1, GameMessageBox.MessageBoxType.Warning); break; } if (!string.IsNullOrEmpty(name)) { AssemblyList.Items.Add(name); if (isCleaningItemsSource) { ComputerСomponents.ItemsSource = new Collection <ListBoxObject>(); } } }
private void CreatePartition_Click(object sender, RoutedEventArgs e) { if (SelectedHDDPartition != null) { int summVolume = 0; foreach (Partition lpartition in SelectedHDDPartition.HDD.Properties.Partitions) { summVolume += lpartition.Volume; } if (summVolume + PartitionVolume.Value <= SelectedHDDPartition.HDD.Properties.Volume) { string letter = GameEnvironment.Computers.CurrentPlayerComputer.GetLetters(2); if (string.IsNullOrEmpty(letter)) { return; } Partition partition = new Partition { Letter = letter, Volume = Convert.ToInt32(PartitionVolume.Value), }; if (!GameEnvironment.Computers.CurrentPlayerComputer.AssignValueToLetter(letter, partition)) { return; } SelectedHDDPartition.HDD.Properties.Partitions.Add(partition); LoadPartitionsList(); } else { GameMessageBox.Show("Создание раздела", "На диске нет столько свободного места!", GameMessageBox.MessageBoxType.Warning); } } }
private void BuyButton_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (!(button.Tag is House)) { return; } House house = button.Tag as House; if (GameEnvironment.Player.House != null) { if (GameEnvironment.Player.House.IsRent == true & GameEnvironment.Player.House.IsRentedOut & house.UId == GameEnvironment.Player.House.UId) { if (GameMessageBox.Show("Покупка", "Данное жилье арендовано вами, вы действительно хотите расторгнуть аренду?", GameMessageBox.MessageBoxType.ConfirmationWithYesNo) == MessageBoxResult.No) { return; } } if ((GameEnvironment.Player.House.IsPurchased || GameEnvironment.Player.House.IsPurchasedOnCredit) && house.UId == GameEnvironment.Player.House.UId) { _ = GameMessageBox.Show("Покупка", "У вас уже куплено данное жилье!", GameMessageBox.MessageBoxType.Information); return; } if (GameEnvironment.Player.House.IsPurchasedOnCredit && house.UId != GameEnvironment.Player.House.UId) { _ = GameMessageBox.Show("Покупка", "Нельзя купить новое жилье пока не погасите кредит за текущее!", GameMessageBox.MessageBoxType.Information); return; } if (GameEnvironment.Player.House.IsPurchased && house.UId != GameEnvironment.Player.House.UId) { if (GameMessageBox.Show("Покупка", "У вас есть другое купленно жилье, вы действительно хотите его продать?", GameMessageBox.MessageBoxType.ConfirmationWithYesNo) == MessageBoxResult.No) { return; } } } Service communal_service = null; for (int i = 0; i <= GameEnvironment.Services.AllServices.Count - 1; i++) { if (GameEnvironment.Services.AllServices[i].SystemName == "communal_payments") { communal_service = GameEnvironment.Services.AllServices[i]; break; } } if (communal_service == null) { GameMessageBox.Show("Покупка", "Не найдена услуга коммунальных платежей, убедитесь в целостности базы данных!", GameMessageBox.MessageBoxType.Error); return; } PropertyForSale(); double price = house.Price * GameEnvironment.Money.PlayerCurrency[0].Course; if (GameEnvironment.Money.PlayerCurrency[0].Withdraw("Покупка " + house.Name, "Агенство недвижимости \"Крыша над головой\"", GameEnvironment.GameEvents.GameTimer.DateAndTime, price)) { CoinCount.Content = GameEnvironment.Money.PlayerCurrency[0].Count.ToString("N3") + " " + GameEnvironment.Money.PlayerCurrency[0].Abbreviation; int uid = GameEnvironment.Services.AllServices.Count + 1; //Возможно прийдеться поменять PlayerTariff playerCommunalTariff = new PlayerTariff(uid + 1, house.Name, GameEnvironment.Money.PlayerCurrency[0], 0, house.Rent, house.Rent, Periodicity.Month, 1, Periodicity.Month, 1, 1, communal_service, house.CommunalPayments * GameEnvironment.Money.PlayerCurrency[0].Course, 1, GameEnvironment.GameEvents.GameTimer.DateAndTime); GameEnvironment.Services.PlayerTariffs.Add(playerCommunalTariff); DateTime date = GameEnvironment.GameEvents.GameTimer.DateAndTime; date = new DateTime(date.Year, date.Month, 15, date.Hour, date.Minute, date.Second); GameEnvironment.GameEvents.Events.Add(new GameEvent(communal_service.UId + ":" + playerCommunalTariff.UId + ":" + (house.CommunalPayments * playerCommunalTariff.Currency.Course), GameEnvironment.GameEvents.GetDateTimeFromPeriodicity(date, playerCommunalTariff.Periodicity, playerCommunalTariff.PeriodicityValue), playerCommunalTariff.Periodicity, playerCommunalTariff.PeriodicityValue, CommunalPayment, true)); GameEnvironment.Player.House = new PlayerHouse(house.UId, house.Name, house.Area, house.StorageSize, house.Rent, house.Price, house.CommunalPayments, house.Location, house.Distance, house.IsPurchase, house.IsRent, house.IsCreditPurchase, house.Image, playerCommunalTariff, false, true, false); SellerText.Text = "Благодарим за покупку, с Вами приятно иметь дело!"; GameEnvironment.Messages.NewMessage("Агенство недвижимости", "Вы купили: " + house.Name + ". Поздравляем Вас с покупкой!", GameMessages.Icon.Info); } else { SellerText.Text = "К сожалению на вашем счету недостаточно средств!"; } }
private void RentButton_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (!(button.Tag is House)) { return; } House house = button.Tag as House; if (GameEnvironment.Player.House != null) { if (GameEnvironment.Player.House.IsRent == true & GameEnvironment.Player.House.IsRentedOut & house.UId == GameEnvironment.Player.House.UId) { _ = GameMessageBox.Show("Аренда", "Вы уже арендовали данное жилье", GameMessageBox.MessageBoxType.Warning); return; } if (GameEnvironment.Player.House.IsPurchased) { if (GameMessageBox.Show("Аренда", "У вас куплено жилье, вы действительно хотите его продать?", GameMessageBox.MessageBoxType.ConfirmationWithYesNo) == MessageBoxResult.No) { return; } } if (GameEnvironment.Player.House.IsPurchasedOnCredit) { _ = GameMessageBox.Show("Аренда", "Нельзя арендовать если есть купленное в кредит жилье!", GameMessageBox.MessageBoxType.Information); return; } } Service service = null; Service communal_service = null; for (int i = 0; i <= GameEnvironment.Services.AllServices.Count - 1; i++) { if (GameEnvironment.Services.AllServices[i].SystemName == "rent") { service = GameEnvironment.Services.AllServices[i]; } else if (GameEnvironment.Services.AllServices[i].SystemName == "communal_payments") { communal_service = GameEnvironment.Services.AllServices[i]; } if (service != null && communal_service != null) { break; } } if (service == null) { GameMessageBox.Show("Аренда", "Не найдена услуга аренды, убедитесь в целостности базы данных!", GameMessageBox.MessageBoxType.Error); return; } if (communal_service == null) { GameMessageBox.Show("Аренда", "Не найдена услуга коммунальных платежей, убедитесь в целостности базы данных!", GameMessageBox.MessageBoxType.Error); return; } PropertyForSale(); int uid = GameEnvironment.Services.AllServices.Count + 1; //Возможно прийдеться поменять PlayerTariff playerTariff = new PlayerTariff(uid, house.Name, GameEnvironment.Money.PlayerCurrency[0], 0, house.Rent, house.Rent, Periodicity.Month, 1, Periodicity.Month, 1, 1, service, house.Rent * GameEnvironment.Money.PlayerCurrency[0].Course, 1, GameEnvironment.GameEvents.GameTimer.DateAndTime); PlayerTariff playerCommunalTariff = new PlayerTariff(uid + 1, house.Name, GameEnvironment.Money.PlayerCurrency[0], 0, house.Rent, house.Rent, Periodicity.Month, 1, Periodicity.Month, 1, 1, communal_service, house.CommunalPayments * GameEnvironment.Money.PlayerCurrency[0].Course, 1, GameEnvironment.GameEvents.GameTimer.DateAndTime); GameEnvironment.Services.PlayerTariffs.Add(playerTariff); GameEnvironment.Services.PlayerTariffs.Add(playerCommunalTariff); GameEnvironment.Player.House = new PlayerHouse(house.UId, house.Name, house.Area, house.StorageSize, house.Rent, house.Price, house.CommunalPayments, house.Location, house.Distance, house.IsPurchase, house.IsRent, house.IsCreditPurchase, house.Image, playerCommunalTariff, true, false, false, playerTariff); GameEnvironment.GameEvents.Events.Add(new GameEvent(service.UId + ":" + playerTariff.UId + ":" + (house.Rent * playerTariff.Currency.Course), GameEnvironment.GameEvents.GetDateTimeFromPeriodicity(GameEnvironment.GameEvents.GameTimer.DateAndTime, playerTariff.Periodicity, playerTariff.PeriodicityValue), playerTariff.Periodicity, playerTariff.PeriodicityValue, RentalPayment, true)); DateTime date = GameEnvironment.GameEvents.GameTimer.DateAndTime; date = new DateTime(date.Year, date.Month, 15, date.Hour, date.Minute, date.Second); GameEnvironment.GameEvents.Events.Add(new GameEvent(communal_service.UId + ":" + playerCommunalTariff.UId + ":" + (house.CommunalPayments * playerCommunalTariff.Currency.Course), GameEnvironment.GameEvents.GetDateTimeFromPeriodicity(date, playerCommunalTariff.Periodicity, playerCommunalTariff.PeriodicityValue), playerCommunalTariff.Periodicity, playerCommunalTariff.PeriodicityValue, CommunalPayment, true)); GameEnvironment.Messages.NewMessage("Агенство недвижимости", "Вы арендовали: " + house.Name + ". Поздравляем Вас!", GameMessages.Icon.Info); }
private void StartInstall_Click(object sender, RoutedEventArgs e) { GameMessageBox.Show("Тестирование и запуск", "Установка производиться непосредственно на главном экране, убедитесь что сборка установлена как сборка по умолчанию и закройте это окно.", GameMessageBox.MessageBoxType.Information); }
/// <param name="auxiliary_check">Вспомогательная проверка нужна при вызове метода из AssemblyList_SelectionChanged</param> private void SaveComputer(bool auxiliary_check = true) { string name = AssemblyList.Text; bool isName = false; if (!string.IsNullOrEmpty(name)) { foreach (String item in AssemblyList.Items) { if (item == name) { isName = true; break; } } } Computer[] currentComputer = GameEnvironment.Computers.PlayerComputers.Where(n => n.Name == name).ToArray(); bool isNewComputer = currentComputer.Count() == 1 ? false : true; bool isChangedComputer = false; if (isNewComputer == false) { isChangedComputer = IsChangedComputer(currentComputer[0]); } if (!auxiliary_check) { return; } if (!(ComputerСomponents.Items.Count >= 1 && isNewComputer || !isNewComputer && isChangedComputer)) { return; } if (!isName) { AddAssemblyName(name, false); } Computer newComputer; if (!isChangedComputer) { Case @case = null; Motherboard motherboard = null; foreach (object obj in ComputerСomponents.Items) { object iobj = (obj as ListBoxObject).IObject; if (iobj is Case) { @case = iobj as Case; } else if (iobj is Motherboard) { motherboard = iobj as Motherboard; } if (@case != null && motherboard != null) { break; } } if (@case == null || motherboard == null) { switch (@case) { case null: if (motherboard != null) { newComputer = new Computer(name, motherboard); } else { newComputer = null; } break; default: newComputer = new Computer(name, @case); break; } } else { newComputer = new Computer(name, @case, motherboard); } } else { newComputer = currentComputer[0]; currentComputer[0].IsEnable = false; } if (newComputer == null) { return; } newComputer = AddСomponents(newComputer); if (isChangedComputer) { _ = GameMessageBox.Show(Properties.Resources.ModifiedAssembly, Properties.Resources.AssemblingChanged, GameMessageBox.MessageBoxType.Information); } else { GameEnvironment.Computers.PlayerComputers.Add(newComputer); _ = GameMessageBox.Show(Properties.Resources.AddAssembly, Properties.Resources.AssemblingAdded, GameMessageBox.MessageBoxType.Information); } }
private void BuyButton_Click(object sender, RoutedEventArgs e) { if (GameEnvironment.Player.House == null) { GameMessageBox.Show("Покупка", "Вам негде это хранить, для начала обзаведитесь жильем.", GameMessageBox.MessageBoxType.Information); return; } Button button = sender as Button; if (button.Tag is BaseItem) { double price = (button.Tag as BaseItem).Price * GameEnvironment.Money.PlayerCurrency[0].Course; price += price / 100 * StorePercentage; if (price <= GameEnvironment.Money.PlayerCurrency[0].Count) { GameEnvironment.Money.PlayerCurrency[0].Withdraw("Оплата покупки: " + (button.Tag as BaseItem).Name, Properties.Resources.ComponentStoreFullName, GameEnvironment.GameEvents.GameTimer.DateAndTime, price); CoinCount.Content = GameEnvironment.Money.PlayerCurrency[0].Count.ToString("N3") + " " + GameEnvironment.Money.PlayerCurrency[0].Abbreviation; if (button.Tag is Case) { Case @case = (button.Tag as Case); GameEnvironment.Items.Cases.Add(new Case(@case.Uid, @case.Name, @case.GetTypeValue(), @case.Price, @case.ManufacturingDate, @case.Properties)); } else if (button.Tag is Motherboard) { Motherboard motherboard = (button.Tag as Motherboard); GameEnvironment.Items.Motherboards.Add(new Motherboard(motherboard.Uid, motherboard.Name, motherboard.GetTypeValue(), motherboard.Price, motherboard.ManufacturingDate, motherboard.Properties)); } else if (button.Tag is PowerSupplyUnit) { PowerSupplyUnit psu = (button.Tag as PowerSupplyUnit); GameEnvironment.Items.PowerSupplyUnits.Add(new PowerSupplyUnit(psu.Uid, psu.Name, psu.GetTypeValue(), psu.Price, psu.ManufacturingDate, psu.Properties)); } else if (button.Tag is CPU) { CPU cpu = (button.Tag as CPU); GameEnvironment.Items.CPUs.Add(new CPU(cpu.Uid, cpu.Name, cpu.GetTypeValue(), cpu.Price, cpu.ManufacturingDate, cpu.Properties)); } else if (button.Tag is RAM) { RAM ram = (button.Tag as RAM); GameEnvironment.Items.RAMs.Add(new RAM(ram.Uid, ram.Name, ram.GetTypeValue(), ram.Price, ram.ManufacturingDate, ram.Properties)); } else if (button.Tag is CPUCooler) { CPUCooler cpuCooler = button.Tag as CPUCooler; GameEnvironment.Items.CPUCoolers.Add(new CPUCooler(cpuCooler.Uid, cpuCooler.Name, cpuCooler.GetTypeValue(), cpuCooler.Price, cpuCooler.ManufacturingDate, cpuCooler.Properties)); } else if (button.Tag is HDD) { HDD hdd = button.Tag as HDD; GameEnvironment.Items.HDDs.Add(new HDD(hdd.Uid, hdd.Name, hdd.GetTypeValue(), hdd.Price, hdd.ManufacturingDate, hdd.Properties)); } else if (button.Tag is Monitor) { Monitor monitor = button.Tag as Monitor; GameEnvironment.Items.Monitors.Add(new Monitor(monitor.Uid, monitor.Name, monitor.GetTypeValue(), monitor.Price, monitor.ManufacturingDate, monitor.Properties)); } else if (button.Tag is VideoCard) { VideoCard videoCard = button.Tag as VideoCard; GameEnvironment.Items.VideoCards.Add(new VideoCard(videoCard.Uid, videoCard.Name, videoCard.GetTypeValue(), videoCard.Price, videoCard.ManufacturingDate, videoCard.Properties)); } else if (button.Tag is OpticalDrive) { OpticalDrive opticalDrive = button.Tag as OpticalDrive; GameEnvironment.Items.OpticalDrives.Add(new OpticalDrive(opticalDrive.Uid, opticalDrive.Name, opticalDrive.GetTypeValue(), opticalDrive.Price, opticalDrive.ManufacturingDate, opticalDrive.Properties)); } else if (button.Tag is Keyboard) { Keyboard keyboard = button.Tag as Keyboard; GameEnvironment.Items.Keyboards.Add(new Keyboard(keyboard.Uid, keyboard.Name, keyboard.GetTypeValue(), keyboard.Price, keyboard.ManufacturingDate, keyboard.Properties)); } SellerText.Text = "Спасибо за покупку " + (button.Tag as BaseItem).Name + ", хороший выбор!"; } else { SellerText.Text = "Извини дружище, нет денег нет товара."; } } else if (button.Tag is Mouse) { Mouse mouse = button.Tag as Mouse; GameEnvironment.Items.Mice.Add(new Mouse(mouse.Uid, mouse.Name, mouse.GetTypeValue(), mouse.Price, mouse.ManufacturingDate, mouse.Properties)); } }
private void BuyCreditButton_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (!(button.Tag is House)) { return; } house = button.Tag as House; if (GameEnvironment.Player.House != null) { if (GameEnvironment.Player.House.IsRent == true & GameEnvironment.Player.House.IsRentedOut & house.UId == GameEnvironment.Player.House.UId) { if (GameMessageBox.Show("Покупка в кредит", "Данное жилье арендовано вами, вы действительно хотите расторгнуть аренду?", GameMessageBox.MessageBoxType.ConfirmationWithYesNo) == MessageBoxResult.No) { return; } } if ((GameEnvironment.Player.House.IsPurchased || GameEnvironment.Player.House.IsPurchasedOnCredit) && house.UId == GameEnvironment.Player.House.UId) { _ = GameMessageBox.Show("Покупка в кредит", "У вас уже куплено данное жилье!", GameMessageBox.MessageBoxType.Information); return; } if (GameEnvironment.Player.House.IsPurchasedOnCredit && house.UId != GameEnvironment.Player.House.UId) { _ = GameMessageBox.Show("Покупка в кредит", "Нельзя купить новое жилье пока не погасите кредит за текущее!", GameMessageBox.MessageBoxType.Information); return; } if (GameEnvironment.Player.House.IsPurchased && house.UId != GameEnvironment.Player.House.UId) { if (GameMessageBox.Show("Покупка в кредит", "У вас есть другое купленно жилье, вы действительно хотите его продать?", GameMessageBox.MessageBoxType.ConfirmationWithYesNo) == MessageBoxResult.No) { return; } } } Service service = null; for (int i = 0; i <= GameEnvironment.Services.AllServices.Count - 1; i++) { if (GameEnvironment.Services.AllServices[i].SystemName == "rent") { service = GameEnvironment.Services.AllServices[i]; } else if (GameEnvironment.Services.AllServices[i].SystemName == "communal_payments") { communal_service = GameEnvironment.Services.AllServices[i]; } if (service != null && communal_service != null) { break; } } if (service == null) { GameMessageBox.Show("Покупка в кредит", "Не найдена услуга аренды, убедитесь в целостности базы данных!", GameMessageBox.MessageBoxType.Error); return; } if (communal_service == null) { GameMessageBox.Show("Покупка в кредит", "Не найдена услуга коммунальных платежей, убедитесь в целостности базы данных!", GameMessageBox.MessageBoxType.Error); return; } PropertyForSale(); bank = new Bank(GameEnvironment); bank.ServiceGrid.Children.Remove(bank.ServiceForm); CreditPanel.Children.Add(bank.ServiceForm); bank.ServiceForm.Visibility = Visibility.Visible; bank.Sum.Text = house.Price.ToString(); bank.Sum.Tag = house.Price; bank.Sum.IsEnabled = false; bank.LoadCredits(); bank.Accept.Click -= bank.Accept_Click; bank.Accept.Click += Accept_Click; bank.CloseServiceForm.Click -= bank.CloseServiceForm_Click; bank.CloseServiceForm.Click += CloseServiceForm_Click; RentPanel.Visibility = Visibility.Collapsed; CreditPanel.Visibility = Visibility.Visible; }