コード例 #1
0
        private void StatisticGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid  stat    = (DataGrid)sender;
            StatTable statRow = (StatTable)stat.SelectedItem;

            StatBoxTable.Items.Clear();

            if (statRow == null)
            {
                foreach (DataGrid StatBox in new List <DataGrid>()
                {
                    StatBoxDown, StatBoxDamag
                })
                {
                    StatBox.Items.Clear();
                    StatBox.Columns.Clear();
                }

                StatNotSelected.Visibility = Visibility.Visible;
                return;
            }
            else
            {
                StatNotSelected.Visibility = Visibility.Hidden;
            }

            StatisticGrid.Margin = new Thickness(0, 540, 0, 0);
            StatisticGrid.Height = StatisticMenu.Height - Constants.STATISTIC_GRID_MARGIN - 590;

            int    shellsForShutdown = (statRow.shutdown > 0 ? (int)statRow.shellsFired / statRow.shutdown : 0);
            string scriptName        = Statistic.getStatisticScript(stat.SelectedIndex);
            int    shellInQueue      = (statRow.shootNumber > 0 ? (int)statRow.shellsFired / statRow.shootNumber : 0);
            double timeForQueue      = (statRow.shootNumber > 0 ? (double)statRow.shootTime / (double)statRow.shootNumber : 0);

            StatBoxAddRow(new String[] {
                "зенитчик", statRow.name,
                "сценарий", scriptName
            });
            StatBoxAddRow(new String[] {
                "сбито", String.Format("{0} ( {1}% )", statRow.shutdown, statRow.shutdownPercent),
                "повреждено", String.Format("{0} ( {1}% )", statRow.damaged, statRow.damagedPercent)
            });
            StatBoxAddRow(new String[] {
                "настрел, снарядов", statRow.shellsFired.ToString(),
                "упущенных", statRow.hasGone.ToString()
            });
            StatBoxAddRow(new String[] {
                "\u2014 из них в цель", String.Format("{0} ( {1}% )", statRow.inTarget, statRow.inTargetPercent),
                "\u2014 из них без повреждений", String.Format("{0}%", statRow.withoutDamage)
            });
            StatBoxAddRow(new String[] {
                "настрел на сбитие", String.Format("{0} выстр./сбитый", shellsForShutdown),
                "нанесён ущерб", Statistic.HumanReadableSumm(statRow.amountOfDamage)
            });
            StatBoxAddRow(new String[] {
                "повреждено своих", statRow.friendDamage.ToString(),
                "повреждено гражданских", statRow.airlinerDamage.ToString()
            });
            StatBoxAddRow(new String[] {
                "общее время боя", statRow.time.ToString(),
                "средняя очередь, снарядов", shellInQueue.ToString()
            });
            StatBoxAddRow(new String[] {
                "\u2014 из них непогоды", statRow.badTime.ToString(),
                "время средней очереди", string.Format("{0:f2} сек", timeForQueue)
            });
            StatBoxAddRow(new String[] {
                "удача", statRow.chance.ToString(),
                "лучший трофей", StatMostValuableTrophy(statRow.aircrafts)
            });

            StatBoxValues(StatBoxDown, statRow.aircrafts, statRow.shutdown, statRow.amountOfDamage);
            StatBoxValues(StatBoxDamag, statRow.aircraftsDamaged, statRow.damaged, statRow.amountOfDamage, inaccurate: true);
        }
