Exemplo n.º 1
0
        private void BonusGeneratorTimerTick(object sender, EventArgs e)
        {
            // up difficulty
            if (ship.ShipScore > prev_ship_score + 500 && obst_cout_increasing_for_up_difficulty < 15)
            {
                prev_ship_score = ship.ShipScore;
                obst_cout_increasing_for_up_difficulty += 2;
                ConsoleMethod.WriteToConsole("Difficulty up! Now " + obst_cout_increasing_for_up_difficulty, Brushes.Green);
            }


            ship.ShipScore += 1;
            if (RandForSomethings.Between(0, 5) == 1)
            {
                if (RandForSomethings.Between(0, 1) == 0)
                {
                    AmmoBonus bonus = new AmmoBonus(this);
                    CurrentBonuses.Add(bonus);
                    AnimationsRace.AnimationBonus(bonus);
                }
                else
                {
                    HealthBonus bonus = new HealthBonus(this);
                    CurrentBonuses.Add(bonus);
                    AnimationsRace.AnimationBonus(bonus);
                }
            }
        }
Exemplo n.º 2
0
 private void MainInput_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         string[] command_line = MainInput.Text.Split(' ');
         ConsoleMethod.WriteToConsole(MainInput.Text, Brushes.Red);
         string command = command_line.Length > 0 ? command_line[0] : "";
         string param   = command_line.Length > 1 ? command_line[1] : "";
         ConsoleMethod.RunConsoleCommand(command, param);
         MainInput.Text = "";
     }
 }
Exemplo n.º 3
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ConsoleMethod.WriteToConsole("Game window loaded", Brushes.White);
            Sounds.PlayBackGround();
            clouds = new Clouds(this);

            //Image image = new Image();
            //AnimationBehavior.SetSourceUri(image, new Uri(@"J:\training\WPF\SeryojaTheGame\SeryojaTheGame\Race\bin\Debug\win_gifs\1.gif"));
            //MainCanvas.Children.Add(image);


            StarShip starShip_title = new StarShip(null);

            starShip_title.shipRectangle.Margin = new Thickness(MainCanvas.ActualWidth / 2 - starShip_title.shipRectangle.Width / 2,
                                                                MainCanvas.ActualHeight - 200,
                                                                0, 0);
            starShip_title.shipRectangle.Name = "ee_tip";
            MainCanvas.Children.Add(starShip_title.shipRectangle);
            while (show_ee_tip)
            {
                AnimationsRace.AnimationMainScreen(starShip_title, this);
                await System.Threading.Tasks.Task.Run(() => System.Threading.Thread.Sleep(23 * 500 + 3000));
            }
        }
