Example #1
0
 private void CreateFailedExamWindow(GameInfo gameInfo, IGameState waitState)
 {
     gameInfo.CurrentPlayer.CurrentlyTakingExam = false;
     var confirmWindow = new ConfirmWindow(gameInfo.Manager, String.Format("You failed. Pay ${0:N0} to pass?", ExamCost), title: "You failed the exam!", autoClose: true, icon: "Images/AlertIcons/Fail");
     gameInfo.Content.Load<SoundEffect>("Sounds/sadtrombone").Play();
     confirmWindow.AffirmButton.Click += (sender, args) => PayForExam(gameInfo, waitState);
     confirmWindow.DenyButton.Click += (sender, args) => gameInfo.Fsm.Remove(waitState);
     gameInfo.Manager.Add(confirmWindow);
 }
Example #2
0
        private void OfferToSellHouse(GameInfo gameInfo, IGameState waitState)
        {
            var currentHouse = gameInfo.CurrentPlayer.House;
            var houseGraphic = gameInfo.Content.Load<Texture2D>(currentHouse.HouseGraphic);
            var manager = gameInfo.Manager;

            var container = new Control(manager) { Left = 16, Top = 16, Color = Color.Transparent };
            var firstLine = new Label(manager) { Text = "You have been offered to buy a new house!  \nYou must sell your current house to be able to buy this one. \n\n     Current House:", Width = 400, Height = 60};
            container.Add(firstLine);
            // Put the house graphic into an image box
            var imageBox = new ImageBox(manager)
            {
                Left = 16,
                Top = 60,
                Image = houseGraphic,
                Color = Color.White,
                Width = houseGraphic.Width,
                Height = houseGraphic.Height
            };
            imageBox.Init();
            container.Add(imageBox);

            var descriptionText = new Label(manager)
            {
                Text =
                    String.Format(
                        "Name : {0}\n\n" +
                        "Average Value: ${1:N0}" +
                        "\n\nCurrent Value: ${2:N0}\n\n",
                        currentHouse.Name, currentHouse.InitialValue, currentHouse.Value),
                Top = imageBox.Height / 2,
                Left = imageBox.Width + 60,
                Height = 100,
                Width = 200
            };
            container.Add(descriptionText);

            var newHouse = new Label(gameInfo.Manager)
                               {Text = "     New offered house", Width = 150, Parent = container, Top = 200, Left = 16};
            newHouse.Init();

            var imageBox2 = new ImageBox(manager)
            {
                Left = 16,
                Top = 230,
                Image = gameInfo.Content.Load<Texture2D>(House.HouseGraphic),
                Color = Color.White,
                Width = houseGraphic.Width,
                Height = houseGraphic.Height
            };
            imageBox.Init();
            container.Add(imageBox2);

            var descriptionText2 = new Label(manager)
            {
                Text =
                    String.Format(
                        "Name : {0}\n\n" +
                        "Average Value: ${1:N0}" +
                        "\n\nCurrent Value: ${2:N0}\n\n",
                        House.Name, House.InitialValue, House.Value),
                Top = imageBox.Height*4 / 2,
                Left = imageBox2.Width + 60,
                Height = 100,
                Width = 200
            };
            container.Add(descriptionText2);

            var offerHouseLine = new Label(manager) { Text = "Would you like to sell your current house?", Width = 400, Top = imageBox.Height*2 + 140 };
            container.Add(offerHouseLine);

            container.Width = descriptionText.Left + descriptionText.Width + 16;
            container.Height = offerHouseLine.Top + offerHouseLine.Height;

            //"Would you like to buy this house? \n" + House.Name, "\nDo you want to buy a house""
            var confirmWindow = new ConfirmWindow(manager, String.Empty, title: "Do you want to sell your house?", control: container);
            confirmWindow.AffirmButton.Click += (sender, args) => SellCurrentHouse(confirmWindow, gameInfo, waitState);
            confirmWindow.DenyButton.Click += (sender, args) => CloseWindow(confirmWindow, gameInfo, waitState);
        }
Example #3
0
 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);
 }
Example #4
0
        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));
        }