コード例 #2
0
        public FirePlace()
        {
            InitializeComponent();

            this.WindowState = WindowState.Maximized;
            this.WindowStyle = WindowStyle.None;

            double heightForShilka = SystemParameters.PrimaryScreenHeight - ShilkaImg.Height;

            Aircrafts.minAltitudeGlobal = (int)(heightForShilka - ShilkaImg.Height);

            foreach (Canvas Menu in new List <Canvas>()
            {
                EndMenu, RestartTrainingMenu, StatisticMenu
            })
            {
                Menu.Height = SystemParameters.PrimaryScreenHeight;
            }

            foreach (Canvas Menu in new List <Canvas>()
            {
                EndMenu, RestartTrainingMenu, firePlaceDock
            })
            {
                Menu.Margin = new Thickness(SystemParameters.PrimaryScreenWidth, 0, 0, 0);
            }

            foreach (Canvas Menu in new List <Canvas>()
            {
                EndMenu, RestartTrainingMenu, firePlaceDock
            })
            {
                Menu.Margin = new Thickness(SystemParameters.PrimaryScreenWidth, 0, 0, 0);
            }

            StatisticMenu.Width  = SystemParameters.PrimaryScreenWidth;
            StatisticMenu.Margin = new Thickness(0, SystemParameters.PrimaryScreenHeight, 0, 0);

            var converter = new BrushConverter();

            StatisticMenu.Background  = (Brush)converter.ConvertFrom(statisticColor);
            StatisticGrid.ItemsSource = Statistic.Load();
            StatisticGrid.Margin      = new Thickness(0, 50, 0, 0);
            StatisticGrid.Height      = StatisticMenu.Height - Constants.STATISTIC_GRID_MARGIN - 50;

            foreach (DataGrid Menu in new List <DataGrid>()
            {
                StatisticGrid, StatBoxTable, StatBoxDown, StatBoxDamag
            })
            {
                Menu.Width = StatisticMenu.Width - Constants.STATISTIC_GRID_MARGIN;
            }

            StatBoxTable.Margin = new Thickness(0, 50, 0, 0);
            StatBoxTable.Height = 320;

            StatBoxTable.Background    = StatisticMenu.Background;
            StatBoxTable.RowBackground = StatisticMenu.Background;
            StatBoxTable.BorderBrush   = StatisticMenu.Background;

            StatNotSelected.Margin = StatBoxTable.Margin;

            double widthStatBox = (SystemParameters.PrimaryScreenWidth / 2) - 100;

            StatBoxDownLabel.Margin = new Thickness(0, 290, 0, 0);
            StatBoxDown.Margin      = new Thickness(0, 300, 0, 0);
            StatBoxDown.Height      = 150;
            StatBoxDown.Width       = widthStatBox;

            double leftPadding = (SystemParameters.PrimaryScreenWidth / 2) - 60;

            StatBoxDamaglabel.Margin = new Thickness(leftPadding, 290, 0, 0);
            StatBoxDamag.Margin      = new Thickness(leftPadding, 300, 0, 0);
            StatBoxDamag.Height      = StatBoxDown.Height;
            StatBoxDamag.Width       = StatBoxTable.Width - widthStatBox - 40;

            statShells.Width = StatisticGrid.Width;

            StartMenu.Height = StatisticMenu.Height;
            StartMenu.Width  = StatisticMenu.Width;
            StartMenu.Margin = new Thickness(0, 0, 0, 0);

            StartMenuButtons.Margin = new Thickness(
                (StartMenu.Width / 2 - StartMenuButtons.Width / 2), (StartMenu.Height / 2 - StartMenuButtons.Height / 2), 0, 0
                );

            StartMenu.Background = (Brush)converter.ConvertFrom(startColor);

            ShilkaImg.Margin = new Thickness(0, heightForShilka, 0, 0);
            RadarImg.Margin  = new Thickness(62, heightForShilka, 0, 0);
            HandImg.Margin   = new Thickness(65, (heightForShilka - 120), 0, 0);

            ToolTipService.ShowDurationProperty.OverrideMetadata(
                typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue));
        }
コード例 #3
0
 public static void GameTimeTicTac(object obj, ElapsedEventArgs e)
 {
     Statistic.GameTimeAddSec(1);
     Statistic.ShootingTimeAdd();
 }
コード例 #4
0
        public void StartGame()
        {
            startMenuShowYet = false;

            double trainingAdditions = ((Shilka.school || Shilka.training) ? 25 : 0);

            statShells.Margin = new Thickness(Constants.STAT_TEXT_TOP, Constants.STAT_TEXT_LEFT + trainingAdditions, 0, 0);

            ScriptImages();

            MoveCanvas(
                moveCanvas: StartMenu,
                prevCanvas: firePlaceDock,
                left: StartMenu.Margin.Left - StartMenu.ActualWidth,
                speed: 0.6
                );

            if (!startGameAlready)
            {
                Game.Elapsed += new ElapsedEventHandler(Shell.Fire);
                Game.Elapsed += new ElapsedEventHandler(Shell.Fly);
                Game.Elapsed += new ElapsedEventHandler(Case.Fly);
                Game.Elapsed += new ElapsedEventHandler(Wrecks.Fly);
                Game.Elapsed += new ElapsedEventHandler(Weather.Change);
                Game.Elapsed += new ElapsedEventHandler(Weather.Fly);
                Game.Elapsed += new ElapsedEventHandler(Aircraft.Fly);
                Game.Elapsed += new ElapsedEventHandler(Statistic.Show);
                Game.Elapsed += new ElapsedEventHandler(Shilka.RadarmMalfunction);

                HandMove.Elapsed       += new ElapsedEventHandler(HideHand);
                AircraftsStart.Elapsed += new ElapsedEventHandler(Aircraft.Start);
                School.Elapsed         += new ElapsedEventHandler(SchoolShow);
                GameTimer.Elapsed      += new ElapsedEventHandler(GameTimeTicTac);
            }
            HandMove.Enabled = true;
            HandMove.Start();

            Game.Enabled = true;
            Game.Start();

            AircraftsStart.Enabled = true;
            AircraftsStart.Start();

            Statistic.GameTimeAddSec(0);

            GameTimer.Enabled = true;
            GameTimer.Start();

            if (Shilka.school || Shilka.training)
            {
                schoolLabel.Content    = (Shilka.school ? "обучающий режим" : "тренировка");
                schoolLabel.Visibility = Visibility.Visible;
                School.Enabled         = true;
                School.Start();
            }
            else
            {
                schoolLabel.Visibility = Visibility.Hidden;
                School.Enabled         = false;
                School.Stop();
            }

            startGameAlready = true;
        }
