Esempio n. 1
0
    public void DoBet()
    {
        if ((int)PhotonNetwork.LocalPlayer.CustomProperties["bet"] != 0 || (int)PhotonNetwork.CurrentRoom.CustomProperties["phase"] == 2 || (int)PhotonNetwork.CurrentRoom.CustomProperties["phase"] == 4)
        {
            return;
        }
        byte evCode = 66;

        CasinoWarPlayer player = PlayerSingleton.GetPlayer();

        player.setBet(100);
        player.setActorNumber(PhotonNetwork.LocalPlayer.ActorNumber);
        PhotonNetwork.SetPlayerCustomProperties(new Hashtable()
        {
            { "bet", 100 }
        });

        string playerString = JsonUtility.ToJson(player);

        UpdatePlayerGui(PhotonNetwork.LocalPlayer);

        Debug.Log(playerString);
        RaiseEventOptions raiseEventOptions = new RaiseEventOptions {
            Receivers = ReceiverGroup.All
        };                                                                                             // You would have to set the Receivers to All in order to receive this event on the local client as well
        SendOptions sendOptions = new SendOptions {
            Reliability = true
        };

        PhotonNetwork.RaiseEvent(evCode, playerString, raiseEventOptions, sendOptions);
    }
Esempio n. 2
0
    void UpdateResultGui(CasinoWarPlayer player)
    {
        Hashtable table = (Hashtable)PhotonNetwork.CurrentRoom.CustomProperties["table"];
        Text      actorField;

        for (int seat = 1; seat <= 5; seat++)
        {
            if ((int)table[seat] == player.getActorID())
            {
                actorField      = Seats.transform.GetChild(ComputeSlot(seat)).GetChild(1).gameObject.GetComponent <Text>();
                actorField.text = "Card: " + player.getMycard().ToString() +
                                  "\nWin Result: " + player.getResult();
            }
        }
        if (player.getActorID() == PhotonNetwork.LocalPlayer.ActorNumber)
        {
            if (player.getResult() == 2)
            {
                WarButton.gameObject.SetActive(true);
            }
            PlayerSingleton.GetPlayer().setCredit(player.getNewCredit());
            PhotonNetwork.SetPlayerCustomProperties(new Hashtable()
            {
                { "credit", player.getNewCredit() }
            });
            UpdatePlayerGui(PhotonNetwork.LocalPlayer);
            UpdateUserInfoText();
            // UpdatePlayerGui(PhotonNetwork.LocalPlayer);
        }
    }
Esempio n. 3
0
    void UpdateUserInfoText()
    {
        CasinoWarPlayer player = PlayerSingleton.GetPlayer();

        UserInfoText.text = "User ID: " + player.getID() +
                            "\nUser Name: " + player.getUserName() +
                            "\nCredit: " + player.getNewCredit();
    }
Esempio n. 4
0
    void Start()
    {
        var userid = PlayerPrefs.GetString("userid");

        PhotonNetwork.AuthValues           = new AuthenticationValues(userid);
        PhotonNetwork.LocalPlayer.NickName = PlayerSingleton.GetPlayer().getUserName();

        UpdateUserInfoText();
        PhotonNetwork.ConnectUsingSettings();

        WarButton.gameObject.SetActive(false);
        //  PhotonNetwork.JoinLobby("casinowarlobby", new TypedLobby { });
    }
Esempio n. 5
0
    public override void OnJoinedRoom()
    {
        base.OnJoinedRoom();
        Seats.SetActive(true);

        PhotonNetwork.SetPlayerCustomProperties(new Hashtable()
        {
            { "bet", 0 }, { "war", 0 }
        });
        PhotonNetwork.SetPlayerCustomProperties(new Hashtable()
        {
            { "credit", PlayerSingleton.GetPlayer().getNewCredit() }
        });
        // foreach (Player player in PhotonNetwork.PlayerListOthers)
        // {
        //     UpdatePlayerGui(player);
        // }
    }