コード例 #1
0
 public static ResourceBuying GetInstance()
 {
     if (_instance == null)
     {
         _instance = new ResourceBuying(null, null, null, null);
     }
     return(_instance);
 }
コード例 #2
0
 public static ResourceBuying GetInstance(Resources r, Card c, PlayerGameBoard p, GameState g)
 {
     if (_instance == null)
     {
         _instance = new ResourceBuying(r, c, p, g);
     }
     else
     {
         _instance.Close();
         _instance.reset();
         _instance = new ResourceBuying(r, c, p, g);
     }
     return(_instance);
 }
コード例 #3
0
//Mouse Click for "Play Card" button
        public void playerMoveButton_Click(object sender, EventArgs e)
        {
            if (player.getPlayedACard() == false)
            {
                int numCards = player.getHand().Count;

                for (int i = 0; i < player.getHand().Count; i++)
                {
                    Card  c   = player.getHand()[i];
                    Image img = (Image)playBoard.Children[(56 + i)];

                    if (img.ActualHeight > 150)//this is the selected card
                    {
                        if (img.Source != new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/EmptyCard.png", UriKind.RelativeOrAbsolute));
                                PlayerGameBoard play = new PlayerGameBoard(parent, player, game);
                            }
                            else
                            {
                                ResourceManager manager = ResourceManager.GetInstance(game);
                                manager.resetResources(player);

                                ResourceBuying window = new ResourceBuying(ResourceManager.GetInstance().GetCombinedResources(player), c, this, game);
                                window.Show();
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void buttonPlay_Click(object sender, RoutedEventArgs e)
        {
            if (rm.ValidateCard(player, cardToPlay))
            {
                player.addPlayedCards(cardToPlay);
                this.Close();
                PlayerGameBoard play = new PlayerGameBoard(parent, player, rm.getGameState());
            }
            else
            {
                this.Close();
                ResourceManager manager = ResourceManager.GetInstance(rm.getGameState());
                manager.resetResources(player);

                ResourceBuying window = new ResourceBuying(ResourceManager.GetInstance().GetCombinedResources(player), cardToPlay, view, rm.getGameState());
                window.Show();
            }
        }
コード例 #5
0
 public void reset()
 {
     _instance = null;
 }
コード例 #6
0
 public static ResourceBuying GetInstance(Resources r, Card c, PlayerGameBoard p, GameState g)
 {
     if (_instance == null)
     {
         _instance = new ResourceBuying(r, c, p, g);
     }
     else
     {
         _instance.Close();
         _instance.reset();
         _instance = new ResourceBuying(r, c, p, g);
     }
     return _instance;
 }
コード例 #7
0
 public static ResourceBuying GetInstance()
 {
     if (_instance == null)
     {
         _instance = new ResourceBuying(null, null, null, null);
     }
     return _instance;
 }
コード例 #8
0
// This button click handler finds which button you pressed and then modifies the appropriate 
// Player resources as well calling methods for removing and adding money
// B[1,7] = YOU, B[8,14] = LEFT, B[15-21] = RIGHT
        private void buyButton_Click(object sender, RoutedEventArgs e)
        {
            Button b = (Button)sender;
            string name = b.Name;//have button name will travel
            
            int index;

            if (name.Length > 2)
            {
                index = ((int)Char.GetNumericValue(name[1])*10) + (int)Char.GetNumericValue(name[2]);
            }
            else
            {
                index = (int)Char.GetNumericValue(name[1]);//know which number
            }
            
            if(index > 0 && index < 8)//Player clicked on YOU
            {
                
                manager.usingSpecialResource(you, (index-1));
                resources = manager.GetCombinedResources(you);                
             
                if (manager.ValidateCard(you, card))//ok check if you can play the card now.
                {                    
                    you.addPlayedCards(card);//add to the playerState
                    board.changeCard(card);//adds to the board cards                    
                    you.setPlayedACard();//set true
                    you.getHand().Remove(card);//remove from cards in hand of player
                    manager.getGameState().incrementTurn();
                    this.Close();
                    PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                }
                else
                {           
                    this.Close();

                    ResourceBuying window = new ResourceBuying(resources, card, board, game);
                    window.Show();
                }
                
            }

            if (index > 7 && index < 15)//Player clicked on LEFT
            {
                int i = (index-8);

                if (manager.canAfford(you))
                {
                    Canvas c = (Canvas)board.getGrid().Children[1];
                    Label l = (Label)c.Children[90];
                    l.Content = " " + manager.getCoinTransaction();

                    Console.WriteLine("YOU current money: " + you.getCoins()); 
                    manager.tradeTo(you, i, 0);
                    resources = manager.GetCombinedResources(you); 

                    if (manager.ValidateCard(you, card))//ok check if you can play the card now.
                    {
                        you.addPlayedCards(card);//add to the playerState
                        board.changeCard(card);//adds to the board cards                    
                        you.setPlayedACard();//set true
                        you.getHand().Remove(card);//remove from cards in hand of player
                        manager.getGameState().incrementTurn();
                        this.Close();
                        PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                    }
                    else
                    {
                        this.Close();
                        ResourceBuying window = new ResourceBuying(resources, card, board, game);
                        window.Show();
                    }
                }
            }

            if (index > 14 && index < 22)//Player clicked on RIGHT
            {
                int i = (index - 15);//0-6 the resource traded
                
                if (manager.canAfford(you))
                {
                    Canvas c = (Canvas)board.getGrid().Children[1];
                    Label l = (Label)c.Children[90];
                    l.Content = " " + manager.getCoinTransaction();

                    manager.tradeTo(you, i, 1);
                    resources = manager.GetCombinedResources(you); 

                    if (manager.ValidateCard(you, card))//ok check if you can play the card now.
                    {
                        you.addPlayedCards(card);//add to the playerState
                        board.changeCard(card);//adds to the board cards                    
                        you.setPlayedACard();//set true
                        you.getHand().Remove(card);//remove from cards in hand of player
                        manager.getGameState().incrementTurn();
                        this.Close();
                        PlayerGameBoard playt = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                    }
                    else
                    {
                        this.Close();
                        ResourceBuying window = new ResourceBuying(resources, card, board, game);
                        window.Show();
                    }
                }
            }
        }
コード例 #9
0
 public void reset()
 {
     _instance = null;
 }
コード例 #10
0
// This button click handler finds which button you pressed and then modifies the appropriate
// Player resources as well calling methods for removing and adding money
// B[1,7] = YOU, B[8,14] = LEFT, B[15-21] = RIGHT
        private void buyButton_Click(object sender, RoutedEventArgs e)
        {
            Button b    = (Button)sender;
            string name = b.Name;//have button name will travel

            int index;

            if (name.Length > 2)
            {
                index = ((int)Char.GetNumericValue(name[1]) * 10) + (int)Char.GetNumericValue(name[2]);
            }
            else
            {
                index = (int)Char.GetNumericValue(name[1]);//know which number
            }

            if (index > 0 && index < 8)//Player clicked on YOU
            {
                manager.usingSpecialResource(you, (index - 1));
                resources = manager.GetCombinedResources(you);

                if (manager.ValidateCard(you, card)) //ok check if you can play the card now.
                {
                    you.addPlayedCards(card);        //add to the playerState
                    board.changeCard(card);          //adds to the board cards
                    you.setPlayedACard();            //set true
                    you.getHand().Remove(card);      //remove from cards in hand of player


                    manager.getGameState().incrementTurn();
                    this.Close();
                    PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                }
                else
                {
                    this.Close();

                    ResourceBuying window = new ResourceBuying(resources, card, board, game);
                    window.Show();
                }
            }

            if (index > 7 && index < 15)//Player clicked on LEFT
            {
                int i = (index - 8);

                if (manager.canAfford(you))
                {
                    Canvas c = (Canvas)board.getGrid().Children[1];
                    Label  l = (Label)c.Children[90];
                    l.Content = " " + manager.getTempCoins(you);

                    Console.WriteLine("YOU current money: " + you.getCoins());
                    manager.tradeTo(you, i, 0);
                    resources = manager.GetCombinedResources(you);

                    if (manager.ValidateCard(you, card)) //ok check if you can play the card now.
                    {
                        you.addPlayedCards(card);        //add to the playerState
                        board.changeCard(card);          //adds to the board cards
                        you.setPlayedACard();            //set true
                        you.getHand().Remove(card);      //remove from cards in hand of player

                        manager.getGameState().incrementTurn();
                        this.Close();
                        PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                    }
                    else
                    {
                        this.Close();
                        ResourceBuying window = new ResourceBuying(resources, card, board, game);
                        window.Show();
                    }
                }
            }

            if (index > 14 && index < 22) //Player clicked on RIGHT
            {
                int i = (index - 15);     //0-6 the resource traded

                if (manager.canAfford(you))
                {
                    Canvas c = (Canvas)board.getGrid().Children[1];
                    Label  l = (Label)c.Children[90];
                    l.Content = " " + manager.getTempCoins(you);

                    manager.tradeTo(you, i, 1);
                    resources = manager.GetCombinedResources(you);

                    if (manager.ValidateCard(you, card)) //ok check if you can play the card now.
                    {
                        you.addPlayedCards(card);        //add to the playerState
                        board.changeCard(card);          //adds to the board cards
                        you.setPlayedACard();            //set true
                        you.getHand().Remove(card);      //remove from cards in hand of player

                        manager.getGameState().incrementTurn();
                        this.Close();
                        PlayerGameBoard playt = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                    }
                    else
                    {
                        this.Close();
                        ResourceBuying window = new ResourceBuying(resources, card, board, game);
                        window.Show();
                    }
                }
            }
        }
コード例 #11
0
ファイル: PlayerGameBoard.cs プロジェクト: sunneh/7Wonders
//Mouse Click for "Play Card" button
        private void playerMoveButton_Click(object sender, EventArgs e)
        {
            if (player.getPlayedACard() == false)
            {               
                int numCards = player.getHand().Count;

                for (int i = 0; i < player.getHand().Count; i++)
                {
                    Card c = player.getHand()[i];
                    Image img = (Image)playBoard.Children[(56 + i)];

                    if (img.ActualHeight > 150)//this is the selected card
                    {
                        if (img.Source != new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Images/EmptyCard.png", UriKind.RelativeOrAbsolute));
                                PlayerGameBoard play = new PlayerGameBoard(parent, player, game);
                            }
                            else
                            {
                                ResourceManager manager = ResourceManager.GetInstance(game);
                                manager.resetResources(player);

                                ResourceBuying window = new ResourceBuying(ResourceManager.GetInstance().GetCombinedResources(player), c, this, game);
                                window.Show();
                            }
                        }
                    }                    
                }
            }
        }
コード例 #12
0
 private void mainWindow_Closed(object sender, EventArgs e)
 {
     //ResourceManager.GetInstance().Reset();
     ResourceBuying.GetInstance().reset();
     ResourceBuying.GetInstance().Close();
 }