public override void KeyDown(Keys key) { if (key == Keys.Escape) { GameStack.Pop(); } }
public MovingGroup(GameStack from, List <PlayingCard>?hitList, bool isMovable) { FromStack = from; IsMovable = isMovable; if (hitList != null) { MovingCards = new List <PlayingCard>(); MovingCards.AddRange(hitList); offVec = new List <Vector>(); var P0 = new Point((double)MovingCards[0].GetValue(Canvas.LeftProperty), (double)MovingCards[0].GetValue(Canvas.TopProperty)); foreach (PlayingCard pc in hitList) { var P = new Point((double)pc.GetValue(Canvas.LeftProperty), (double)pc.GetValue(Canvas.TopProperty)); offVec.Add(P - P0); } } }
private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); Stack <IGameState> s = new Stack <IGameState>(); IGameState state = null; do { state = GameStack.Peek(); if (state.OnUpdate(keyPress)) { s.Push(GameStack.Pop()); } }while (!state.Pauses && GameStack.Count > 0); while (s.Count > 0) { GameStack.Push(s.Pop()); } }
private static void OnRootConsoleRender(object sender, UpdateEventArgs e) { Stack <IGameState> s = new Stack <IGameState>(); IGameState state = null; do { state = GameStack.Peek(); state.OnRender(); if (state.Transparent) { s.Push(GameStack.Pop()); } }while (!state.Pauses && GameStack.Count > 0); while (s.Count > 0) { GameStack.Push(s.Pop()); } _rootConsole.Draw(); }
static void Main(string[] args) { GameStack gameStack = new GameStack(); GameQueue gameQueue = new GameQueue(); #region Part 1 //add spells to the stack and then pop them #region stack section //add the spells to the stack #region spells Console.WriteLine("Adding spells to the stack:"); gameStack.Push("Lightning Bolt"); Console.WriteLine(gameStack.Peek()); gameStack.Push("Snapcaster Mage"); Console.WriteLine(gameStack.Peek()); gameStack.Push("CounterSpell"); Console.WriteLine(gameStack.Peek()); gameStack.Push("TwinBolt"); Console.WriteLine(gameStack.Peek()); gameStack.Push("Daze"); Console.WriteLine(gameStack.Peek()); #endregion Console.WriteLine(); Console.WriteLine("Spells resolving in reverse order:"); //while loop to pop each item in the list while it has items in it while (gameStack.IsEmpty == false) { Console.WriteLine(gameStack.Pop()); } #endregion //spacing lines Console.WriteLine(); Console.WriteLine(); //add people to a queue and then dequeue them #region queue section //adding people to a queue #region people Console.WriteLine("People being queued a server"); gameQueue.Enqueue("Nick"); gameQueue.Enqueue("Briana"); gameQueue.Enqueue("Drake"); gameQueue.Enqueue("Nico"); gameQueue.Enqueue("Some other nerd"); //displays each of the people in the queue for (int i = 0; i < gameQueue.Count - 1; i++) { Console.WriteLine(gameQueue.Queue[i]); } #endregion //while the queue has people in it, dequeue until the list is empty Console.WriteLine(); Console.WriteLine("Adding the queued people to the server:"); while (gameQueue.IsEmpty == false) { Console.WriteLine(gameQueue.Dequeue() + " Has joined the server: " + (gameQueue.Count - 1) + " player(s) left in the queue"); } #endregion #endregion //spacing for part 2 Console.WriteLine("\n\n\n\n"); #region Part 2 //part 2 stacks //store the current page as a string, defaults to Google on startup while (true) { Console.WriteLine(); Console.WriteLine("Here are your possible controls:"); Console.WriteLine("1. visit a new webpage"); Console.WriteLine("2. move forward to the next page"); Console.WriteLine("3. navigate back to the previous page"); Console.WriteLine("4. print the current page, as well as the backward stack and forward stack"); Console.WriteLine("5. quit the loop"); string answer = Console.ReadLine(); int answerInt = 0; int.TryParse(answer, out answerInt); switch (answerInt) { case 1: currentPage = VisitPage(currentPage); break; case 2: currentPage = NextPage(currentPage); break; case 3: currentPage = PreviousPage(currentPage); break; case 4: PrintEverything(currentPage); break; case 5: return; default: Console.WriteLine("Invalid Entry, please try again"); Console.WriteLine("--------------------"); Console.WriteLine(); break; } } #endregion }
public Duel(Game game, GameState gameState) : base(game) { this.gameState = gameState; this.gameState.ActionResolved += GameState_ActionResolved; Vector2 cardSize = new Vector2(100, 126); Vector2 zoneSize = new Vector2(854, 126); /* PLAYER ONE */ playerOneHero = new Single(this, gameState.PlayerOne.PlayerCard); playerOneHero.Position = new Vector2(196, 584); playerOneHero.Size = cardSize; playerOneHealthDisplay = new Display(playerOneHero); playerOneHealthDisplay.Text = "HP: 20"; playerOneHealthDisplay.Alignment = System.Drawing.ContentAlignment.BottomRight; gameState.PlayerOne.HealthChanged += (e) => playerOneHealthDisplay.SetText(string.Format("HP: {0}", e)); playerOneDeck = new CardStack(this, gameState.PlayerOne.Deck, new Vector2(1170, 584), cardSize); playerOneGraveyard = new CardStack(this, gameState.PlayerOne.Graveyard, new Vector2(1170, 448), cardSize); playerOneGraveyard.IsFaceUp = true; playerOneHand = new CardGroup(this, new Vector2(306, 584), zoneSize, gameState.PlayerOne.Hand); playerOneElysium = new CardGroup(this, new Vector2(306, 448), zoneSize, gameState.PlayerOne.Elysium); playerOneBattlefield = new CardGroup(this, new Vector2(306, 312), zoneSize, gameState.PlayerOne.Field); playerOneHero.Clicked += PlayerOneHero_Clicked; playerOneHand.CardSelected += PlayerOneHand_CardSelected; playerOneHand.CardContextSelected += PlayerOneHand_CardContextSelected; playerOneHand.CardHovered += CardHovered; playerOneElysium.CardSelected += PlayerOneElysium_CardSelected; playerOneElysium.CardContextSelected += PlayerOneElysium_CardContextSelected; playerOneElysium.CardHovered += CardHovered; playerOneBattlefield.CardSelected += PlayerOneBattlefield_CardSelected; playerOneBattlefield.CardHovered += CardHovered; playerOneBattlefield.CardContextSelected += PlayerOneBattlefield_CardContextSelected; /* PLAYER TWO */ playerTwoHero = new Single(this, gameState.PlayerTwo.PlayerCard); playerTwoHero.Position = new Vector2(196, 10); playerTwoHero.Size = cardSize; playerTwoHero.Clicked += PlayerTwoHero_Clicked; playerTwoHealthDisplay = new Display(playerTwoHero); playerTwoHealthDisplay.Text = "HP: 20"; playerTwoHealthDisplay.Alignment = System.Drawing.ContentAlignment.BottomRight; gameState.PlayerTwo.HealthChanged += (e) => playerTwoHealthDisplay.SetText(string.Format("HP: {0}", e)); playerTwoDeck = new CardStack(this, gameState.PlayerTwo.Deck, new Vector2(1170, 10), cardSize); playerTwoGraveyard = new CardStack(this, gameState.PlayerTwo.Graveyard, new Vector2(1170, 146), cardSize); playerTwoGraveyard.IsFaceUp = true; playerTwoElysium = new CardGroup(this, new Vector2(306, 10), zoneSize, gameState.PlayerTwo.Elysium); playerTwoBattlefield = new CardGroup(this, new Vector2(306, 146), zoneSize, gameState.PlayerTwo.Field); playerTwoBattlefield.CardSelected += PlayerTwoBattlefield_CardSelected; playerTwoHandCounter = new HandCounter(this, "Content/Art/Assets/hand_count_symbol.png", new Vector2(206f, 12f)); gameState.PlayerTwo.Hand.CollectionChanged += () => { playerTwoHandCounter.Text = gameState.PlayerTwo.Hand.Count.ToString(); }; /* OTHER */ gameStackControl = new GameStack(this, new Vector2(10f, 10f), new Vector2(175f, 470f)); gameState.NewStateAction += (e) => gameStackControl.AddGameStack(e); phaseTracker = new PhaseTracker(this, new Vector2(304f, 280f), gameState); previewCard = new Single(this, null); previewCard.Position = new Vector2(10f, 490f); previewCard.Size = new Vector2(175f, 220f); previewCard.IgnoreCardStates = true; promptBox = new TextBox(this, string.Empty, 12f); promptBox.Position = new Vector2(1175f, 287f); gameState.PlayerOne.Prompt += (e) => promptBox.SetText(e); continueButton = new Button(this, "Continue", 12f); continueButton.Position = new Vector2(1170, 388); continueButton.OnClick += ContinueButton_Click; endTurnButton = new Button(this, "End Turn", 12f); endTurnButton.Position = new Vector2(1170, 418); endTurnButton.OnClick += EndTurnButton_Click; Menu.ItemSelected += Menu_ItemSelected; castingController = new CastingController(gameState, gameState.PlayerOne); castingController.CostPaid += CastingController_CostPaid; castingController.Canceled += CastingController_Canceled; }
static void CopyStack(GameStack st, out List <(SolverCard, bool)> solverSt)
private void TransToMainMenu() { Thread.Sleep(3000); GameStack.Push(GameStack.MakeItem <MainMenuStackItem>()); }
void IGameSetters.SetGameModeStack(GameStack gameStack) { throw new NotImplementedException(); }