Esempio n. 1
0
        private void setButtons(Thingy rockthingy, Thingy paperthingy, Thingy scissorsthingy)
        {
            rock.Background     = new SolidColorBrush(Colors.Gray);
            paper.Background    = new SolidColorBrush(Colors.Gray);
            scissors.Background = new SolidColorBrush(Colors.Gray);
            image.Stretch       = Stretch.Fill;
            BitmapImage paperImg = new BitmapImage();

            image.Width        = paperImg.DecodePixelWidth = 280;
            paperImg.UriSource = new Uri("ms-appx:///Assets/ic_launcher.png");
            image.Source       = paperImg;
            rock.Content       = rockthingy.getName();
            paper.Content      = paperthingy.getName();
            scissors.Content   = scissorsthingy.getName();
            textBlock.Text     = "Come on then.";
            textBlock1.Text    = go / 3 + "";
        }
Esempio n. 2
0
        private void haveGo(Thingy rock, Thingy paper, Thingy scissors, int turn, Button button)

        {
            string gloater = "balls balls balls";

            image.Stretch = Stretch.Fill;
            BitmapImage bitmapImage = new BitmapImage();

            image.Width           = bitmapImage.DecodePixelWidth = 280;
            bitmapImage.UriSource = new Uri("ms-appx:///Assets/ic_launcher.png");
            image.Source          = bitmapImage;

            int cpu = rnd.Next(1, 4);

            switch (cpu)
            {
            case 1:
                cpuname = rock.getName();
                cpuverb = rock.getVerb();
                break;

            case 2:
                cpuname = paper.getName();
                cpuverb = paper.getVerb();
                break;

            case 3:
                cpuname = scissors.getName();
                cpuverb = scissors.getVerb();
                break;
            }


            int result = -1;


            if (turn == 1)
            {
                name = rock.getName();
                verb = rock.getVerb();


                if (cpu == 1)
                {
                    result = DRAW;
                }

                if (cpu == 2)
                {
                    result = LOSE;
                    setPic(rock);
                }

                if (cpu == 3)
                {
                    //gloatString = ;
                    setPic(scissors);
                    result = WIN;
                }

                gloater = rock.getGloatwin(result);
            }
            if (turn == 2)

            {
                name = paper.getName();
                verb = paper.getVerb();

                if (cpu == 1)
                {
                    result = WIN;
                    setPic(scissors);
                }

                if (cpu == 2)
                {
                    result = DRAW;
                }

                if (cpu == 3)
                {
                    result = LOSE;
                    setPic(paper);
                }
                gloater = paper.getGloatwin(result);
            }


            if (turn == 3)
            {
                name = scissors.getName();
                verb = scissors.getVerb();

                if (cpu == 1)
                {
                    result = LOSE; setPic(scissors);
                }
                if (cpu == 2)
                {
                    result = WIN;
                    setPic(paper);
                }

                if (cpu == 3)
                {
                    result = DRAW;
                }
                gloater = scissors.getGloatwin(result);
            }


            if (result == DRAW)
            {
                //tester.Text = turn + " " + cpu + " " + "DRAW" + name + verb + cpu + cpuname + cpuverb;
                gloatString = ("You chose " + name + ".\nWe chose " + cpuname + ".\nA draw.\n" +
                               name + " likes " + cpuname + ".");
                //   gloater += ("You chose " + name + " We chose " + cpuname + " draw " +
                //              name + " likes " + cpuname + " ");
            }
            if (result == WIN)
            {
                // tester.Text = turn + " " + cpu + " " + "WIN" + name + verb + cpu + cpuname + cpuverb;
                gloatString = "You chose " + name + ".\nWe chose " + cpuname + ".\nYou win!\n"
                              + name + " " + verb + " " + cpuname + ".";
                // gloater += "You chose " + name + " We chose " + cpuname + " You win!"
                //                 + name + " " + verb + " " + cpuname + " ";
            }
            if (result == LOSE)
            {
                // tester.Text = turn + " " + cpu + " " + "LOSE" + name + verb + cpu + cpuname + cpuverb;
                gloatString = ("You chose " + name + ".\nWe chose " +
                               cpuname + ".\nYou lose.\n"
                               + cpuname + " " +
                               cpuverb + " " + name + ".");
                //   gloater += ("You chose " + name + " We chose " +
                //             cpuname + " You lose "
                //         + cpuname + " " +
                //          cpuverb + " " + name + " ");
            }
            gloatStringPlus = gloater;

            if (result == WIN)
            {
                go += 3;
                button.Background = new SolidColorBrush(Colors.Green);
            }

            if (result == LOSE)
            {
                go = 0; button.Background = new SolidColorBrush(Colors.Red);
            }

            if (result == DRAW)
            {
                button.Background = new SolidColorBrush(Colors.Orange);
            }
            yourTurn = false;
        }