Esempio n. 1
0
    public void RPC_TradeProperty(PhotonPlayer trader, PhotonPlayer tradee, int[] propA, int[] propB, int moneyA, int moneyB)
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }
        NPlayer playerA = FindGamePlayer(trader);
        NPlayer playerB = FindGamePlayer(tradee);

        playerA.ChangeMoney(-moneyA);
        playerA.ChangeMoney(moneyB);
        playerB.ChangeMoney(moneyA);
        playerB.ChangeMoney(-moneyB);

        foreach (int propID in propB)
        {
            NProperty property = NBoardManager.instance.Properties[propID];
            playerB.RemoveProperty(property);
            playerA.AddProperty(property);
            property.SoldTo(playerA);
            photonView.RPC("RPC_SetPropertyOwnerMarker", PhotonTargets.All, propID, trader);
        }

        foreach (int propID in propA)
        {
            NProperty property = NBoardManager.instance.Properties[propID];
            playerA.RemoveProperty(property);
            playerB.AddProperty(property);
            property.SoldTo(playerB);
            photonView.RPC("RPC_SetPropertyOwnerMarker", PhotonTargets.All, propID, tradee);
        }
    }
Esempio n. 2
0
    public void RPC_PurchaseProperty(int propertyID, int purchasePrice, PhotonPlayer caller)
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }
        NPlayer   player   = FindGamePlayer(caller);
        NProperty property = NBoardManager.instance.Properties[propertyID];

        if (player.CurrentMoney >= purchasePrice)
        {
            player.ChangeMoney(-purchasePrice);
            player.AddProperty(property);
            property.SoldTo(player);
            photonView.RPC("RPC_SetPropertyOwnerMarker", PhotonTargets.All, propertyID, caller);
        }
    }