Пример #1
0
 public ResourceWindow(Resources res)
 {
     this.rc = res;
     InitializeComponent();
     createButtons();
     createValueFields();            
 }
 public ResourceBuying(Resources res, Card c, PlayerGameBoard p)
 {
     rc = res;
     card = c;
     board = p;
     you = rm.getGameState().getPlayerNum(rc.getPlayerName()[1]);
     
     InitializeComponent();
     createButtons();
     createValueFields();
 }
Пример #3
0
        public WonderBuyingWindow(Resources res, Card c, PlayerGameBoard p, GameState g)
        {
            resources = res;
            card      = c;
            board     = p;
            game      = g;
            manager   = ResourceManager.GetInstance();
            you       = manager.getGameState().getPlayerNum(resources.getPlayerName()[1]);

            InitializeComponent();
            createButtons();
            createValueFields();
        }
Пример #4
0
        public ResourceBuying(Resources res, Card c, PlayerGameBoard p, GameState g)
        {
            resources = res;

            //Console.WriteLine(resources.ToString());
            
            card    = c;
            board   = p;
            game    = g;
            manager = ResourceManager.GetInstance();


            you = manager.getGameState().getPlayerNum(resources.getPlayerName()[1]);
            
            InitializeComponent();
            createButtons();
            createValueFields();
        }
Пример #5
0
 public static WonderBuyingWindow GetInstance(Resources r, Card c, PlayerGameBoard p, GameState g)
 {
     if (_instance == null)
     {
         _instance = new WonderBuyingWindow(r, c, p, g);
     }
     else
     {
         _instance.Close();
         _instance.reset();
         _instance = new WonderBuyingWindow(r, c, p, g);
     }
     return _instance;
 }
Пример #6
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.ValidateWonder(you))//ok check if you can play the card now.
                {
                    you.getHand().Remove(card);//remove from cards in hand of player
                    you.setPlayedACard();//set true
                    game.incrementTurn();
                    you.setWonderCards(card);
                    you.getBoard().incrementWonderLevel(you);
                    this.Close();
                    PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                }
                else
                {
                    this.Close();

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

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

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

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

                    if (manager.ValidateWonder(you))//ok check if you can play the card now.
                    {
                        you.getHand().Remove(card);//remove from cards in hand of player
                        you.setPlayedACard();//set true
                        game.incrementTurn();
                        you.setWonderCards(card);
                        you.getBoard().incrementWonderLevel(you);
                        this.Close();
                        PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                    }
                    else
                    {
                        this.Close();

                        WonderBuyingWindow window = new WonderBuyingWindow(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.ValidateWonder(you))//ok check if you can play the card now.
                    {
                        you.getHand().Remove(card);//remove from cards in hand of player
                        you.setPlayedACard();//set true
                        game.incrementTurn();
                        you.setWonderCards(card);
                        you.getBoard().incrementWonderLevel(you);
                        this.Close();
                        PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, manager.getGameState());
                    }
                    else
                    {
                        this.Close();

                        WonderBuyingWindow window = new WonderBuyingWindow(resources, card, board, game);
                        window.Show();
                    }
                }
            }
        }
 public static ResourceBuying GetInstance(Resources r, Card c, PlayerGameBoard p)
 {
     if (_instance == null)
     {
         _instance = new ResourceBuying(r, c, p);
     }
     else
     {
         _instance.Close();
         _instance = new ResourceBuying(r, c, p);
     }
     return _instance;
 }
        //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
            }

            Console.WriteLine("Button Number: " + index);
            
            if(index > 0 && index < 8)
            {

                this.Hide();

                rm.usingSpecialResource(you, index-1);                
                
                //rm.resetSpecialResources(you);

                rc = rm.GetCombinedResources(you);

                ResourceBuying window = ResourceBuying.GetInstance(rc, card, board);                
                
                if (rm.ValidateCard(you, card))//ok check if you can play the card now.
                {                    
                    //window.Hide();
                    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
                    rm.getGameState().incrementTurn();

                    //refresh the view
                    PlayerGameBoard play = new PlayerGameBoard(board.getGrid(), you, rm.getGameState());
                }
                else
                {                    
                    window.Show();
                }
                Console.WriteLine("Player: " + you.getName() + " Calling Special: index currently: " + (index-1));
            }
        }