Raise Event send text and change Ownership
Options
I am doing a project which is very similar to a card game. But I don't know how to do it, can somebody help. Game Rule : Player 1 and Player 2 are using a different computer, but the game is connecting by Photon Pun. When Player 1 gets a score, a text will equal to the score ( Text ABC; ABC.text = score.ToString();) After the Player 1 got the score, it is time for Player 2 to play. But before that, Player 2 should see the score that Player 1 has got. When one player is playing, other players can only wait for fot him.
I saw people are using RaiseEvent, but I have watch a video, he only sends the value of the data, but not a Text which can display for every player. Also, I think I need to photonView:IsMind , and base.photonView.RequestOwnership(); to decide which player should play.
Can someone help me, I am new in Unity and Photon.
I saw people are using RaiseEvent, but I have watch a video, he only sends the value of the data, but not a Text which can display for every player. Also, I think I need to photonView:IsMind , and base.photonView.RequestOwnership(); to decide which player should play.
Can someone help me, I am new in Unity and Photon.
0
Comments
-
Here is my Raise Event program
// Get data from the previous program and send to the internet
private void DartInternet()
{
int ScoreWeb1 = PlayerGetScore[0];
int ScoreWeb2 = PlayerGetScore[1];
int ScoreWeb3 = PlayerGetScore[2];
int ScoreWeb4 = PlayerGetScore[3];
int PlayerNum= k;
int PlayerRound = PlayerRoundNumber;
int TotalRound = TotalRoundNumber;
object[] datas = new object[] { ScoreWeb1, ScoreWeb2, ScoreWeb3, ScoreWeb4, PlayerNum, PlayerRound, TotalRound };
PhotonNetwork.RaiseEvent(DART_SCORE_EVENT, datas, RaiseEventOptions.Default, SendOptions.SendUnreliable);
}
private void NetworkingClient_EventReceived(EventData obj)
{
if (obj.Code == DART_SCORE_EVENT)
{
object[] datas = (object[])obj.CustomData;
int ScoreWeb1 = (int)datas[0];
int ScoreWeb2 = (int)datas[1];
int ScoreWeb3 = (int)datas[2];
int ScoreWeb4 = (int)datas[3];
int PlayerNum = (int)datas[4];
int PlayerRound = (int)datas[5];
int TotalRound = (int)datas[6];
// Reveive the data from photon and set them to text
PlayerScoreArray[0].text = ScoreWeb1.ToString();
PlayerScoreArray[1].text = ScoreWeb2.ToString();
PlayerScoreArray[2].text = ScoreWeb3.ToString();
PlayerScoreArray[3].text = ScoreWeb4.ToString();
_playerNumber.text = PlayerNum.ToString();
_playerRoundNumber.text = PlayerRound.ToString();
_totalRoundNumber.text = TotalRound.ToString();
}
}
private void OnEnable()
{
PhotonNetwork.NetworkingClient.EventReceived += NetworkingClient_EventReceived;
}
private void OnDisable()
{
PhotonNetwork.NetworkingClient.EventReceived -= NetworkingClient_EventReceived;
}0 -
BUT I Failed0