示例#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);
        }
    }