/// <summary> /// Pokazuje wskazanemu graczowi poppup z pytaniem, czy chce on kupić dane pole /// </summary> /// <param name="player">Gracz, któremu pokazujemy popup</param> /// <param name="visualiser">Instancja visualisera, który przechowuje dane pole</param> private void ShowBuyPopup(Player player, PlaceVisualiser visualiser) { if (player.Money >= GetInitialPrice()) { LanguageController language = SettingsController.instance.languageController; //popup o mozliwosci kupienia pola od banku string message = language.GetWord("DO_YOU_WANT_TO_BUY") + GetFieldName() + "\n" + language.GetWord("PRICE") + ":" + GetInitialPrice() + "?"; Popup.PopupAction yesAction = delegate(Popup source) { //gracz chce kupic pole wiec jest mu przydzielane z banku GameplayController.instance.banking.AquireBuilding(player, player.PlaceId); source.onClose = null; }; Popup.PopupAction auctionAction = delegate { EventManager.instance.SendOnAuction(player.GetName(), player.PlaceId, "", GetInitialPrice(), player.GetName()); }; QuestionPopup wantToBuy = QuestionPopup.CreateYesNoDialog(message, yesAction); wantToBuy.onClose += auctionAction; PopupSystem.instance.AddPopup(wantToBuy); } else { //Jeżeli nie stać nas na kupienie budynku, rozpoczyna się licytacja EventManager.instance.SendOnAuction(player.GetName(), visualiser.placeIndex, "", GetInitialPrice(), player.GetName()); } }
/// <summary> /// Pokazuje wskazanemu graczowi poppup z pytaniem, czy chce on ulepszyć dane pole /// </summary> /// <param name="player">Gracz, któremu pokazujemy popup</param> /// <param name="visualiser">Instancja visualisera, który przechowuje dane pole</param> /// <param name="language">Odwołanie do LanguageControllera</param> private void ShowUpgradePopup(Player player, PlaceVisualiser visualiser, LanguageController language) { //Tylko budynki o typie NormalBuilding można ulepszyć int currentTier = GameplayController.instance.board.GetTier(visualiser.placeIndex); //Pytamy o możliwość ulepszenia tylko wtedy, gdy istnieje następny poziom budynku if (HasNextTier(visualiser.placeIndex) && player.Money >= GameplayController.instance.banking.GetUpgradePrice(visualiser.placeIndex)) { float upgradePrice = GetTier(currentTier + 1).buyPrice; //Sprawdzamy, czy gracz ma wystraczająco pieniędzy na ulepszenie if (player.Money >= upgradePrice) { string message = language.GetWord("DO_YOU_WANT_TO_UPGRADE") + GetFieldName() + "? \n" + language.GetWord("UPGRADE_COST") + upgradePrice; Popup.PopupAction yesAction = delegate(Popup source) { GameplayController.instance.banking.UpgradeBuilding(player, visualiser.placeIndex); }; QuestionPopup upgrade = QuestionPopup.CreateYesNoDialog(message, yesAction); PopupSystem.instance.AddPopup(upgrade); } } }
private void OnTradeOfferReceived(string senderNickName, string[] senderBuildingNames, float senderMoney, string receiverNickName, string[] receiverBuildingNames, float receiverMoney) { if (receiverNickName == PhotonNetwork.LocalPlayer.NickName) { Popup.PopupAction yesAction = delegate { Player sender = gC.session.FindPlayer(senderNickName); List <Field> myBuildings = new List <Field>(); foreach (string name in receiverBuildingNames) { if (gC.board.GetField(name) != null) { myBuildings.Add(gC.board.GetField(name)); } } Player receiver = gC.session.FindPlayer(receiverNickName); List <Field> theirBuildings = new List <Field>(); foreach (string name in senderBuildingNames) { if (gC.board.GetField(name) != null) { theirBuildings.Add(gC.board.GetField(name)); } } OpenRightPanel(sender, myBuildings, receiverMoney, theirBuildings, senderMoney); }; IconPopup tradeOfferReceivedPopup = new IconPopup(IconPopupType.Trade, QuestionPopup.CreateYesNoDialog(lC.GetWord("YOU_GOT_AN_OFFER_FROM") + senderNickName + " <br>" + lC.GetWord("DO_YOU_WANT_TO_SEE"), yesAction)); PopupSystem.instance.AddPopup(tradeOfferReceivedPopup); } }
public void ShowDice(Popup.PopupAction diceAction) { IconPopup dicePopup = new IconPopup(IconPopupType.Dice, diceAction); GameObject dice = boxPools[typeof(IconBox)].TakeObject(); dice.GetComponent <Animator>().SetBool("Dice", true); DiceBox = dice.GetComponent <IconBox>(); DiceBox.Init(dicePopup); }
protected void ShowPayPopup(Player player, PlaceVisualiser visualiser, float cost) { LanguageController language = SettingsController.instance.languageController; Player owner = GameplayController.instance.board.GetOwner(visualiser.placeIndex); //Wiadomość o konieczności zapłaty string message = language.GetWord("YOU_MUST_PAY") + owner.GetName() + language.GetWord("FOR_STAY_ON_PLACE") + "\n" + language.GetWord("COST") + cost; Popup.PopupAction onOk = delegate(Popup source) { GameplayController.instance.banking.Pay(player, owner, cost); }; QuestionPopup payPopup = QuestionPopup.CreateOkDialog(message, onOk); PopupSystem.instance.AddPopup(payPopup); }
/// <summary> /// Funckja wywoływana, gdy aukcja dobiegnie końca /// <param name="offerForLastBidder">Czy zaoferować kuono budynku ostatniemu graczowi, który został w licytacji, a nigdy nie podbijał</param> /// </summary> private void EndAuction(int placeId, float bid, bool offerForLastBidder = true) { if (auctionPopup != null) { auctionPopup.onClose = null; } if (bidders.Count > 0) { string auctionEndedMessage = SettingsController.instance.languageController.GetWord("AUCTION_ENDED"); IconPopup auctionEnded = new IconPopup(IconPopupType.Auction, auctionEndedMessage); if (GameplayController.instance.session.FindPlayer(bidders[0]).NetworkPlayer.IsLocal) { if (raisers.Contains(bidders[0])) { AquireBuilding(GameplayController.instance.session.FindPlayer(bidders[0]), placeId); } else if (offerForLastBidder && GameplayController.instance.session.FindPlayer(bidders[0]).Money >= bid) { string message = SettingsController.instance.languageController.GetWord("DO_YOU_WANT_TO_BUY") + " " + GameplayController.instance.board.GetField(placeId).GetFieldName() + "\n" + SettingsController.instance.languageController.GetWord("PRICE") + ":" + bid + "?"; Popup.PopupAction yesAction = delegate(Popup source) { AquireBuilding(GameplayController.instance.session.localPlayer, placeId); }; QuestionPopup buyQuestion = QuestionPopup.CreateYesNoDialog(message, yesAction); PopupSystem.instance.AddPopup(buyQuestion); } } if (GameplayController.instance.session.playerCount > 2) { PopupSystem.instance.AddPopup(auctionEnded); } } PopupSystem.instance.ClosePopup(auctionPopup); ClearAuction(); GameplayController.instance.flow.Resume(); }
public override void OnAwake(Player player, PlaceVisualiser visualiser) { if (player.NetworkPlayer.IsLocal && player.Imprisoned) { Board board = GameplayController.instance.board; LanguageController language = SettingsController.instance.languageController; FlowController flow = GameplayController.instance.flow; flow.Pause(); QuestionPopup startTurn = QuestionPopup.CreateOkDialog(language.GetWord("YOU_ARE_IN_PRISON")); flow.CloseOnDiceClose(startTurn); Popup.PopupAction diceRoll = delegate(Popup source) { if (freeingThrows.Contains(board.dice.rollResult)) { QuestionPopup free = QuestionPopup.CreateOkDialog(language.GetWord("YOU_ARE_FREE")); GameplayController.instance.flow.RollResult().Invoke(source); player.Imprisoned = false; PopupSystem.instance.AddPopup(free); } else { QuestionPopup noFree = QuestionPopup.CreateOkDialog(language.GetWord("NOT_THIS_TIME")); GameplayController.instance.diceController.Roll(board.dice.rollResult.Roll1, board.dice.rollResult.Roll2); PopupSystem.instance.AddPopup(noFree); flow.RewindToSkiping(); } }; startTurn.onClose += delegate { PopupSystem.instance.ShowDice(diceRoll); }; PopupSystem.instance.AddPopup(startTurn); } else { base.OnAwake(player, visualiser); } }
/// <summary> /// Funckja sterująca przepływem aukcji /// </summary> private void AuctionFlow(string playerName, int placeId, string bidder, float bid, string passPlayerName) { LanguageController lang = SettingsController.instance.languageController; //1 linijka: Licytacja //2 linijka: nazwa budynku string auctionString = lang.GetWord("AUCTION") + "\n" + GameplayController.instance.board.GetField(placeId).GetFieldName() + "\n"; if (bidders.Contains(bidder)) //Jeżeli bidders posiada biddera aka czy ktoś pobił { // Ostatni gracz jest lokalny: 3 linijka: Ty podbiłeś if (GameplayController.instance.session.FindPlayer(bidder).NetworkPlayer.IsLocal) { auctionString += lang.GetWord("YOU_RAISED"); } // Ostatni gracz nie jest lokalny 3 linijka: Gracz <nick> podbił else { auctionString += lang.GetWord("PLAYER") + " " + bidder + " " + lang.GetWord("RAISED"); } } else if (playerName != passPlayerName && passPlayerName != "") //Jeżeli ktoś spasował, ponieważ sprawdza czy osoba pasująca nie jest startującym aukcji { //Jeżeli pasujący gracz jest lokalny 3 linijka: Ty spasowałeś if (GameplayController.instance.session.FindPlayer(passPlayerName).NetworkPlayer.IsLocal) { auctionString += lang.GetWord("YOU_PASSED"); } //Jeżeli pasujący gracz nie jest lokalny 3 linijka: Gracz <nick> spasował else { auctionString += lang.GetWord("PLAYER") + " " + passPlayerName + " " + lang.GetWord("PASSED"); } } else if (playerName == passPlayerName) //Jeżeli gracz który spasował, jest graczem który zaczął akcję, aka pierwsze wywołanie eventu licytacji { //Jeżeli gracz jest lokalny 3 linijka : Zacząłeś aukcję if (GameplayController.instance.session.FindPlayer(playerName).NetworkPlayer.IsLocal) { auctionString += lang.GetWord("YOU_STARTED_AUCTION"); } //Jeżeli gracz nie jest lokalny 3 linijka: gracz <nick> rozpoczął aukcję else { auctionString += lang.GetWord("PLAYER") + " " + playerName + " " + lang.GetWord("STARTED_AUCTION"); } } //4 linijka: Obecna stawka: <bid> auctionString += "\n" + lang.GetWord("AUCTION_CURRENT_BID") + bid; auctionPopup = new QuestionPopup(auctionString); if (!GameplayController.instance.session.FindPlayer(playerName).NetworkPlayer.IsLocal&& bidders.Contains(GameplayController.instance.session.localPlayer.GetName())) { //Wersja dla osób, które mogą licytować string passString = lang.GetWord("PASS"); string raiseString = lang.GetWord("RAISE"); Popup.PopupAction passAction = delegate(Popup source) { source.onClose = null; EventManager.instance.SendOnAuction(playerName, placeId, "", bid, GameplayController.instance.session.localPlayer.GetName()); }; Popup.PopupAction raiseAction = delegate(Popup source) { source.onClose = null; if (!raisers.Contains(GameplayController.instance.session.localPlayer.GetName())) { raisers.Add(GameplayController.instance.session.localPlayer.GetName()); } EventManager.instance.SendOnAuction(playerName, placeId, GameplayController.instance.session.localPlayer.GetName(), bid + Keys.Gameplay.RAISE_BID_VALUE, ""); }; auctionPopup.AddButton(passString, passAction); if (GameplayController.instance.session.localPlayer.Money >= bid + Keys.Gameplay.RAISE_BID_VALUE) { auctionPopup.AddButton(raiseString, raiseAction); } auctionPopup.onClose = passAction; } PopupSystem.instance.AddPopup(auctionPopup); }