private void OnTriggerEnter2D(Collider2D other) { Debug.Log($"Collection fruit {photonView.InstantiationId} for player"); if (other.gameObject.tag == "Player") { FruitBasket fruitBasket = other.gameObject.GetComponent <FruitBasket>(); //if (fruitBasket != null && photonView.IsMine) if (fruitBasket != null && other.gameObject.GetComponent <PhotonView>().IsMine) { fruitBasket.Modify(Amount); } if (this.gameObject != null) { int playerId = other.gameObject.GetComponent <PlayerSetup>().PlayerNumber; Debug.Log($"Collection fruit {photonView.InstantiationId} for player id {playerId}"); OnCollected(fruitBasket.FruitCount, playerId); if (!photonView.IsMine && PhotonNetwork.LocalPlayer.IsMasterClient) { photonView.RPC("DestroyFruit", RpcTarget.AllBuffered); } } } }
private void DamagePlayer(Collider2D other) { if (other.gameObject.tag == "Player") { Debug.Log("Hit player"); FruitBasket fruitBasket = other.gameObject.GetComponent <FruitBasket>(); MovementController movementController = other.gameObject.GetComponent <MovementController>(); PhotonView photonV = other.gameObject.GetComponent <PhotonView>(); // if (PhotonNetwork.IsMasterClient && fruitBasket.Modifiable) // { // fruitBasket.Modify(-_damage); // movementController.KnockBack(); // } if (photonV.IsMine && fruitBasket.Modifiable) { fruitBasket.Modify(-_damage); movementController.KnockBack(); } } }