top of page

Rhino Game

Solo Project

OVERVIEW

I've created this project as a part of Games Networking and architecture module. We learned how to created a fully operative multiplayer game using Unity and Photon PUN 2. It was something completely brand new experience for me. It has a working single player and multiplayer. Main focus was on multi that's why single player is a bit simple but multiplayer is advanced. You have access to global leaderboard. Your personal best score saves itself in a JSON file that is then encoded and encrypted.  

TOOLS

Unity

Photon PUN2

LANGUAGE

C#

MEDIA GALLERY

Zrzut ekranu (220).png
Zrzut ekranu (223).png
Zrzut ekranu (219).png
Zrzut ekranu (218).png

SAMPLE CODE

Multiplayer score script

public class MultiplayerScore : MonoBehaviourPunCallbacks
{
    public GameObject playerScorePrefab;
    public Transform panel;

   

    public Dictionary<int, GameObject> playerScore = new Dictionary<int, GameObject>();

​

    // Start is called before the first frame update
    void Start()
    {
        foreach(var player in PhotonNetwork.PlayerList)
        {
            player.SetScore(0);

            var playerScoreObject = Instantiate(playerScorePrefab, panel);
            var playerScoreObjectText = playerScoreObject.GetComponent<Text>();
            playerScoreObjectText.text = string.Format("{0} Score: {1}", player.NickName,              player.GetScore());

            playerScore[player.ActorNumber] = playerScoreObject;
        }
    }


public override void OnPlayerPropertiesUpdate(Photon.Realtime.Player targetPlayer, ExitGames.Client.Photon.Hashtable changedProps)
    {
        var playerScoreObject = playerScore[targetPlayer.ActorNumber];
        var playerScoreObjectText = playerScoreObject.GetComponent<Text>();
        playerScoreObjectText.text = string.Format("{0} Score: {1}",                     targetPlayer.NickName, targetPlayer.GetScore());

    }

   

public override void OnPlayerLeftRoom(Photon.Realtime.Player otherPlayer)
    {
        Debug.Log("Score should be deleted");
        Destroy(playerScore[otherPlayer.ActorNumber]);
    }
}

bottom of page