Esempio n. 1
0
    /* instantiates al the new list of cards in the current Hand */
    public List <UIButtonElement> instanciateHandView(List <UIButtonElement> newHandList)
    {
        HandList = new List <UIButtonElement>();

        for (int i = 0; i < newHandList.Count; i++)
        {
            UIButtonElement instantiatedElement = this.createNewElement(newHandList[i], i);
            HandList.Add(instantiatedElement);
        }

        return(HandList);
    }
Esempio n. 2
0
        public void OnClick(object sender, EventArgs e)
        {
            UIButtonElement active = Buttons.Find(x => x.Active);

            if (active == StartButton)
            {
                Game.CurrentState = States.GamePreload;
            }
            else if (active == DifficultyButton)
            {
                GameOptions.Difficulty++;
                DifficultyButton.Text = DifficultyText;
            }
        }
Esempio n. 3
0
    /* returns a UIButtonElement list for the current Hand */
    public List <UIButtonElement> setupHandList()
    {
        List <UIButtonElement> handList = new List <UIButtonElement>();

        for (int i = 0; i < currentHandSize; i++)
        {
            UIButtonElement card = Deck.drawCard();
            handList.Add(card);
        }

        Hand.instanciateHandView(handList);

        return(handList);
    }
Esempio n. 4
0
 public MainMenu(Game game)
 {
     Game        = game;
     GameOptions = new GameOptions
     {
         Difficulty = 5
     };
     Font             = new Font("Microsoft Sans Serif", 14, FontStyle.Bold, GraphicsUnit.Pixel);
     StartButton      = new UIButtonElement("Start Game", (int)(Game.CanvasWidth * 0.5) - 100, (int)(Game.CanvasHeight * 0.5), 200, 40, Brushes.LightGray, Brushes.Gray, Brushes.Black, Brushes.White, Font);
     DifficultyButton = new UIButtonElement(DifficultyText, (int)(Game.CanvasWidth * 0.5) - 100, (int)(Game.CanvasHeight * 0.6), 200, 40, Brushes.LightGray, Brushes.Gray, Brushes.Black, Brushes.White, Font);
     Buttons          = new List <UIButtonElement> {
         StartButton, DifficultyButton
     };
 }
Esempio n. 5
0
    /* puts given card into discardDeck */
    public List <UIButtonElement> discardCard(UIButtonElement card)
    {
        discardDeck.Add(card);

        // remove it from our unknown list
        UIButtonElement cardInUnknown = getCardInUnknownList(card);

        if (cardInUnknown != null)
        {
            unknownList.Remove(cardInUnknown);
        }

        return(discardDeck);
    }
Esempio n. 6
0
    /* reorders everything inside current deck */
    public List <UIButtonElement> shuffleCurrentDeck()
    {
        List <UIButtonElement> tempDeck = currentDeck;
        int n = tempDeck.Count;

        for (int i = 0; i < tempDeck.Count; i++)
        {
            int             k        = Random.Range(i, tempDeck.Count - 1);
            UIButtonElement tempCard = tempDeck[k];
            tempDeck[k] = tempDeck[i];
            tempDeck[i] = tempCard;
        }
        return(tempDeck);
    }
Esempio n. 7
0
        public GameOverScreen(Game game, int scores)
        {
            Game   = game;
            Scores = scores;
            Font         font    = new Font("Microsoft Sans Serif", 28, FontStyle.Bold, GraphicsUnit.Pixel);
            Font         fontBtn = new Font("Microsoft Sans Serif", 14, FontStyle.Bold, GraphicsUnit.Pixel);
            StringFormat format  = new StringFormat
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            };

            GameOverText     = new UITextElement("GAME OVER", font, Brushes.White, game.CanvasWidth / 2, game.CanvasHeight / 2 - 16, format);
            ScoresText       = new UITextElement("Yours score: " + Scores, font, Brushes.White, game.CanvasWidth / 2, game.CanvasHeight / 2 + 16, format);
            BackToMenuButton = new UIButtonElement("BACK TO MENU", game.CanvasWidth / 2 - 100, (int)(game.CanvasHeight * 0.7), 200, 30, Brushes.LightGray, Brushes.Gray, Brushes.Black, Brushes.White, fontBtn);
        }
Esempio n. 8
0
 /* draws the next card in the currentDeck */
 public UIButtonElement drawCard()
 {
     if (currentDeck.Count <= 0)
     {
         this.handleShuffleDiscardToDeck();
         return(this.drawCard());
     }
     else
     {
         // todo: implement a pop() method?
         UIButtonElement card = currentDeck[0]; // get the top card
         unknownList.Add(card);
         currentDeck.Remove(card);              // remove it from current deck
         return(card);
     }
 }
Esempio n. 9
0
    /* creates the initial list of Card Elements for a new deck */
    public List <UIButtonElement> createDeck(List <string> cardList)
    {
        List <UIButtonElement> tempDeck = new List <UIButtonElement>();

        for (int i = 0; i < cardList.Count; i++)
        {
            string          newType = cardList[i];
            UIButtonElement newCard = new UIButtonElement();

            // set stuff to be created
            newCard.ID   = "id-" + i;
            newCard.Type = cardList[i];

            tempDeck.Add(newCard);
        }
        ;
        return(tempDeck);
    }
Esempio n. 10
0
 public UIButtonElement createNewElement(UIButtonElement Element, int index)
 {
     return(this.createNewElement(Element, index, 3)); // TODO fix
 }
Esempio n. 11
0
 public UIButtonElement createNewElement(UIButtonElement Element, int index, int total)
 {
     Element.instantiateElement(CardConstants.handStartPosition, this.getNextPosition(index, total));
     return(Element);
 }
Esempio n. 12
0
 /* trying to keep certain variables private */
 public void setElement(UIButtonElement e)
 {
     Element = e;
 }
Esempio n. 13
0
 //
 public UIButtonElement getCardInUnknownList(UIButtonElement card)
 {
     return(unknownList.Find(item => item.ID == card.ID));
 }
Esempio n. 14
0
 public void handleUseAction(UIButtonElement Element)
 {
     Singletons.Instantiator.instantiateObject(Element.Type);
 }
Esempio n. 15
0
 // clicked on UI
 public void onUseAction(UIButtonElement Element)
 {
     this.handleUseAction(Element);
     CurrentTurn++;
 }