Exemplo n.º 4
0
        private void CollisionTimerTimerTick(object sender, EventArgs e)
        {
            BetterRandom random_for_some = new BetterRandom();

            // check collision obsts and ship
            for (int i = 0; i < CurrentObsts.Count; i++)
            {
                if (ship.ShipHitBox.IntersectsWith(CurrentObsts[i].GetHitBoxObst()))
                {
                    ser_hurt = true;
                    ship.ShipSprite.Visual = (Visual)Application.Current.Resources["seryoja_hurt"];
                    ConsoleMethod.WriteToConsole("Obst number " + i + " hitted!", Brushes.White);
                    ship.ShipHp = ship.ShipHp - CurrentObsts[i].ObstDamage <= 0 ?
                                  0 : (int)(ship.ShipHp - CurrentObsts[i].ObstDamage);
                    AnimationsRace.AnimationShipDamage(ship);

                    Sounds.PlaySoundOnce("hurt_" + random_for_some.Between(1, 2) + ".wav");

                    if (ship.ShipHp == 0)
                    {
                        GameOver();
                    }
                }
            }

            // check collision bullets and obsts
            for (int i = ship.CurrentAmmos.Count - 1; i >= 0; i--)
            {
                // bullet on obsts
                for (int j = 0; j < CurrentObsts.Count; j++)
                {
                    if (CurrentObsts[j].GetHitBoxObst().IntersectsWith(
                            ship.GetHitBoxFire(ship.CurrentAmmos[i])) &&
                        !CurrentObsts[j].Hitted)
                    {
                        CurrentObsts[j].Hitted = true;
                        ship.ShipScore        += 10;
                        ConsoleMethod.WriteToConsole("Obst number " + j + " fired by bullet number " + i + "!", Brushes.White);
                        CurrentObsts[j].ObstacleFiredAnimation();
                        RemoveElementAfterAnimation(CurrentObsts[j].ObstToCanvas);
                        CurrentObsts.Remove(CurrentObsts[j]);
                        Sounds.ObstDamageSoundPlay();
                    }
                }

                // bullet on boss
                if (bossfight)
                {
                    if (ship.CurrentAmmos.Count == 0)
                    {
                        return;
                    }
                    if (boss.GetBossHitBox().IntersectsWith(ship.GetHitBoxFire(ship.CurrentAmmos[i])))
                    {
                        if (boss.BossHealthPoint >= 0)
                        {
                            MainCanvas.Children.Remove(ship.CurrentAmmos[i]);
                            boss.BossHealthPoint       -= ship.ShipFireDamage;
                            progressBarHealthBoss.Value = boss.BossHealthPoint;
                            ConsoleMethod.WriteToConsole("Boss hitted!", Brushes.GreenYellow);
                            continue;
                        }
                        else
                        {
                            GameWin();
                        }
                    }
                }
            }

            // collision boss fire with seryoja
            if (bossfight)
            {
                for (int i = 0; i < boss.CurrentBossAmmos.Count; i++)
                {
                    try
                    {
                        Rect BossFireHitBox = new Rect();
                        BossFireHitBox.Width  = boss.CurrentBossAmmos[i].Width;
                        BossFireHitBox.Height = boss.CurrentBossAmmos[i].Height;
                        BossFireHitBox.X      = boss.CurrentBossAmmos[i].Margin.Left;
                        BossFireHitBox.Y      = boss.CurrentBossAmmos[i].Margin.Top;

                        if (BossFireHitBox.IntersectsWith(ship.ShipHitBox))
                        {
                            if (ship.ShipHp > 0)
                            {
                                ship.ShipHp = ship.ShipHp - boss.BossFireDamage <= 0 ? 0 : ship.ShipHp - boss.BossFireDamage;
                            }
                            else
                            {
                                GameOver();
                            }
                        }
                    }
                    catch { }
                }
            }

            // check collision with bonuses
            for (int i = 0; i < CurrentBonuses.Count; i++)
            {
                if (ship.ShipHitBox.IntersectsWith(CurrentBonuses[i].GetHitBoxObst()) && !CurrentBonuses[i].Hitted)
                {
                    CurrentBonuses[i].Hitted = true;
                    if (CurrentBonuses[i] is AmmoBonus)
                    {
                        ser_hurt = true;
                        ship.ShipSprite.Visual = (Visual)Application.Current.Resources["seryoja_happy"];
                        ConsoleMethod.WriteToConsole("Ammo Bonus obtained!", Brushes.White);
                        ship.ShipAmmo += (CurrentBonuses[i] as AmmoBonus).ammo_count;
                        Sounds.PlaySoundOnce("meh_" + random_for_some.Between(1, 2) + ".wav");
                    }
                    else if (CurrentBonuses[i] is HealthBonus)
                    {
                        ConsoleMethod.WriteToConsole("HP Bonus obtained!", Brushes.White);
                        if (ship.ShipHp < 100)
                        {
                            ser_hurt = true;
                            ship.ShipSprite.Visual = (Visual)Application.Current.Resources["seryoja_happy"];
                            ship.ShipHp            = ship.ShipHp + (CurrentBonuses[i] as HealthBonus).health_count >= 100 ?
                                                     100 : ship.ShipHp + (CurrentBonuses[i] as HealthBonus).health_count;
                            Sounds.PlaySoundOnce("meh_" + random_for_some.Between(1, 2) + ".wav");
                        }
                        else
                        {
                            continue;
                        }
                    }
                    RemoveElementAfterAnimation(CurrentBonuses[i].bonus_rectangle);
                    CurrentBonuses.Remove(CurrentBonuses[i]);
                }
            }
        }