コード例 #1
0
    public void RequestUpgrade(int playerID, PLOT plotID, int level)
    {
        Player player = TurnDirector.Ins.GetPlayer(playerID);

        if (player == null)
        {
            UpgradeFailCallback("Cannot find player with playerID: " + playerID.ToString());
            return;
        }

        if (!Plot.plotDictionary.ContainsKey(plotID))
        {
            UpgradeFailCallback("Cannot find plot with plotID" + plotID.ToString());
            return;
        }

        if (!(Plot.plotDictionary[plotID] is PlotConstructionMarket))
        {
            UpgradeFailCallback("Plot with plotID: " + plotID.ToString() + " is not a Plot Construction Market");
            return;
        }

        PlotConstructionMarket plot = Plot.plotDictionary[plotID] as PlotConstructionMarket;

        if (plot.UpgradeFee(plot.Level, level) > Bank.Ins.MoneyPlayer(player))
        {
            UpgradeFailCallback("Not enough money to upgrade");
            return;
        }

        photonView.RPC("_RequestUpgradeServer", RpcTarget.MasterClient, playerID, (int)plotID, level, PhotonNetwork.LocalPlayer.UserId);
    }
コード例 #2
0
    private void _RequestUpgradeServer(int playerID, int plotID, int level, string clientID)
    {
        Player player = TurnDirector.Ins.GetPlayer(playerID);
        var    client = PhotonNetwork.PlayerList.Single(x => x.UserId == clientID);

        if (player == null)
        {
            photonView.RPC("UpgradeFailCallback", client, "Cannot find player with playerID: " + playerID.ToString());
            return;
        }

        if (!Plot.plotDictionary.ContainsKey((PLOT)plotID))
        {
            photonView.RPC("UpgradeFailCallback", client, "Cannot find plot with plotID" + plotID.ToString());
            return;
        }

        if (!(Plot.plotDictionary[(PLOT)plotID] is PlotConstructionMarket))
        {
            photonView.RPC("UpgradeFailCallback", client,
                           "Plot with plotID: " + plotID.ToString() + " is not a Plot Construction Market");
            return;
        }

        PlotConstructionMarket plot = Plot.plotDictionary[(PLOT)plotID] as PlotConstructionMarket;

        if (plot.UpgradeFee(plot.Level, level) > Bank.Ins.MoneyPlayer(player))
        {
            photonView.RPC("UpgradeFailCallback", client, "Not enough money to upgrade");
            return;
        }

        photonView.RPC("UpgradeSuccessCallback", RpcTarget.All, playerID, plotID, level, plot.UpgradeFee(plot.Level, level));
    }
コード例 #3
0
    private void OnUpgradeSuccess(Player player, PlotConstructionMarket plot, int level)
    {
        if (gameObject.activeSelf == false)
        {
            return;
        }

        Skip();
    }
コード例 #4
0
    public void SetPlot(Plot plot)
    {
        if (plot is PlotConstructionMarket)
        {
            _plot = plot as PlotConstructionMarket;

            if (_txtPriceLvls != null)
            {
                for (int i = 0; i < _txtPriceLvls.Length; i++)
                {
                    var txtPriceLvl = _txtPriceLvls[i];

                    if (_plot.Level <= i)
                    {
                        if (txtPriceLvl != null)
                        {
                            txtPriceLvl.text = _plot.UpgradeFee(_plot.Level, i + 1).ToString();
                        }
                        if (_buttonUpgrade[i] != null)
                        {
                            _buttonUpgrade[i].gameObject.SetActive(true);
                        }
                    }
                    else
                    {
                        if (txtPriceLvl != null)
                        {
                            txtPriceLvl.text = "";
                        }
                        if (_buttonUpgrade[i] != null)
                        {
                            _buttonUpgrade[i].gameObject.SetActive(false);
                        }
                    }
                }
            }

            // Only show upgrade button level 4 when plot has been upgrade to level 3
            if (_plot.Level < 3)
            {
                _buttonUpgrade[3].gameObject.SetActive(false);
            }
            else
            {
                _buttonUpgrade[3].gameObject.SetActive(true);
            }
        }
        else
        {
            Debug.LogError("Someone set plot that not Construction Temple into Market Upgrade UI");
        }
    }
コード例 #5
0
    public override IAction ActionOnEnter(Player player)
    {
        return(new LambdaAction(() =>
        {
            NotifyPlotEnter(player);

            // Calculate the tax fee
            int currentPlayerMoney = Bank.Ins.MoneyPlayer(player);
            int totalPlotNetworth = 0;

            foreach (var plotPair in Plot.plotDictionary)
            {
                if (plotPair.Value is PlotConstructionMarket)
                {
                    PlotConstructionMarket plot = plotPair.Value as PlotConstructionMarket;

                    if (plot.Owner == player)
                    {
                        int plotNetwork = plot.Price + (int)(0.5 * plot.UpgradeFee(0, plot.Level));

                        totalPlotNetworth += plotNetwork;
                    }
                }
            }

            int totalTax = (int)(taxFactor * (currentPlayerMoney + totalPlotNetworth));

            Debug.Log("PlotTax: make player pay tax");
            Bank.Ins.TakeMoney(player, totalTax, false);

            Bank.Ins.AddMoneyToLuckyDraw(100);

            if (player.MinePlayer)
            {
                int totalAnimationDelay = 0;

                if (player.HasLost)
                {
                    totalAnimationDelay += 2;
                }

                FutureTask <bool> .Delay(totalAnimationDelay).then((bool result) =>
                {
                    Debug.Log("PlotTax: call end turn");
                    base.ActionOnEnter(player).PerformAction();
                });
            }
        }));
    }
コード例 #6
0
 public void OnPlotEnter(Player player, Plot plot)
 {
     Debug.Log("Receive On Plot Pass By");
     if (player == targetPlayer)
     {
         if (plot is PlotConstructionMarket)
         {
             PlotConstructionMarket p = (PlotConstructionMarket)plot;
             if (p.Owner != player)
             {
                 //Nhan 200 gold o day
                 Bank.Ins.SendMoney(targetPlayer, 200);
                 return;
             }
         }
         //Mat 100 gold o day
         Bank.Ins.TakeMoney(targetPlayer, 100);
     }
 }
コード例 #7
0
    private void UpgradeSuccessCallback(int playerID, int plotID, int level, int money)
    {
        Player player = TurnDirector.Ins.GetPlayer(playerID);

        PlotConstructionMarket plot = Plot.plotDictionary[(PLOT)plotID] as PlotConstructionMarket;

        if (player == null)
        {
            Debug.LogError("Upgrade Success Callback cannot find player " + playerID.ToString());
        }
        if (plot == null)
        {
            Debug.LogError("Upgrade Success Callback cannot find plot " + playerID.ToString() + " as PlotConstructionMarket");
        }

        Bank.Ins.TakeMoney(player, money);
        plot.Upgrade(level);
        OnUpgradeSuccess?.Invoke(player, plot, level);
    }