Exemple #1
0
 public void nextTurn(Napkin napkin, String s)
 {
     game.incrementActiveRow();
     game.changeTurns();
     napkin.changeNapkin(s);
     Invalidate(true);
 }
Exemple #2
0
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            timer1.Start();
            if (game != null)
            {
                if (MouseButtons.Left == e.Button)
                {
                    if (game.selectedFruit == null)
                    {
                        game.selectedFruit = game.doc.fruitIfHit(e.X, e.Y);
                        try
                        {
                            Stream str = Properties.Resources.pop_sound;
                            soundplayer = new SoundPlayer(str);
                            soundplayer.Play();
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    if (game.selectedFruit != null)
                    {
                        game.selectedFruit.MoveTo(e.X, e.Y);
                    }
                }

                Napkin napkin = game.getNapkin(e.X, e.Y);
                if (napkin != null)
                {
                    if (napkin.isCollision(e.X, e.Y))
                    {
                        napkin.changeNapkin("hover");
                    }
                    else
                    {
                        napkin.changeNapkin("00");
                    }
                }
            }

            //Invalidate(true);
        }
        public void InitializeNapkins()
        {
            int x          = Form1.getRatioX(440);
            int y          = Form1.getRatioY(215);
            int difference = Form1.getRatioY(47);

            if (playerID == 0)
            {
                x = Form1.getRatioX(440);
            }
            else
            {
                x = Form1.getRatioX(540);
            }
            for (int i = 0; i < 10; i++)
            {
                Napkin napkin = new Napkin(i, "00", x, y + difference * (i % 10), (int)Math.Round(50 * Form1.ratioX), (int)Math.Round(50 * Form1.ratioY));
                napkins.Add(napkin);
            }
        }
Exemple #4
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            if (game == null)
            {
                initializeGame();
            }

            if (MouseButtons.Right == e.Button && game != null)
            {
                removeFromPlate(e.X, e.Y);
                Fruit fr = game.doc.fruitIfHit(e.X, e.Y);
                placeFruit(fr);
            }
            if (MouseButtons.Left == e.Button && game != null)
            {
                Napkin napkin = game.getNapkin(e.X, e.Y);
                if (napkin.isCollision(e.X, e.Y))
                {
                    String s = game.matchingCombination();
                    if (s == null)
                    {
                        MessageBox.Show("Must fill all the plates with a fruit");
                    }
                    else
                    {
                        String gameStatus = game.gameStatus();
                        if (gameStatus == "continue")
                        {
                            nextTurn(napkin, s);
                            Player igrac = game.getActivePlayer();

                            if (igrac.isComputer)
                            {
                                this.secoudPlayerPicture.Image = Properties.Resources.computer_avatar;



                                napkin = igrac.getCurrentNapkin();
                                List <LittlePlate> lps       = igrac.getCurrentPlates();
                                List <Fruit>       fruitComb = igrac.autoplay.nextCombination();
                                for (int i = 0; i < 4; i++)
                                {
                                    fruitComb[i].MoveTo(lps[i].position.X, lps[i].position.Y);
                                    lps[i].fruitOn = fruitComb[i];
                                    Invalidate(true);
                                }



                                s          = game.matchingCombination();
                                gameStatus = game.gameStatus();
                                if (gameStatus == "continue")
                                {
                                    nextTurn(napkin, s);
                                }
                                else
                                {
                                    nextTurn(napkin, s);
                                    RevealingCombinations revealForm = new RevealingCombinations(game.player1, game.player2, gameStatus);
                                    DialogResult          result     = revealForm.ShowDialog();
                                    if (result == DialogResult.OK)
                                    {
                                        initializeGame();
                                    }
                                    else
                                    {
                                        terminateGame();
                                    }
                                }
                            }
                        }
                        else
                        {
                            nextTurn(napkin, s);
                            RevealingCombinations revealForm = new RevealingCombinations(game.player1, game.player2, gameStatus);
                            DialogResult          result     = revealForm.ShowDialog();
                            if (result == DialogResult.OK)
                            {
                                initializeGame();
                            }
                            else
                            {
                                terminateGame();
                            }
                        }
                    }
                }
            }

            Invalidate(true);
        }