コード例 #5
0
ファイル: Shell.cs プロジェクト: mig1023/shilka
        public static void Fly(object obj, ElapsedEventArgs e)
        {
            Application.Current.Dispatcher.BeginInvoke(new ThreadStart(delegate
            {
                FirePlace main = (FirePlace)Application.Current.MainWindow;

                if (animationStop)
                {
                    return;
                }

                foreach (var line in allLines)
                {
                    main.firePlace.Children.Remove(line);
                }

                allLines.Clear();
                Shilka.DrawGuns(main);

                fireMutex++;

                foreach (var shell in shells)
                {
                    shell.x = (shell.x + Constants.SHELL_SPEED * shell.cos);
                    shell.y = (shell.y - Constants.SHELL_SPEED * shell.sin);

                    shell.shellImage.Margin = new Thickness(shell.x, shell.y, 0, 0);

                    foreach (Aircraft aircraft in Aircraft.aircrafts)
                    {
                        if (
                            shell.fly &&
                            (shell.y < (aircraft.aircraftImage.Margin.Top + aircraft.aircraftImage.Height)) &&
                            (shell.y > (aircraft.aircraftImage.Margin.Top)) &&
                            (shell.x > (aircraft.aircraftImage.Margin.Left)) &&
                            (shell.x < (aircraft.aircraftImage.Margin.Left + aircraft.aircraftImage.Width))
                            )
                        {
                            if (aircraft.cloud)
                            {
                                continue;
                            }

                            bool itsOnlyTargetPlane = false;

                            if (Shilka.training && (aircraft.aircraftType == "il28bm_77bm2"))
                            {
                                if (aircraft.TargetTubHit(shell, ref itsOnlyTargetPlane))
                                {
                                    continue;
                                }
                            }

                            if (itsOnlyTargetPlane && aircraft.fly && (aircraft.tragetTugHitPoint <= 0))
                            {
                                aircraft.TargetTugDisengaged();
                            }

                            Line shellTrace = new Line
                            {
                                X1 = shell.x + shell.cos,
                                Y1 = shell.y - shell.sin,
                                X2 = shell.x + Constants.FLASH_SIZE,
                                Y2 = shell.y - Constants.FLASH_SIZE
                            };
                            shell.flash                = true;
                            shellTrace.Stroke          = Brushes.Red;
                            shellTrace.StrokeThickness = Constants.FLASH_SIZE;

                            Wrecks.WreckBreackOffFromAircraft(
                                startX: shell.x,
                                startY: shell.y,
                                direction: aircraft.flightDirection,
                                maxSpeed: (aircraft.zeroSpeed ? 0 : (int)aircraft.speed),
                                maxSize: aircraft.wrecksMaxSize,
                                number: aircraft.wrecksNumber,
                                randomDistance: (aircraft.zeroSpeed ? aircraft.size[0] : 0)
                                );

                            if (aircraft.weight == Aircraft.WeightType.Light)
                            {
                                aircraft.y -= Constants.THROWS_UP_BY_HITS;
                            }
                            else if (aircraft.weight == Aircraft.WeightType.Middle)
                            {
                                aircraft.y -= Constants.THROWS_UP_BY_HITS_FOR_MIDDLE_AIRCRAFT;
                            }

                            main.firePlace.Children.Add(shellTrace);
                            Canvas.SetZIndex(shellTrace, 20);
                            allLines.Add(shellTrace);

                            Statistic.ShellFiredAdd(inTarget: true);

                            if (itsOnlyTargetPlane)
                            {
                                shell.fly = false;
                                continue;
                            }

                            aircraft.hitpoint -= 1;

                            if (aircraft.hitpoint <= 0 && !aircraft.dead)
                            {
                                aircraft.Shutdown(main);
                            }

                            double planeMiddle     = aircraft.aircraftImage.Margin.Left + aircraft.aircraftImage.Width / 2;
                            aircraft.placeOfDamage = (shell.x < planeMiddle ? 1 : -1);
                        }
                        else if (shell.flash)
                        {
                            shell.fly = false;
                        }
                    }

                    if ((shell.delay >= Constants.SHELL_DELAY) && (shell.shellImage.Visibility == Visibility.Hidden))
                    {
                        shell.shellImage.Visibility = Visibility.Visible;
                    }

                    if ((shell.y < 0) || (shell.x > currentWidth))
                    {
                        shell.fly = false;
                    }
                    else if (shell.delay < Constants.SHELL_DELAY)
                    {
                        shell.delay++;
                    }
                }

                for (int x = 0; x < shells.Count; x++)
                {
                    if ((shells[x].fly == false) && (fireMutex == 1))
                    {
                        main.firePlace.Children.Remove(shells[x].shellImage);
                        shells.RemoveAt(x);
                    }
                }

                fireMutex--;
            }));
        }
