Exemplo n.º 1
0
    /// <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);
            }
        }
    }
Exemplo n.º 2
0
    /// <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());
        }
    }
Exemplo n.º 3
0
    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);
        }
    }
Exemplo n.º 4
0
    /// <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();
    }