Why does my Raise Events are stop working at the middle of working Game ??

Devesh
✭
Can any please suggest me with my code should i do with my code in Raise events I am not prety sure that its alright but i can say that i have implemented all the things in right way Thanks for viewing my request and answering me in advance God may bless you
public class Chessman : MonoBehaviourPunCallbacks { public static Chessman Instanse; //References to objects in our Unity Scene public GameObject controller; public GameObject movePlate; private const byte Board_Change_Event_wX = 0; private const byte Board_Change_Event_WY = 1; private const byte Board_Change_Event_BX = 2; private const byte Board_Change_Event_BY = 3; public int xBoard = -1; public int yBoard = -1; //Variable for keeping track of the player it belongs to "black" or "white" public string player; //working functions public override void OnEnable() { base.OnEnable(); PhotonNetwork.NetworkingClient.EventReceived += NetworkingClient_EventReceived; } public override void OnDisable() { base.OnDisable(); PhotonNetwork.NetworkingClient.EventReceived -= NetworkingClient_EventReceived; } public void Start() { Instanse = this; Sprite_Change_of_any(); Set_Player_Properties(); base.photonView.RPC("Onsend_POS", RpcTarget.All); } private void OnMouseUp() { Plates(); } //Networking private void NetworkingClient_EventReceived(EventData obj) { GameObject[] Pycs = GameObject.FindGameObjectsWithTag("Pieces"); // getting all pieces // white set.. get.. if (obj.Code == Board_Change_Event_wX) // white set.. get.. x { object[] WhitePieceXData = (object[])obj.CustomData; // Getting Data //main piece int WrookXboard = (int)WhitePieceXData[0]; // Getting x from data as rook Xboard int WknightXboard = (int)WhitePieceXData[1]; // Getting x from data as knight Xboard int WbishopXboard = (int)WhitePieceXData[2]; // Getting x from data as bishop Xboard int WqueenXboard = (int)WhitePieceXData[3];// Getting x from data as queen Xboard int WkingXboard = (int)WhitePieceXData[4];// Getting x from data as king Xboard int WbishopsecXboard = (int)WhitePieceXData[5];// Getting x from data as second bishop Xboard int WknightsecXboard = (int)WhitePieceXData[6];// Getting x from data as second knight Xboard int WrooksecXboard = (int)WhitePieceXData[7];// Getting x from data as second rook Xboard //pawn int Wpawn1stXboard = (int)WhitePieceXData[8];// Getting x from data as 1st pawn Xboard int Wpawn2ndXboard = (int)WhitePieceXData[9];// Getting x from data as 2nd Xboard int Wpawn3rdXboard = (int)WhitePieceXData[10];// Getting x from data as 3rd Xboard int Wpawn4thXboard = (int)WhitePieceXData[11];// Getting x from data as 4th Xboard int Wpawn5thXboard = (int)WhitePieceXData[12];// Getting x from data as 5th Xboard int Wpawn6thXboard = (int)WhitePieceXData[13];// Getting x from data as 6th Xboard int Wpawn7thXboard = (int)WhitePieceXData[14];// Getting x from data as 7th Xboard int Wpawn8thXboard = (int)WhitePieceXData[15];// Getting x from data as 8th Xboard if (Pycs[16].GetPhotonView().Owner.IsMasterClient) // if pyc 16 means other object is owned by masterclient then set { // get.. mains white x Pycs[16].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[16], WrookXboard); Pycs[17].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[17], WknightXboard); Pycs[18].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[18], WbishopXboard); Pycs[19].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[19], WqueenXboard); Pycs[20].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[20], WkingXboard); Pycs[21].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[21], WbishopsecXboard); Pycs[22].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[22], WknightsecXboard); Pycs[23].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[23], WrooksecXboard); //get.. pawns white x Pycs[24].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[24], Wpawn1stXboard); Pycs[25].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[25], Wpawn2ndXboard); Pycs[26].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[26], Wpawn3rdXboard); Pycs[27].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[27], Wpawn4thXboard); Pycs[28].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[28], Wpawn5thXboard); Pycs[29].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[29], Wpawn6thXboard); Pycs[30].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[30], Wpawn7thXboard); Pycs[31].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[31], Wpawn8thXboard); } } if (obj.Code == Board_Change_Event_WY) // setting white y { object[] WhitePieceYData = (object[])obj.CustomData; // get data //main set .... int WrookYboard = (int)WhitePieceYData[0]; int WknightYboard = (int)WhitePieceYData[1]; int WbishopYboard = (int)WhitePieceYData[2]; int WqueenYboard = (int)WhitePieceYData[3]; int WkingYboard = (int)WhitePieceYData[4]; int WbishopsecYboard = (int)WhitePieceYData[5]; // second bishop set y int WknightsecYboard = (int)WhitePieceYData[6]; // second knight set y int WrooksecYboard = (int)WhitePieceYData[7]; // second rook set y // pawn set ... int Wpawn1stYboard = (int)WhitePieceYData[8]; int Wpawn2ndYboard = (int)WhitePieceYData[9]; int Wpawn3rdYboard = (int)WhitePieceYData[10]; int Wpawn4thYboard = (int)WhitePieceYData[11]; int Wpawn5thYoard = (int)WhitePieceYData[12]; int Wpawn6thYoard = (int)WhitePieceYData[13]; int Wpawn7thYoard = (int)WhitePieceYData[14]; int Wpawn8thYoard = (int)WhitePieceYData[15]; if (Pycs[16].GetPhotonView().Owner.IsMasterClient) // if owned by masterclient { // get.. mains white y Pycs[16].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[16], WrookYboard); Pycs[17].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[17], WknightYboard); Pycs[18].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[18], WbishopYboard); Pycs[19].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[19], WqueenYboard); Pycs[20].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[20], WkingYboard); Pycs[21].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[21], WbishopsecYboard); Pycs[22].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[22], WknightsecYboard); Pycs[23].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[23], WrooksecYboard); //get.. pawns white y Pycs[24].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[24], Wpawn1stYboard); Pycs[25].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[25], Wpawn2ndYboard); Pycs[26].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[26], Wpawn3rdYboard); Pycs[27].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[27], Wpawn4thYboard); Pycs[28].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[28], Wpawn5thYoard); Pycs[29].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[29], Wpawn6thYoard); Pycs[30].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[30], Wpawn7thYoard); Pycs[31].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[31], Wpawn8thYoard); } } // black set.. get.. if (obj.Code == Board_Change_Event_BX) // set.. get.. black x { object[] BlackPieceXData = (object[])obj.CustomData; // get all data // set black main piece x int BrookXboard = (int)BlackPieceXData[0]; int BknightXboard = (int)BlackPieceXData[1]; int BbishopXboard = (int)BlackPieceXData[2]; int BqueenXboard = (int)BlackPieceXData[3]; int BkingXboard = (int)BlackPieceXData[4]; int BbishopsecXboard = (int)BlackPieceXData[5]; int BknightsecXboard = (int)BlackPieceXData[6]; int BrooksecXboard = (int)BlackPieceXData[7]; // set black pawn piece x int Bpawn1stXboard = (int)BlackPieceXData[8]; int Bpawn2ndXboard = (int)BlackPieceXData[9]; int Bpawn3rdXboard = (int)BlackPieceXData[10]; int Bpawn4thXboard = (int)BlackPieceXData[11]; int Bpawn5thXboard = (int)BlackPieceXData[12]; int Bpawn6thXboard = (int)BlackPieceXData[13]; int Bpawn7thXboard = (int)BlackPieceXData[14]; int Bpawn8thXboard = (int)BlackPieceXData[15]; if (!Pycs[16].GetPhotonView().Owner.IsMasterClient) // if not owned by the mater client { // get.. mains black x Pycs[16].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[16], BrookXboard); Pycs[17].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[17], BknightXboard); Pycs[18].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[18], BbishopXboard); Pycs[19].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[19], BqueenXboard); Pycs[20].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[20], BkingXboard); Pycs[21].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[21], BbishopsecXboard); Pycs[22].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[22], BknightsecXboard); Pycs[23].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[23], BrooksecXboard); //get.. pawns black x Pycs[24].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[24], Bpawn1stXboard); Pycs[25].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[25], Bpawn2ndXboard); Pycs[26].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[26], Bpawn3rdXboard); Pycs[27].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[27], Bpawn4thXboard); Pycs[28].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[28], Bpawn5thXboard); Pycs[29].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[29], Bpawn6thXboard); Pycs[30].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[30], Bpawn7thXboard); Pycs[30].GetComponent<DiedChessman>().Set_Xboard_Easy(Pycs[31], Bpawn8thXboard); } } if (obj.Code == Board_Change_Event_BY) // set.. get.. black y { object[] BlackPieceYData = (object[])obj.CustomData; // set.. y black data //mains black y set.. int BrookYboard = (int)BlackPieceYData[0]; int BknightYboard = (int)BlackPieceYData[1]; int BbishopYboard = (int)BlackPieceYData[2]; int BqueenYboard = (int)BlackPieceYData[3]; int BkingYboard = (int)BlackPieceYData[4]; int BbishopsecYboard = (int)BlackPieceYData[5]; int BknightsecYboard = (int)BlackPieceYData[6]; int BrooksecYboard = (int)BlackPieceYData[7]; // pawn black y set int Bpawn1stYboard = (int)BlackPieceYData[8]; int Bpawn2ndYboard = (int)BlackPieceYData[9]; int Bpawn3rdYboard = (int)BlackPieceYData[10]; int Bpawn4thYboard = (int)BlackPieceYData[11]; int Bpawn5thYoard = (int)BlackPieceYData[12]; int Bpawn6thYoard = (int)BlackPieceYData[13]; int Bpawn7thYoard = (int)BlackPieceYData[14]; int Bpawn8thYoard = (int)BlackPieceYData[15]; if (!Pycs[16].GetPhotonView().Owner.IsMasterClient) // if the 16th piece owner is not master client { // get.. mains black y Pycs[16].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[16], BrookYboard); Pycs[17].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[17], BknightYboard); Pycs[18].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[18], BbishopYboard); Pycs[19].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[19], BqueenYboard); Pycs[20].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[20], BkingYboard); Pycs[21].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[21], BbishopsecYboard); Pycs[22].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[22], BknightsecYboard); Pycs[23].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[23], BrooksecYboard); //get.. pawns black y Pycs[24].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[24], Bpawn1stYboard); Pycs[25].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[25], Bpawn2ndYboard); Pycs[26].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[26], Bpawn3rdYboard); Pycs[27].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[27], Bpawn4thYboard); Pycs[28].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[28], Bpawn5thYoard); Pycs[29].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[29], Bpawn6thYoard); Pycs[30].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[30], Bpawn7thYoard); Pycs[31].GetComponent<DiedChessman>().Set_Yboard_Easy(Pycs[31], Bpawn8thYoard); } } } // referenceof sprites //References to all the possible Sprites that this Chesspiece could be public Sprite black_queen, black_knight, black_bishop, black_king, black_rook, black_pawn; public Sprite white_queen, white_knight, white_bishop, white_king, white_rook, white_pawn; // made for set non-player function public void Set_Player_Properties() { // for master client if (PhotonNetwork.IsMasterClient) { GameObject[] Pycses = GameObject.FindGameObjectsWithTag("Pieces"); GameObject Controllr = GameObject.FindGameObjectWithTag("GameController"); //Setting Player Pycses[16].GetComponent<Chessman>().player = "black"; Pycses[17].GetComponent<Chessman>().player = "black"; Pycses[18].GetComponent<Chessman>().player = "black"; Pycses[19].GetComponent<Chessman>().player = "black"; Pycses[20].GetComponent<Chessman>().player = "black"; Pycses[21].GetComponent<Chessman>().player = "black"; Pycses[22].GetComponent<Chessman>().player = "black"; Pycses[23].GetComponent<Chessman>().player = "black"; Pycses[24].GetComponent<Chessman>().player = "black"; Pycses[25].GetComponent<Chessman>().player = "black"; Pycses[26].GetComponent<Chessman>().player = "black"; Pycses[27].GetComponent<Chessman>().player = "black"; Pycses[28].GetComponent<Chessman>().player = "black"; Pycses[29].GetComponent<Chessman>().player = "black"; Pycses[30].GetComponent<Chessman>().player = "black"; Pycses[31].GetComponent<Chessman>().player = "black"; //Setting Controller Pycses[16].GetComponent<Chessman>().controller = Controllr; Pycses[17].GetComponent<Chessman>().controller = Controllr; Pycses[18].GetComponent<Chessman>().controller = Controllr; Pycses[19].GetComponent<Chessman>().controller = Controllr; Pycses[20].GetComponent<Chessman>().controller = Controllr; Pycses[21].GetComponent<Chessman>().controller = Controllr; Pycses[22].GetComponent<Chessman>().controller = Controllr; Pycses[23].GetComponent<Chessman>().controller = Controllr; Pycses[24].GetComponent<Chessman>().controller = Controllr; Pycses[25].GetComponent<Chessman>().controller = Controllr; Pycses[26].GetComponent<Chessman>().controller = Controllr; Pycses[27].GetComponent<Chessman>().controller = Controllr; Pycses[28].GetComponent<Chessman>().controller = Controllr; Pycses[29].GetComponent<Chessman>().controller = Controllr; Pycses[30].GetComponent<Chessman>().controller = Controllr; Pycses[31].GetComponent<Chessman>().controller = Controllr; } // for Non Master client if (!PhotonNetwork.IsMasterClient) { GameObject[] Pycses = GameObject.FindGameObjectsWithTag("Pieces"); GameObject Controllr = GameObject.FindGameObjectWithTag("GameController"); //Setting Player Pycses[16].GetComponent<Chessman>().player = "white"; Pycses[17].GetComponent<Chessman>().player = "white"; Pycses[18].GetComponent<Chessman>().player = "white"; Pycses[19].GetComponent<Chessman>().player = "white"; Pycses[20].GetComponent<Chessman>().player = "white"; Pycses[21].GetComponent<Chessman>().player = "white"; Pycses[22].GetComponent<Chessman>().player = "white"; Pycses[23].GetComponent<Chessman>().player = "white"; Pycses[24].GetComponent<Chessman>().player = "white"; Pycses[25].GetComponent<Chessman>().player = "white"; Pycses[26].GetComponent<Chessman>().player = "white"; Pycses[27].GetComponent<Chessman>().player = "white"; Pycses[28].GetComponent<Chessman>().player = "white"; Pycses[29].GetComponent<Chessman>().player = "white"; Pycses[30].GetComponent<Chessman>().player = "white"; Pycses[31].GetComponent<Chessman>().player = "white"; //Setting Controller Pycses[16].GetComponent<Chessman>().controller = Controllr; Pycses[17].GetComponent<Chessman>().controller = Controllr; Pycses[18].GetComponent<Chessman>().controller = Controllr; Pycses[19].GetComponent<Chessman>().controller = Controllr; Pycses[20].GetComponent<Chessman>().controller = Controllr; Pycses[21].GetComponent<Chessman>().controller = Controllr; Pycses[22].GetComponent<Chessman>().controller = Controllr; Pycses[23].GetComponent<Chessman>().controller = Controllr; Pycses[24].GetComponent<Chessman>().controller = Controllr; Pycses[25].GetComponent<Chessman>().controller = Controllr; Pycses[26].GetComponent<Chessman>().controller = Controllr; Pycses[27].GetComponent<Chessman>().controller = Controllr; Pycses[28].GetComponent<Chessman>().controller = Controllr; Pycses[29].GetComponent<Chessman>().controller = Controllr; Pycses[30].GetComponent<Chessman>().controller = Controllr; Pycses[31].GetComponent<Chessman>().controller = Controllr; } } public void Sprite_Change_of_any() { GameObject[] pyc = GameObject.FindGameObjectsWithTag("Pieces"); if (!PhotonNetwork.IsMasterClient) // owned by masterclient { pyc[16].GetComponent<SpriteRenderer>().sprite = white_rook; pyc[17].GetComponent<SpriteRenderer>().sprite = white_knight; pyc[18].GetComponent<SpriteRenderer>().sprite = white_bishop; pyc[19].GetComponent<SpriteRenderer>().sprite = white_queen; pyc[20].GetComponent<SpriteRenderer>().sprite = white_king; pyc[21].GetComponent<SpriteRenderer>().sprite = white_bishop; pyc[22].GetComponent<SpriteRenderer>().sprite = white_knight; pyc[23].GetComponent<SpriteRenderer>().sprite = white_rook; pyc[24].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[25].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[26].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[27].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[28].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[29].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[30].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[31].GetComponent<SpriteRenderer>().sprite = white_pawn; pyc[16].name = "white_rook"; pyc[17].name = "white_knight"; pyc[18].name = "white_bishop"; pyc[19].name = "white_queen"; pyc[20].name = "white_king"; pyc[21].name = "white_bishop"; pyc[22].name = "white_knight"; pyc[23].name = "white_rook"; pyc[24].name = "white_pawn"; pyc[25].name = "white_pawn"; pyc[26].name = "white_pawn"; pyc[27].name = "white_pawn"; pyc[28].name = "white_pawn"; pyc[29].name = "white_pawn"; pyc[30].name = "white_pawn"; pyc[31].name = "white_pawn"; } if (PhotonNetwork.IsMasterClient) //owned by master client { pyc[16].GetComponent<SpriteRenderer>().sprite = black_rook; pyc[17].GetComponent<SpriteRenderer>().sprite = black_knight; pyc[18].GetComponent<SpriteRenderer>().sprite = black_bishop; pyc[19].GetComponent<SpriteRenderer>().sprite = black_queen; pyc[20].GetComponent<SpriteRenderer>().sprite = black_king; pyc[21].GetComponent<SpriteRenderer>().sprite = black_bishop; pyc[22].GetComponent<SpriteRenderer>().sprite = black_knight; pyc[23].GetComponent<SpriteRenderer>().sprite = black_rook; pyc[24].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[25].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[26].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[27].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[28].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[29].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[30].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[31].GetComponent<SpriteRenderer>().sprite = black_pawn; pyc[16].name = "black_rook"; pyc[17].name = "black_knight"; pyc[18].name = "black_bishop"; pyc[19].name = "black_queen"; pyc[20].name = "black_king"; pyc[21].name = "black_bishop"; pyc[22].name = "black_knight"; pyc[23].name = "black_rook"; pyc[24].name = "black_pawn"; pyc[25].name = "black_pawn"; pyc[26].name = "black_pawn"; pyc[27].name = "black_pawn"; pyc[28].name = "black_pawn"; pyc[29].name = "black_pawn"; pyc[30].name = "black_pawn"; pyc[31].name = "black_pawn"; } } // Made for Easy Working public void SetposEmpty_Easy(GameObject obj) { obj.GetComponent<Chessman>().controller.GetComponent<Game>().SetPositionEmpty(obj.GetComponent<Chessman>().GetXBoard(), obj.GetComponent<Chessman>().GetYBoard()); } public void Setpos_Easy(GameObject obj) { obj.GetComponent<Chessman>().controller.GetComponent<Game>().SetPosition(obj); } public void Set_Xboard_Easy(GameObject obj , int x) { obj.GetComponent<Chessman>().SetXBoard(x); } public void Set_Yboard_Easy(GameObject obj , int y) { obj.GetComponent<Chessman>().SetYBoard(y); } public void Set_pOs_Very_Easy() { GameObject[] Pycs = GameObject.FindGameObjectsWithTag("Pieces"); Pycs[16].GetComponent<DiedChessman>().Setpos_Easy(Pycs[16]); Pycs[17].GetComponent<DiedChessman>().Setpos_Easy(Pycs[17]); Pycs[18].GetComponent<DiedChessman>().Setpos_Easy(Pycs[18]); Pycs[19].GetComponent<DiedChessman>().Setpos_Easy(Pycs[19]); Pycs[20].GetComponent<DiedChessman>().Setpos_Easy(Pycs[20]); Pycs[21].GetComponent<DiedChessman>().Setpos_Easy(Pycs[21]); Pycs[22].GetComponent<DiedChessman>().Setpos_Easy(Pycs[22]); Pycs[23].GetComponent<DiedChessman>().Setpos_Easy(Pycs[23]); //pawn section Pycs[24].GetComponent<DiedChessman>().Setpos_Easy(Pycs[24]); Pycs[25].GetComponent<DiedChessman>().Setpos_Easy(Pycs[25]); Pycs[26].GetComponent<DiedChessman>().Setpos_Easy(Pycs[26]); Pycs[27].GetComponent<DiedChessman>().Setpos_Easy(Pycs[27]); Pycs[28].GetComponent<DiedChessman>().Setpos_Easy(Pycs[28]); Pycs[29].GetComponent<DiedChessman>().Setpos_Easy(Pycs[29]); Pycs[30].GetComponent<DiedChessman>().Setpos_Easy(Pycs[30]); Pycs[31].GetComponent<DiedChessman>().Setpos_Easy(Pycs[31]); } //setting info online for player public void Activate() { //Get the game controller controller = GameObject.FindGameObjectWithTag("GameController"); //Take the instantiated location and adjust transform SetCoords(); //Choose correct sprite based on piece's name switch (this.name) { case "black_queen": this.GetComponent<SpriteRenderer>().sprite = black_queen; player = "black"; break; case "black_knight": this.GetComponent<SpriteRenderer>().sprite = black_knight; player = "black"; break; case "black_bishop": this.GetComponent<SpriteRenderer>().sprite = black_bishop; player = "black"; break; case "black_king": this.GetComponent<SpriteRenderer>().sprite = black_king; player = "black"; break; case "black_rook": this.GetComponent<SpriteRenderer>().sprite = black_rook; player = "black"; break; case "black_pawn": this.GetComponent<SpriteRenderer>().sprite = black_pawn; player = "black"; break; case "white_queen": this.GetComponent<SpriteRenderer>().sprite = white_queen; player = "white"; break; case "white_knight": this.GetComponent<SpriteRenderer>().sprite = white_knight; player = "white"; break; case "white_bishop": this.GetComponent<SpriteRenderer>().sprite = white_bishop; player = "white"; break; case "white_king": this.GetComponent<SpriteRenderer>().sprite = white_king; player = "white"; break; case "white_rook": this.GetComponent<SpriteRenderer>().sprite = white_rook; player = "white"; break; case "white_pawn": this.GetComponent<SpriteRenderer>().sprite = white_pawn; player = "white"; break; } } public void SetCoords() { //Get the board value in order to convert to xy coords float x = xBoard; float y = yBoard; //Adjust by variable offset x *= 0.66f; y *= 0.66f; //Add constants (pos 0,0) x += -2.3f; y += -2.3f; //Set actual unity values this.transform.position = new Vector3(x, y, -1.0f); } // get & set boards public int GetXBoard() { return xBoard; } public int GetYBoard() { return yBoard; } public void SetXBoard(int x) { xBoard = x; } public void SetYBoard(int y) { yBoard = y; } // Move Plate for public void Plates() { if (controller.GetComponent<Game>().GetCurrentPlayer() == "black" && !PhotonNetwork.IsMasterClient || controller.GetComponent<Game>().GetCurrentPlayer() == "white" && PhotonNetwork.IsMasterClient) { if (!controller.GetComponent<Game>().IsGameOver() && controller.GetComponent<Game>().GetCurrentPlayer() == player) { //Remove all moveplates relating to previously selected piece DestroyMovePlates(); //Create new MovePlates InitiateMovePlates(); } } } public void DestroyMovePlates() { //Destroy old MovePlates GameObject[] movePlates = GameObject.FindGameObjectsWithTag("MovePlate"); for (int i = 0; i < movePlates.Length; i++) { Destroy(movePlates[i]); //Be careful with this function "Destroy" it is asynchronous } } public void InitiateMovePlates() { switch (this.name) { case "black_queen": case "white_queen": LineMovePlate(1, 0); LineMovePlate(0, 1); LineMovePlate(1, 1); LineMovePlate(-1, 0); LineMovePlate(0, -1); LineMovePlate(-1, -1); LineMovePlate(-1, 1); LineMovePlate(1, -1); break; case "black_knight": case "white_knight": LMovePlate(); break; case "black_bishop": case "white_bishop": LineMovePlate(1, 1); LineMovePlate(1, -1); LineMovePlate(-1, 1); LineMovePlate(-1, -1); break; case "black_king": case "white_king": SurroundMovePlate(); break; case "black_rook": case "white_rook": LineMovePlate(1, 0); LineMovePlate(0, 1); LineMovePlate(-1, 0); LineMovePlate(0, -1); break; case "black_pawn": PawnMovePlate(xBoard, yBoard - 1); break; case "white_pawn": PawnMovePlate(xBoard, yBoard + 1); break; } } // Line Move Plate public void LineMovePlate(int xIncrement, int yIncrement) { Game sc = controller.GetComponent<Game>(); int x = xBoard + xIncrement; int y = yBoard + yIncrement; while (sc.PositionOnBoard(x, y) && sc.GetPosition(x, y) == null) { MovePlateSpawn(x, y); x += xIncrement; y += yIncrement; } // 1. First Contition ---- Pos On Board Pos Goes Out or Not // 2. Second Condition -------- Get Pos Means Getting the Pos AND Player Of this.player is not equal to this.player if (sc.PositionOnBoard(x, y) && sc.GetPosition(x, y) != null && sc.GetPosition(x, y).GetComponent<Chessman>().player != player) // && sc.GetPosition(x, y).GetComponent<Chessman>().player != player <<<<<<<<<<<< Can Use on This Line if(Statement) { MovePlateAttackSpawn(x, y); // Components Of The If StateMent // 1 . Sc = Local Variable For Game Script // 2 . GetPos = Return The X , Y - Pos On Board // 3 . GetChessManScript = Get Chess Man Script // 4 . .Player = Getting the Player For Chess Man Script In String Form // 5 . != = Not Equal To // 6 . MultiplayerYourPlayer = My Multiplayer In the Form Of String } } public void LMovePlate() { PointMovePlate(xBoard + 1, yBoard + 2); PointMovePlate(xBoard - 1, yBoard + 2); PointMovePlate(xBoard + 2, yBoard + 1); PointMovePlate(xBoard + 2, yBoard - 1); PointMovePlate(xBoard + 1, yBoard - 2); PointMovePlate(xBoard - 1, yBoard - 2); PointMovePlate(xBoard - 2, yBoard + 1); PointMovePlate(xBoard - 2, yBoard - 1); } public void SurroundMovePlate() { PointMovePlate(xBoard, yBoard + 1); PointMovePlate(xBoard, yBoard - 1); PointMovePlate(xBoard - 1, yBoard + 0); PointMovePlate(xBoard - 1, yBoard - 1); PointMovePlate(xBoard - 1, yBoard + 1); PointMovePlate(xBoard + 1, yBoard + 0); PointMovePlate(xBoard + 1, yBoard - 1); PointMovePlate(xBoard + 1, yBoard + 1); } public void PointMovePlate(int x, int y) { Game sc = controller.GetComponent<Game>(); if (sc.PositionOnBoard(x, y)) { GameObject cp = sc.GetPosition(x, y); if (cp == null) { MovePlateSpawn(x, y); } else if (cp.GetComponent<Chessman>().player != player) { MovePlateAttackSpawn(x, y); } } } public void PawnMovePlate(int x, int y) { Game sc = controller.GetComponent<Game>(); if (sc.PositionOnBoard(x, y)) { if (sc.GetPosition(x, y) == null) { MovePlateSpawn(x, y); } if (sc.PositionOnBoard(x + 1, y) && sc.GetPosition(x + 1, y) != null && sc.GetPosition(x + 1, y).GetComponent<Chessman>().player != player) { Debug.Log("finally it works 667 line" + sc); MovePlateAttackSpawn(x + 1, y); } if (sc.PositionOnBoard(x - 1, y) && sc.GetPosition(x - 1, y) != null && sc.GetPosition(x - 1, y).GetComponent<Chessman>().player != player) { Debug.Log("finally it works 673 line " + sc); MovePlateAttackSpawn(x - 1, y); } } } public void MovePlateSpawn(int matrixX, int matrixY) { //Get the board value in order to convert to xy coords float x = matrixX; float y = matrixY; //Adjust by variable offset x *= 0.66f; y *= 0.66f; //Add constants (pos 0,0) x += -2.3f; y += -2.3f; //Set actual unity values GameObject mp = Instantiate(movePlate, new Vector3(x, y, -3.0f), Quaternion.identity); MovePlate mpScript = mp.GetComponent<MovePlate>(); mpScript.SetReference(gameObject); mpScript.SetCoords(matrixX, matrixY); } public void MovePlateAttackSpawn(int matrixX, int matrixY) { //Get the board value in order to convert to xy coords float x = matrixX; float y = matrixY; //Adjust by variable offset x *= 0.66f; y *= 0.66f; //Add constants (pos 0,0) x += -2.3f; y += -2.3f; //Set actual unity values GameObject mp = Instantiate(movePlate, new Vector3(x, y, -3.0f), Quaternion.identity); MovePlate mpScript = mp.GetComponent<MovePlate>(); mpScript.attack = true; mpScript.SetReference(gameObject); mpScript.SetCoords(matrixX, matrixY); } // sending these over to MOVE PLATE SCRIPT // Pun as rpcs logs [PunRPC] public void Destroy_Function_RPC(int viewid) { PhotonView PhotonViewid = PhotonView.Find(viewid); if (PhotonViewid.gameObject.GetPhotonView().IsMine) { PhotonViewid.gameObject.GetPhotonView().RPC("Instantiating_Empty_Obj", RpcTarget.All,viewid,$"Empty obj {PhotonViewid.gameObject.name}"); } } [PunRPC] public void Instantiating_Empty_Obj(int Viewid, string name) { PhotonView PVid = PhotonView.Find(Viewid); int TIndex = PVid.gameObject.transform.GetSiblingIndex(); Vector3 Pos = new Vector3(100, 100, 199); GameObject controller = GameObject.FindGameObjectWithTag("GameController"); Game Gm = controller.GetComponent<Game>(); PVid.gameObject.GetComponent<DiedChessman>().SetposEmpty_Easy(PVid.gameObject); if (PVid.gameObject.GetPhotonView().IsMine) { PhotonNetwork.Destroy(PVid.gameObject); } GameObject EmtyObj = Instantiate(Gm.EmptyObj, Pos, Quaternion.identity); if (PVid.gameObject == null) { EmtyObj.GetPhotonView().ViewID = Viewid; } EmtyObj.transform.SetSiblingIndex(TIndex); EmtyObj.name = name; } [PunRPC] public void Onsend_XYB() { //for master client if (PhotonNetwork.IsMasterClient) { GameObject[] pycs = GameObject.FindGameObjectsWithTag("Pieces"); // info white Pieces object[] WhitePieceXData = new object[16]; //Made a array of the xboard which i want to send from 0-15 WhitePieceXData[0] = pycs[0].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[0]); WhitePieceXData[1] = pycs[1].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[1]); WhitePieceXData[2] = pycs[2].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[2]); WhitePieceXData[3] = pycs[3].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[3]); WhitePieceXData[4] = pycs[4].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[4]); WhitePieceXData[5] = pycs[5].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[5]); WhitePieceXData[6] = pycs[6].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[6]); WhitePieceXData[7] = pycs[7].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[7]); WhitePieceXData[8] = pycs[8].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[8]); WhitePieceXData[9] = pycs[9].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[9]); WhitePieceXData[10] = pycs[10].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[10]); WhitePieceXData[11] = pycs[11].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[11]); WhitePieceXData[12] = pycs[12].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[12]); WhitePieceXData[13] = pycs[13].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[13]); WhitePieceXData[14] = pycs[14].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[14]); WhitePieceXData[15] = pycs[15].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[15]); object[] WhitePieceYData = new object[16]; ////Made a array of the Yboard which i want to send from 0-15 WhitePieceYData[0] = pycs[0].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[0]); WhitePieceYData[1] = pycs[1].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[1]); WhitePieceYData[2] = pycs[2].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[2]); WhitePieceYData[3] = pycs[3].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[3]); WhitePieceYData[4] = pycs[4].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[4]); WhitePieceYData[5] = pycs[5].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[5]); WhitePieceYData[6] = pycs[6].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[6]); WhitePieceYData[7] = pycs[7].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[7]); WhitePieceYData[8] = pycs[8].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[8]); WhitePieceYData[9] = pycs[9].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[9]); WhitePieceYData[10] = pycs[10].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[10]); WhitePieceYData[11] = pycs[11].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[11]); WhitePieceYData[12] = pycs[12].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[12]); WhitePieceYData[13] = pycs[13].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[13]); WhitePieceYData[14] = pycs[14].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[14]); WhitePieceYData[15] = pycs[15].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[15]); RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.All }; PhotonNetwork.RaiseEvent(Board_Change_Event_wX, WhitePieceXData, raiseEventOptions, SendOptions.SendUnreliable); PhotonNetwork.RaiseEvent(Board_Change_Event_WY, WhitePieceYData, raiseEventOptions, SendOptions.SendUnreliable); } //for non-master client if (!PhotonNetwork.IsMasterClient) { GameObject[] pycs = GameObject.FindGameObjectsWithTag("Pieces"); // getting all the pieces but the black piece is on 0-15 object[] BlackPieceXData = new object[16]; // obj for sending BlackPieceXData[0] = pycs[0].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[0]); BlackPieceXData[1] = pycs[1].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[1]); BlackPieceXData[2] = pycs[2].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[2]); BlackPieceXData[3] = pycs[3].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[3]); BlackPieceXData[4] = pycs[4].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[4]); BlackPieceXData[5] = pycs[5].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[5]); BlackPieceXData[6] = pycs[6].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[6]); BlackPieceXData[7] = pycs[7].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[7]); BlackPieceXData[8] = pycs[8].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[8]); BlackPieceXData[9] = pycs[9].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[9]); BlackPieceXData[10] = pycs[10].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[10]); BlackPieceXData[11] = pycs[11].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[11]); BlackPieceXData[12] = pycs[12].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[12]); BlackPieceXData[13] = pycs[13].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[13]); BlackPieceXData[14] = pycs[14].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[14]); BlackPieceXData[15] = pycs[15].GetComponent<DiedChessman>().Get_X_Board_Easy(pycs[15]); object[] BlackPieceYData = new object[16]; // getting all the pieces but the black piece is on 0-15 BlackPieceYData[0] = pycs[0].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[0]); BlackPieceYData[1] = pycs[1].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[1]); BlackPieceYData[2] = pycs[2].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[2]); BlackPieceYData[3] = pycs[3].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[3]); BlackPieceYData[4] = pycs[4].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[4]); BlackPieceYData[5] = pycs[5].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[5]); BlackPieceYData[6] = pycs[6].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[6]); BlackPieceYData[7] = pycs[7].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[7]); BlackPieceYData[8] = pycs[8].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[8]); BlackPieceYData[9] = pycs[9].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[9]); BlackPieceYData[10] = pycs[10].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[10]); BlackPieceYData[11] = pycs[11].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[11]); BlackPieceYData[12] = pycs[12].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[12]); BlackPieceYData[13] = pycs[13].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[13]); BlackPieceYData[14] = pycs[14].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[14]); BlackPieceYData[15] = pycs[15].GetComponent<DiedChessman>().Get_Y_Board_Easy(pycs[15]); RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.All }; PhotonNetwork.RaiseEvent(Board_Change_Event_BX, BlackPieceXData, raiseEventOptions, SendOptions.SendUnreliable); PhotonNetwork.RaiseEvent(Board_Change_Event_BY, BlackPieceYData, raiseEventOptions, SendOptions.SendUnreliable); } } [PunRPC] public void Onsend_POS() { // setting pos empty GameObject[] Pycs = GameObject.FindGameObjectsWithTag("Pieces"); Pycs[16].GetComponent<Chessman>().Onsend_XYB(); Pycs[16].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[16]); Pycs[17].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[17]); Pycs[18].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[18]); Pycs[19].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[19]); Pycs[20].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[20]); Pycs[21].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[21]); Pycs[22].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[22]); Pycs[23].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[23]); // pawn Pycs[24].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[24]); Pycs[25].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[25]); Pycs[26].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[26]); Pycs[27].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[27]); Pycs[28].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[28]); Pycs[29].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[29]); Pycs[30].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[30]); Pycs[31].GetComponent<DiedChessman>().SetposEmpty_Easy(Pycs[31]); //setting latest x board and y board Pycs[16].GetComponent<Chessman>().Onsend_XYB(); Pycs[16].GetComponent<Chessman>().Set_pOs_Very_Easy(); // setting pos //mains } }
0
Comments
-
You may want to take a look at the Analyzing Disconnects doc.
You may be sending too much too frequently or any such.
Without an error message, we can't help. We do not read this amount of code. The code tags are for clarification, not to post hundreds of lines without GameObject context.
Also read the Get Help doc and add the missing info (don't post an AppId).0 -
firstly a very very thanku for your reply Can you please tell me if i send a raise event like in the given code bellow when will i get this code in the other client i means how much timetime it actually takes0
-
I can't check your code for you.
If you want to know how it performs, use the Profiler of Unity to get an idea.
If the question is how long it takes to send some data: It depends on the amount of data you send and your connection. Photon is not meant to send huge amounts of data. If you need to share more than 500kB (give or take), it might be better to do this via a rest service (which can be combined with Photon).1 -
You are right but can you please explain me with example what is the difference between the Sending a code Reliable and Sendia code unReliable0
-
The Sequencing section in the docs probably explains the difference best and in most detail.0
-
not a code i want to say a raise event how can i do that can you please explain it yourself in more simpler way as i have already read the photon doc for that but i am not able to got it please explain in simple language0