コード例 #6
0
ファイル: Shell.cs プロジェクト: mig1023/shilka
        public static void Fire(object obj, ElapsedEventArgs e)
        {
            int currentFragmentation = Constants.FRAGMENTATION + ((Shilka.degreeOfHeatingGunBurrels - 30) / 25);

            if ((Shilka.currentScript == Scripts.ScriptsNames.Libya) && (rand.Next(Constants.GUN_JAMMING_CHANCE) == 1))
            {
                Array jamming = Enum.GetValues(typeof(gunJammedType));
                gunJammed = (gunJammedType)jamming.GetValue(rand.Next(jamming.Length));
            }

            if (
                (Shilka.fire || (gunJammed == gunJammedType.alwaysShoot))
                &&
                (gunJammed != gunJammedType.doesntShoot)
                &&
                !((gunJammed != gunJammedType.sometimesShoot) && (rand.Next(Constants.GUN_JAMMING_CHANCE) == 1))
                &&
                !Shilka.reheatingGunBurrels
                )
            {
                fireMutex++;
                if (fireMutex > 1)
                {
                    fireMutex--;
                    return;
                }

                for (int a = 0; a < Constants.VOLLEY; a++)
                {
                    Shell newShell = new Shell
                    {
                        fly   = true,
                        delay = 0,

                        x = rand.Next((-1 * currentFragmentation), currentFragmentation) + Constants.FIRE_WIDTH_CORRECTION,
                        y = currentHeight + rand.Next((-1 * currentFragmentation), currentFragmentation) - Constants.FIRE_HEIGHT_CORRECTION
                    };

                    double e1 = Math.Sqrt((ptX * ptX) + (ptY * ptY));

                    double tryCos = ptX / e1;
                    double trySin = ptY / e1;

                    newShell.cos = (double.IsNaN(tryCos) ? lastCos : tryCos);
                    newShell.sin = (double.IsNaN(trySin) ? lastSin : trySin);

                    lastCos = newShell.cos;
                    lastSin = newShell.sin;

                    Application.Current.Dispatcher.BeginInvoke(new ThreadStart(delegate
                    {
                        FirePlace main = (FirePlace)Application.Current.MainWindow;

                        Image newImage = new Image
                        {
                            Width  = Constants.SHELL_LENGTH,
                            Height = Constants.SHELL_THICKNESS
                        };

                        double angle = (Math.Asin(newShell.sin) * 180 / Math.PI) * -1;

                        newImage.RenderTransform = new RotateTransform(angle);
                        newImage.Source          = Functions.ImageFromResources("shell", Aircraft.ImageType.Other);
                        newImage.Margin          = new Thickness(newShell.x, newShell.y, 0, 0);
                        newImage.Visibility      = Visibility.Hidden;

                        newShell.shellImage = newImage;

                        Canvas.SetZIndex(newImage, 10);

                        main.firePlace.Children.Add(newImage);
                        shells.Add(newShell);
                    }));

                    Statistic.ShellFiredAdd();

                    Case.CaseExtractor();
                }
                fireMutex--;

                Shilka.HeatingOfGuns(shooting: true);
            }
            else
            {
                Shilka.HeatingOfGuns(shooting: false);
            }
        }