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); }
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)); }
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"); } }
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(); }); } })); }