void Hurt(PhotonView view, int attackerId, int damage) { if (view != null && view.Owner != null) { var health = view.Owner.GetHealth(); if (health > 0) { health -= damage; view.Owner.SetHealth(health); if (health > 0) { view.RPC(GameConst.RpcDamage, view.Owner, attackerId, health); } else { view.RPC(GameConst.RpcDie, RpcTarget.All, attackerId); } } } else if (view != null && view.CompareTag(GameConst.TagAI)) { var health = PhotonNetwork.CurrentRoom.GetBotHealth(view.ViewID); if (health > 0) { health -= damage; PhotonNetwork.CurrentRoom.SetBotHealth(view.ViewID, health); if (health > 0) { view.RPC(GameConst.RpcDamage, RpcTarget.MasterClient, attackerId, health); } else { view.RPC(GameConst.RpcDie, RpcTarget.All, attackerId); } } } }