void HandleHitObject(object sender, GlobalGameState.HitObjectArgs e) { if (IsGameOver) { return; // No more } // This part should always only be run on the server. if (e.hitRaycast.transform.GetComponent <PlayerShield>() != null) { PlayerShield shield = e.hitRaycast.transform.GetComponent <PlayerShield>(); if (shield.shieldLevel <= 0) { return; // Probably destroy by another shot in the same frame } shield.shieldLevel -= e.hitStrength; // Add to my score int scoreToAdd = +10; if (shield.shieldLevel <= 0) { // Player has died. Network.Destroy(e.hitRaycast.transform.GetComponent <NetworkView>().viewID); Quaternion rotation = Quaternion.FromToRotation(Vector3.up, e.hitRaycast.normal); Network.Instantiate(e.explosionEffect, e.hitRaycast.transform.position, rotation, 0); scoreToAdd += +20; } // Now go back to the object itself and update the score. scoreBoard.AddToPlayerScoreByGuid(e.weaponObject.networkView.owner.guid, scoreToAdd); networkView.RPC("SetPlayerScores", RPCMode.Others, scoreBoard.Serialize()); if (scoreBoard.GetPlayerScoreByGui(e.weaponObject.networkView.owner.guid) >= TargetScoreToWin) { // We have a winner. winner = scoreBoard.GetPlayerNameByGuid(e.weaponObject.networkView.owner.guid); Debug.Log("Winner is " + winner); GameOver(); } } }