Exemple #1
0
        private void dispatkunai(object sender, EventArgs e)
        {
            if (KunaC == 1)
            {
                double d = Math.Sqrt(Math.Pow(Canvas.GetTop(kunai) - Canvas.GetTop(boss), 2) + Math.Pow(Canvas.GetLeft(kunai) - Canvas.GetLeft(boss), 2));

                if (shibi <= 100)
                {
                    if (Canvas.GetLeft(kunai) >= 0)
                    {
                        Canvas.SetLeft(kunai, Canvas.GetLeft(kunai) + 20);
                    }
                    else
                    {
                        Canvas.SetLeft(kunai, -122);
                    }
                    if (d <= 152)
                    {
                        BossHP.Value -= 25;
                        Canvas.SetLeft(kunai, Canvas.GetLeft(kunai) - 1000);
                        Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 50);
                        if (BossHP.Value <= 0)
                        {
                            MainWindow.MN += 100; //add money
                            label1.Content = "$  " + MainWindow.MN;
                            Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 1000);
                            Winner wn = new Winner();
                            wn.Show();
                            this.Hide();
                            timer.Stop();
                            timerKunai.Stop();
                            timerBoss.Stop();
                        }
                    }
                }
            }
            else if (BomC == 1)
            {
                double d = Math.Sqrt(Math.Pow(Canvas.GetTop(bomb) - Canvas.GetTop(boss), 2) + Math.Pow(Canvas.GetLeft(bomb) - Canvas.GetLeft(boss), 2));

                if (shibi <= 100)
                {
                    if (Canvas.GetLeft(bomb) >= 0)
                    {
                        Canvas.SetLeft(bomb, Canvas.GetLeft(bomb) + 20);
                    }
                    else
                    {
                        Canvas.SetLeft(bomb, -122);
                    }
                    if (d <= 152)
                    {
                        BossHP.Value -= 40;
                        Canvas.SetLeft(bomb, Canvas.GetLeft(bomb) - 1000);
                        Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 50);
                        if (BossHP.Value <= 0)
                        {
                            MainWindow.MN += 100; //add money
                            label1.Content = "$  " + MainWindow.MN;
                            Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 1000);
                            Winner wn = new Winner();
                            wn.Show();
                            this.Hide();
                            timer.Stop();
                            timerKunai.Stop();
                            timerBoss.Stop();
                        }
                    }
                }
            }
            else if (ShuC == 1)
            {
                double d = Math.Sqrt(Math.Pow(Canvas.GetTop(shuriken) - Canvas.GetTop(boss), 2) + Math.Pow(Canvas.GetLeft(shuriken) - Canvas.GetLeft(boss), 2));

                if (shibi <= 100)
                {
                    if (Canvas.GetLeft(shuriken) >= 0)
                    {
                        Canvas.SetLeft(shuriken, Canvas.GetLeft(shuriken) + 20);
                    }
                    else
                    {
                        Canvas.SetLeft(shuriken, -122);
                    }
                    if (d <= 152)
                    {
                        BossHP.Value -= 15;
                        Canvas.SetLeft(shuriken, Canvas.GetLeft(shuriken) - 1000);
                        Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 50);
                        if (BossHP.Value <= 0)
                        {
                            MainWindow.MN += 100; //add money
                            label1.Content = "$  " + MainWindow.MN;
                            Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 1000);
                            Winner wn = new Winner();
                            wn.Show();
                            this.Hide();
                            timer.Stop();
                            timerKunai.Stop();
                            timerBoss.Stop();
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void dispatBoss(object sender, EventArgs e)
        {
            double d = Math.Sqrt(Math.Pow(Canvas.GetTop(boss) - Canvas.GetTop(player), 2) + Math.Pow(Canvas.GetLeft(boss) - Canvas.GetLeft(player), 2));

            if (d >= 200)
            {
                if (statusBoss == 1)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (2).png", UriKind.Relative));
                    statusBoss  = 2;
                }
                else if (statusBoss == 2)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (3).png", UriKind.Relative));
                    statusBoss  = 3;
                }
                else if (statusBoss == 3)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (4).png", UriKind.Relative));
                    statusBoss  = 4;
                }
                else if (statusBoss == 4)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (5).png", UriKind.Relative));
                    statusBoss  = 5;
                }
                else if (statusBoss == 5)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (6).png", UriKind.Relative));
                    statusBoss  = 6;
                }
                else if (statusBoss == 6)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (7).png", UriKind.Relative));
                    statusBoss  = 7;
                }
                else if (statusBoss == 7)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (8).png", UriKind.Relative));
                    statusBoss  = 8;
                }
                else if (statusBoss == 8)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (9).png", UriKind.Relative));
                    statusBoss  = 9;
                }
                else if (statusBoss == 9)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (10).png", UriKind.Relative));
                    statusBoss  = 10;
                }
                else if (statusBoss == 10)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\idle 2 (1).png", UriKind.Relative));
                    statusBoss  = 1;
                }
            }
            else if (d <= 199)
            {
                if (statusBoss == 1)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss2.png", UriKind.Relative));
                    statusBoss  = 2;
                }
                else if (statusBoss == 2)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss3.png", UriKind.Relative));
                    statusBoss  = 3;
                }
                else if (statusBoss == 3)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss4.png", UriKind.Relative));
                    statusBoss  = 4;
                }
                else if (statusBoss == 4)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss5.png", UriKind.Relative));
                    statusBoss  = 5;
                }
                else if (statusBoss == 5)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss6.png", UriKind.Relative));
                    statusBoss  = 6;
                }
                else if (statusBoss == 6)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss7.png", UriKind.Relative));
                    statusBoss  = 7;
                }
                else if (statusBoss == 7)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss8.png", UriKind.Relative));
                    statusBoss  = 8;
                }
                else if (statusBoss == 8)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss9.png", UriKind.Relative));
                    statusBoss  = 9;
                }
                else if (statusBoss == 9)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss10.png", UriKind.Relative));
                    statusBoss  = 10;
                }
                else if (statusBoss == 10)
                {
                    boss.Source = new BitmapImage(new Uri(@"\res\Boss1.png", UriKind.Relative));
                    statusBoss  = 1;
                }
            }


            if (d < 100)
            {
                if (keyK == true)
                {
                    BossHP.Value -= 20;
                    Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 50);
                    if (BossHP.Value <= 0)
                    {
                        MainWindow.MN += 100; //add money
                        label1.Content = "$  " + MainWindow.MN;
                        Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 1000);
                        Winner wn = new Winner();
                        wn.Show();
                        this.Hide();
                        timer.Stop();
                        timerKunai.Stop();
                        timerBoss.Stop();
                    }
                }
            }
            if (d < 100 && Canvas.GetLeft(player) >= 0)
            {
                playerHP.Value -= 20;
                Canvas.SetLeft(player, Canvas.GetLeft(player) - 50);
                if (playerHP.Value <= 0)
                {
                    final.result = "GAME OVER";
                    final fn = new final();
                    fn.Show();
                    this.Hide();
                    timer.Stop();
                    timerKunai.Stop();
                    timerBoss.Stop();
                }
            }


            Random rn = new Random();
            {
                if (rn.Next(10) >= 8)
                {
                    Canvas.SetLeft(boss, Canvas.GetLeft(boss) + 20);
                }
                else if (Canvas.GetLeft(boss) >= Canvas.GetLeft(player))
                {
                    Canvas.SetLeft(boss, Canvas.GetLeft(boss) - 20);
                }
            }
        }