private void NodeChosen(Node node, GameInfo gameInfo, IGameState waitState) { gameInfo.Fsm.Remove(waitState); gameInfo.ClearTargets(); gameInfo.PanCameraToObject(gameInfo.CurrentPlayer); var currentPlayer = gameInfo.CurrentPlayer; currentPlayer.NextNode = node; // Give the player a passport for the island they are going to arrive at var assetResponse = currentPlayer.Accept(new PassportStamp(((Travel)node.BindedLogic.PureLogic).IslandType)); // Give the player a car modification if required currentPlayer.SetTransport(TransportType); if (assetResponse == AssetResponse.CollectedAllPassportStamps) { if (gameInfo.GameRuleType == GameRuleType.Passport) { gameInfo.Fsm.LazyPush(StateFactory.GetState(GameStates.GameStates.EndGame)); } } gameInfo.CreateMessage(String.Format("You have been given a {0} passport token!", IslandType)); gameInfo.Fsm.Push(StateFactory.GetState(GameStates.GameStates.VisuallyMovePlayer)); }
private void BuyNewHouse(ConfirmWindow window, GameInfo gameInfo, IGameState waitState) { gameInfo.CurrentPlayer.Accept(House); CloseWindow(window, gameInfo, waitState); gameInfo.CreateMessage(String.Format("{0} just bought a house!", gameInfo.CurrentPlayer.Name)); }
private void SellCurrentHouse(ConfirmWindow window, GameInfo gameInfo, IGameState waitState) { gameInfo.CurrentPlayer.Remove(gameInfo.CurrentPlayer.House); gameInfo.CreateMessage(String.Format("{0} just sold a house!", gameInfo.CurrentPlayer.Name)); window.Close(); OfferPlayerHouse(gameInfo, waitState); }
private void TakeNextPlayerBet(GameInfo gameInfo) { if (playerNum == -1) { bettingPlayer = gameInfo.CurrentPlayer; gameInfo.CreateMessage(String.Format("{0} Place your extra bet!", bettingPlayer.Name)); } else if (playerNum < gameInfo.PlayerList.Count()) { bettingPlayer = gameInfo.PlayerList[playerNum]; gameInfo.CreateMessage(String.Format("{0} Place your bet!", bettingPlayer.Name)); } else { gameInfo.CreateMessage("Click the spinner to see who won!"); gameInfo.Spinner.ListenMouseDown -= placeBetDelegate; gameInfo.Fsm.Remove(waitState); } }
private static void CleanUp(Node node, Vector2 location, GameInfo gameInfo) { gameInfo.CreateMessage(String.Empty); gameInfo.ClearTargets(); foreach (var possibleNode in _possibleNodes) { possibleNode.RememberColorState(ColorState.None); possibleNode.SetColorState(ColorState.None); possibleNode.ListenMouseDown -= _cleanupCallback; possibleNode.ListenMouseDown -= _callback; } }
private IGameState[] WinnerFound(GameInfo gameInfo, Player player) { gameInfo.Content.Load <SoundEffect>("Sounds/applause").Play(); player.Cash += SpinToWinCashValue; var alert = new Alert(gameInfo.Manager, String.Format("Congratulations, {0}! You won {1:N0}!", player.Name, SpinToWinCashValue), "Spin To Win :: Winner!", icon: Constants.ImageIcons.SpinToWin); alert.Closed += (sender, args) => { gameInfo.Fsm.Remove(waitState); gameInfo.CreateMessage(String.Empty); }; gameInfo.Manager.Add(alert); return(new[] { waitState }); }
public IGameState[] PerformLogic(GameTime gameTime, GameInfo gameInfo) { // Increase the age bool endWorld = gameInfo.IncreaseAgeCounter(); var waitState = StateFactory.GetState(GameStates.Wait); var alert = new Alert(gameInfo.Manager, "You just spun a 10!\nThe world age increases!\n" + (endWorld ? "Retirement Age Reached!" : String.Empty), "World age increased", icon : Constants.ImageIcons.SpinToWin); gameInfo.Manager.Add(alert); alert.Closed += (sender, args) => gameInfo.Fsm.Remove(waitState); gameInfo.CreateMessage(endWorld ? "Retirement Age Reached!" : "The world age counter increases by 10!"); return endWorld ? new[] { waitState, StateFactory.GetState(GameStates.EndGame) } : new[] { waitState }; }
private void TakePlayerBet(GameInfo gameInfo, Spinner spinner, Vector2 clickLocation) { var bettedNumber = spinner.CalculateMouseNumber(clickLocation); if (PlacedBets[bettedNumber - 1] != null) { gameInfo.CreateMessage("Number already chosen!"); return; } spinner.HighlightedSections[bettedNumber - 1] = bettingPlayer.PlayerColor; PlacedBets[bettedNumber - 1] = bettingPlayer; playerNum++; TakeNextPlayerBet(gameInfo); }
public IGameState[] PerformLogic(GameTime gameTime, GameInfo gameInfo) { // Increase the age bool endWorld = gameInfo.IncreaseAgeCounter(); var waitState = StateFactory.GetState(GameStates.Wait); var alert = new Alert(gameInfo.Manager, "You just spun a 10!\nThe world age increases!\n" + (endWorld ? "Retirement Age Reached!" : String.Empty), "World age increased", icon: Constants.ImageIcons.SpinToWin); gameInfo.Manager.Add(alert); alert.Closed += (sender, args) => gameInfo.Fsm.Remove(waitState); gameInfo.CreateMessage(endWorld ? "Retirement Age Reached!" : "The world age counter increases by 10!"); return(endWorld ? new[] { waitState, StateFactory.GetState(GameStates.EndGame) } : new[] { waitState }); }
public static void TravelToNodes(List<Node> possibleNodes, GameInfo gameInfo, MouseDown<Node> callback, bool createCameratTargets = true) { gameInfo.PanCameraToObject(gameInfo.CurrentPlayer); gameInfo.CreateMessage("Choose your destination!"); _cleanupCallback = (node, location) => CleanUp(node, location, gameInfo); _callback = callback; _possibleNodes = possibleNodes; foreach (var possibleNode in possibleNodes) { possibleNode.RememberColorState(ColorState.Glow); possibleNode.SetColorState(ColorState.Glow); possibleNode.ListenMouseDown += callback; possibleNode.ListenMouseDown += _cleanupCallback; if (createCameratTargets) { gameInfo.AddLowPriorityTarget(possibleNode); } } }
public static void TravelToNodes(List <Node> possibleNodes, GameInfo gameInfo, MouseDown <Node> callback, bool createCameratTargets = true) { gameInfo.PanCameraToObject(gameInfo.CurrentPlayer); gameInfo.CreateMessage("Choose your destination!"); _cleanupCallback = (node, location) => CleanUp(node, location, gameInfo); _callback = callback; _possibleNodes = possibleNodes; foreach (var possibleNode in possibleNodes) { possibleNode.RememberColorState(ColorState.Glow); possibleNode.SetColorState(ColorState.Glow); possibleNode.ListenMouseDown += callback; possibleNode.ListenMouseDown += _cleanupCallback; if (createCameratTargets) { gameInfo.AddLowPriorityTarget(possibleNode); } } }
public IGameState[] PerformLogic(GameTime gameTime, GameInfo gameInfo) { var waitState = StateFactory.GetState(GameStates.Wait); var alert = new Alert(gameInfo.Manager, "You have just spun a 1!\n" + "The world will now begin to change!\n\n" + "This will affect both house prices\n" + "And the logic in the world tiles!\n", "The world is going to change!", icon: Constants.ImageIcons.SpinToWin); gameInfo.Manager.Add(alert); alert.Closed += (sender, args) => gameInfo.Fsm.Remove(waitState); gameInfo.CreateMessage("The world is changing!"); return new[] { new FadeInWorld(_changeableNode.Concat(_houseNodes).Cast<WorldObject>().ToList()), new ChangeWorldLogic(_changeableNode, _houseNodes), new FadeOutWorld(_changeableNode.Concat(_houseNodes).Cast<WorldObject>().ToList()), waitState }; }
public IGameState[] PerformLogic(GameTime gameTime, GameInfo gameInfo) { var waitState = StateFactory.GetState(GameStates.Wait); var alert = new Alert(gameInfo.Manager, "You have just spun a 1!\n" + "The world will now begin to change!\n\n" + "This will affect both house prices\n" + "And the logic in the world tiles!\n", "The world is going to change!", icon: Constants.ImageIcons.SpinToWin); gameInfo.Manager.Add(alert); alert.Closed += (sender, args) => gameInfo.Fsm.Remove(waitState); gameInfo.CreateMessage("The world is changing!"); return(new[] { new FadeInWorld(_changeableNode.Concat(_houseNodes).Cast <WorldObject>().ToList()), new ChangeWorldLogic(_changeableNode, _houseNodes), new FadeOutWorld(_changeableNode.Concat(_houseNodes).Cast <WorldObject>().ToList()), waitState }); }
private void NodeChosen(Node node, GameInfo gameInfo, IGameState waitState) { gameInfo.Fsm.Remove(waitState); gameInfo.ClearTargets(); gameInfo.PanCameraToObject(gameInfo.CurrentPlayer); var currentPlayer = gameInfo.CurrentPlayer; currentPlayer.NextNode = node; // Give the player a passport for the island they are going to arrive at var assetResponse = currentPlayer.Accept(new PassportStamp(((Travel)node.BindedLogic.PureLogic).IslandType)); // Give the player a car modification if required currentPlayer.SetTransport(TransportType); if (assetResponse == AssetResponse.CollectedAllPassportStamps) { if(gameInfo.GameRuleType == GameRuleType.Passport) { gameInfo.Fsm.LazyPush(StateFactory.GetState(GameStates.GameStates.EndGame)); } } gameInfo.CreateMessage(String.Format("You have been given a {0} passport token!", IslandType)); gameInfo.Fsm.Push(StateFactory.GetState(GameStates.GameStates.VisuallyMovePlayer)); }
// The game rules dictate that we keep spinning the spinner until a winner // is found private IGameState[] NoWinnerFound(GameInfo gameInfo) { gameInfo.CreateMessage("No winner found! Spin again!"); return(new[] { this, StateFactory.GetState(GameStates.GameStates.Spin) }); }
private void CreateFirstDisplayWindow(Manager manager, GameInfo gameInfo, Story red, Story black) { const int spacing = 20; const int width = 500; int yPos = spacing; var window = new Window(manager) { Text = "Story card", Width = 600 }; window.Init(); var descriptionlabel = new Label(manager) { Text = red.DisplayedMessage, Top = yPos, Width = width, Height = 70, Left = 30 }; descriptionlabel.Text = "When this window closes you will be required to spin the spinner.\n" + "If the spinner lands on a black spot you will undergo what the black card says.\n" + "If the spinner lands on a red spot you will undergo what the red card says.\n\n" + "These are stories you are spinning for!"; yPos += descriptionlabel.Height + spacing / 2; var redstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 100, Parent = window, Color = Color.Red, Text = "Red Story", TextColor = Color.White }; redstorybox.Init(); yPos += redstorybox.Height; var redstorylabel = new Label(manager) { Width = redstorybox.Width, Height = redstorybox.Height, Parent = redstorybox, Text = red.DisplayedMessage, Left = spacing, StayOnTop = true }; redstorylabel.Init(); var blackstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 200, Parent = window, Color = Color.Black, Text = "Black Story", TextColor = Color.White }; blackstorybox.Init(); yPos += blackstorybox.Height + spacing / 2; var blackstorylabel = new Label(manager) { Width = blackstorybox.Width, Height = blackstorybox.Height, Parent = blackstorybox, Text = black.DisplayedMessage, Left = spacing, StayOnTop = true }; blackstorylabel.Init(); var close = new Button(manager) { Text = "OK", Top = yPos, Left = window.Width / 2 - 50, Parent = window }; close.Init(); close.Click += (sender, args) => window.Close(); yPos += close.Height + spacing; window.Add(descriptionlabel); window.Height = blackstorybox.Height + redstorybox.Height + yPos / 2; manager.Add(window); window.Closed += (sender, args) => WindowClosed(gameInfo); gameInfo.CreateMessage("Click the spinner to see your story!"); }
private IGameState[] TakeExamLogic(GameInfo gameInfo) { gameInfo.CreateMessage("Time for your exam! Spin the spinner!"); gameInfo.PanCameraToObject(gameInfo.Spinner); return new[] { this, StateFactory.GetState(GameStates.GameStates.Spin) }; }
private void CreateFirstDisplayWindow(Manager manager, GameInfo gameInfo, Story red, Story black) { const int spacing = 20; const int width = 500; int yPos = spacing; var window = new Window(manager) { Text = "Story card", Width = 600 }; window.Init(); var descriptionlabel = new Label(manager) { Text = red.DisplayedMessage, Top = yPos, Width = width, Height = 70, Left = 30}; descriptionlabel.Text = "When this window closes you will be required to spin the spinner.\n" + "If the spinner lands on a black spot you will undergo what the black card says.\n" + "If the spinner lands on a red spot you will undergo what the red card says.\n\n" + "These are stories you are spinning for!"; yPos += descriptionlabel.Height + spacing / 2; var redstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 100, Parent = window, Color = Color.Red, Text = "Red Story", TextColor = Color.White}; redstorybox.Init(); yPos += redstorybox.Height; var redstorylabel = new Label(manager) { Width = redstorybox.Width, Height = redstorybox.Height, Parent = redstorybox, Text = red.DisplayedMessage, Left = spacing, StayOnTop = true }; redstorylabel.Init(); var blackstorybox = new GroupBox(manager) { Width = 500, Height = 100, Left = 30, Top = 200, Parent = window, Color = Color.Black, Text = "Black Story", TextColor = Color.White }; blackstorybox.Init(); yPos += blackstorybox.Height+spacing/2; var blackstorylabel = new Label(manager) { Width = blackstorybox.Width, Height = blackstorybox.Height, Parent = blackstorybox, Text = black.DisplayedMessage, Left = spacing, StayOnTop = true }; blackstorylabel.Init(); var close = new Button(manager) { Text = "OK", Top = yPos, Left = window.Width / 2 - 50, Parent = window }; close.Init(); close.Click += (sender, args) => window.Close(); yPos += close.Height + spacing; window.Add(descriptionlabel); window.Height = blackstorybox.Height + redstorybox.Height + yPos/2; manager.Add(window); window.Closed += (sender, args) => WindowClosed(gameInfo); gameInfo.CreateMessage("Click the spinner to see your story!"); }
private IGameState[] TakeExamLogic(GameInfo gameInfo) { gameInfo.CreateMessage("Time for your exam! Spin the spinner!"); gameInfo.PanCameraToObject(gameInfo.Spinner); return(new[] { this, StateFactory.GetState(GameStates.GameStates.Spin) }); }