/* 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); }
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; } }
/* 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); }
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 }; }
/* 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); }
/* 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); }
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); }
/* 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); } }
/* 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); }
public UIButtonElement createNewElement(UIButtonElement Element, int index) { return(this.createNewElement(Element, index, 3)); // TODO fix }
public UIButtonElement createNewElement(UIButtonElement Element, int index, int total) { Element.instantiateElement(CardConstants.handStartPosition, this.getNextPosition(index, total)); return(Element); }
/* trying to keep certain variables private */ public void setElement(UIButtonElement e) { Element = e; }
// public UIButtonElement getCardInUnknownList(UIButtonElement card) { return(unknownList.Find(item => item.ID == card.ID)); }
public void handleUseAction(UIButtonElement Element) { Singletons.Instantiator.instantiateObject(Element.Type); }
// clicked on UI public void onUseAction(UIButtonElement Element) { this.handleUseAction(Element); CurrentTurn++; }