private void OnPhotonEvent(byte eventCode, object content, int senderID) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code == PhotonEventCodes.Scored) { if (this.role == 1 && view.isMine) { var score = PhotonNetwork.player.GetScore(); PhotonNetwork.player.SetScore((score) + 1); } else if (this.role == 2 && view.isMine) { var score = PhotonNetwork.player.GetScore(); PhotonNetwork.player.SetScore((score) - 1); } hitedTimes++; } if (code == PhotonEventCodes.GameOver) { PhotonNetwork.LoadLevel("GameOver_OnlineGame_2"); } if (code == PhotonEventCodes.StartGame) { PhotonNetwork.player.SetScore(0); panelReady.SetActive(false); StartCoroutine(this.Wait()); } }
/// <summary> /// CALLBACK: Subcribed upon OnEnable and Unsubsribed upon OnDisable /// </summary> /// <param name="eventCode"></param> /// <param name="content"></param> /// <param name="senderId"></param> private void PhotonNetwork_OnEventCall(byte eventCode, object content, int senderId) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code == PhotonEventCodes.RespawnPlayer) { object[] datas = content as object[]; if (datas.Length == 3) { if (RespawnPlayerCoroutine != null) { StopCoroutine(RespawnPlayerCoroutine); } RespawnPlayerCoroutine = RespawnPlayer((int)datas[0], (string)datas[1], (string)datas[2]); StartCoroutine(RespawnPlayerCoroutine); } } else if (code.Equals(PhotonEventCodes.FireBulletFX)) { object[] datas = content as object[]; if (datas.Length.Equals(4)) { FireBulletFX((bool)datas[0], (Vector3)datas[1], (HitTargets)datas[2], (string)datas[3]); } } }
private void PhotonNetwork_OnEventCall(byte eventCode, object content, int senderId) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code == PhotonEventCodes.ColorChange) { object[] datas = content as object[]; if (datas.Length == 4) { if ((int)datas[0] == base.photonView.viewID) { BallMaterial.color = new Color((float)datas[1], (float)datas[2], (float)datas[3]); } } } if (code == PhotonEventCodes.BallMovement) { object[] datas = content as object[]; if (datas.Length == 4) { if ((int)datas[0] == base.photonView.viewID) { BallMoveCoroutine = StartCoroutine(C_MoveFromTo((Vector3)datas[1], (Vector3)datas[2], (float)datas[3])); //float vertical = Input.GetAxis("Vertical"); //float horizontal = Input.GetAxis("Horizontal"); //transform.position += transform.forward * (vertical * 40 * Time.deltaTime) + transform.right * (horizontal * 40 * Time.deltaTime); } } } }
private void OnPhotonEvent(byte eventCode, object content, int senderID) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code == PhotonEventCodes.StartGame) { PhotonNetwork.player.SetScore(0); panelReady.SetActive(false); StartCoroutine(this.Wait()); } }
private void OnPhotonEvent(byte eventCode, object content, int senderID) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code == PhotonEventCodes.RoleDefine) { object[] datas = content as object[]; int data = (int)datas[0]; var roleName = ""; var sp = new Vector3(0, 0, 0); //En fonction du role et du fait que le joueur soit masterclient ou non //on défini le role name et la vector correspondants au GameObject //de son role if (PhotonNetwork.player.IsMasterClient) { if (data == 1) { roleName = "AttackPlayer_2"; sp = new Vector3(0, 0, 120); } else if (data == 2) { roleName = "DefensePlayer_2"; sp = new Vector3(0, 0, 95.2f); } } else { if (data == 1) { roleName = "DefensePlayer_2"; sp = new Vector3(0, 0, 95.2f); } else if (data == 2) { roleName = "AttackPlayer_2"; sp = new Vector3(0, 0, 120); } } //Puis instantiation du GameObject et activation de ses composants GameObject MyPlayer; MyPlayer = PhotonNetwork.Instantiate( roleName, sp, Quaternion.identity, 0 ); MyPlayer.GetComponent <PlayerController_2>().enabled = true; MyPlayer.GetComponentInChildren <Camera>().enabled = true; MyPlayer.GetComponentInChildren <Canvas>().enabled = true; } }
private void PhotonNetwork_OnEventCall(byte eventCode, object content, int senderId) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code == PhotonEventCodes.ChangeMovementType) { object[] datas = content as object[]; if (datas.Length == 2) { ChangeMovementType((int)datas[0], (MovementType)datas[1]); } } }
//Méthode appelée lors d'un event Photon //l'eventCode permet d'éxecuter différentes actions private void OnPhotonEvent(byte eventCode, object content, int senderID) { PhotonEventCodes code = (PhotonEventCodes)eventCode; //evenement de recuprération de l'array des choix des joueurs //dans tabChoices if (code == PhotonEventCodes.TabChoiceFilling) { object[] datas = content as object[]; if (datas.Length == 150) { for (int i = 0; i < 150; i++) { tabChoices[i] = (int)datas[i]; } //this.StartCoroutine(this.Wait()); } } if (code == PhotonEventCodes.StartGame) { PhotonNetwork.player.SetScore(0); panelReady.SetActive(false); this.StartCoroutine(this.Wait()); } //Event lorsqu'un joueur marque un point //Actualise le score joueur + adverse if (code == PhotonEventCodes.UpdateScores) { txtPlayerScore.text = PhotonNetwork.player.GetScore().ToString(); txtOpponentScore.text = otherPlayer.NickName + " : " + otherPlayer.GetScore().ToString(); } if (code == PhotonEventCodes.GameOver) { PhotonNetwork.LoadLevel("GameOver_1"); } }
private void OnPhotonEvent(byte eventCode, object content, int senderID) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code == PhotonEventCodes.StartGame) { PhotonNetwork.player.SetScore(0); panelReady.SetActive(false); StartCoroutine(this.StartTimer()); } if (code == PhotonEventCodes.Game_5_CanTap && view.isMine) { this.canTap = true; this.btnTap.interactable = true; this.imgTapIndicator.transform.rotation = Quaternion.Euler(0, 0, 0); this.imgTapIndicator.sprite = tapIndicatorSprites[1]; } if (code == PhotonEventCodes.Game_5_Tap) { RaiseEventOptions options = new RaiseEventOptions() { Receivers = ReceiverGroup.All }; PhotonNetwork.RaiseEvent((byte)PhotonEventCodes.Game_5_CantTap, 0, true, options); object[] datas = content as object[]; int playerTapID = (int)datas[0]; if (PhotonNetwork.isMasterClient) { StopCoroutine(this.StartTimer()); PhotonPlayer playerToScore = PhotonPlayer.Find(playerTapID); foreach (PhotonPlayer player in PhotonNetwork.playerList) { if (player.IsMasterClient) { int playerScore = playerToScore.GetScore(); playerToScore.SetScore(playerScore + 1); object[] playerName = new object[1]; playerName[0] = playerToScore.NickName; PhotonNetwork.RaiseEvent((byte)PhotonEventCodes.Game_5_DisplayPlayerSocred, playerName, true, options); } } } if (PhotonNetwork.isMasterClient) { Debug.Log("Timer ouvre toi !"); StartCoroutine(this.ScoredDelay()); } } if (code == PhotonEventCodes.Game_5_CantTap) { this.imgTapIndicator.sprite = tapIndicatorSprites[0]; this.imgTapIndicator.enabled = false; this.canTap = false; this.btnTap.interactable = false; } if (code == PhotonEventCodes.Game_5_DisplayPlayerSocred) { object[] datas = content as object[]; string playerScored = (string)datas[0]; this.txtPlayerScored.text = playerScored + " marque le point !"; } if (code == PhotonEventCodes.Game_5_DisplayWaiting) { this.txtPlayerScored.text = ""; this.imgTapIndicator.enabled = true; } }
private void PhotonNetwork_OnEventCall(byte eventCode, object content, int senderId) { PhotonEventCodes code = (PhotonEventCodes)eventCode; if (code.Equals(PhotonEventCodes.HealthReset)) { object[] datas = content as object[]; if (datas.Length.Equals(3)) { SetStat((string)datas[0], (PlayerStatCodes)datas[1], (int)datas[2]); } } else if (code.Equals(PhotonEventCodes.HealthUpdate)) { object[] datas = content as object[]; if (datas.Length.Equals(3)) { UpdateStat((string)datas[0], (PlayerStatCodes)datas[1], (int)datas[2]); } } else if (code.Equals(PhotonEventCodes.DamageDealt)) { object[] datas = content as object[]; if (datas.Length.Equals(3)) { UpdateStat((string)datas[0], (PlayerStatCodes)datas[1], (int)datas[2]); } } else if (code.Equals(PhotonEventCodes.DamageReceived)) { object[] datas = content as object[]; if (datas.Length.Equals(3)) { UpdateStat((string)datas[0], (PlayerStatCodes)datas[1], (int)datas[2]); } } else if (code.Equals(PhotonEventCodes.Kills)) { object[] datas = content as object[]; if (datas.Length.Equals(3)) { UpdateStat((string)datas[0], (PlayerStatCodes)datas[1], (int)datas[2]); } } else if (code.Equals(PhotonEventCodes.Deaths)) { object[] datas = content as object[]; if (datas.Length.Equals(3)) { UpdateStat((string)datas[0], (PlayerStatCodes)datas[1], (int)datas[2]); } } else if (code.Equals(PhotonEventCodes.DustFX)) { object[] datas = content as object[]; if (datas.Length.Equals(1)) { DustFX((bool)datas[0]); } } }