Example #1
0
    public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer)
    {
        LobbyPlayer         lobby  = lobbyPlayer.GetComponent <LobbyPlayer>();
        NetPlayerController player = gamePlayer.GetComponent <NetPlayerController>();

        player.playerName = lobby.playerName;
    }
Example #2
0
    private void RegisterPlayerControllerSpawnedOnRemoteClient(int viewID)
    {
        PhotonView          playerControllerView = PhotonView.Find(viewID);
        NetPlayerController netPlayerController  = playerControllerView.gameObject.AddComponent <NetPlayerController>();

        _NetPlayerControllers[viewID] = netPlayerController;
    }
Example #3
0
    public string repairTypeHelperText; // TODO: this should be made protected so no one else overrides

    // Start is called before the first frame update
    void Awake()
    {
        photonView = GetComponent <PhotonView>();
        if (photonView.IsMine)
        {
            LocalInstance = this;
        }
        DontDestroyOnLoad(this);
    }
Example #4
0
    private void SpawnPlayer(NetworkConnection conn)
    {
        NetPlayerController player = Instantiate(playerPrefab, spawnPoints[numPlayers].position, spawnPoints[numPlayers].rotation).GetComponent <NetPlayerController>();

        NetworkServer.AddPlayerForConnection(conn, player.gameObject);
        player.RpcSetSpawnPoint(spawnPoints[numPlayers - 1].position, spawnPoints[numPlayers - 1].rotation);
        player.playerNumber = numPlayers;

        players.Add(player);
    }
Example #5
0
 private void Start()
 {
     if (GameManager.instance != null)
     {
         Init();
     }
     if (isLocalPlayer && isClient)
     {
         LocalPlayer = this;
         StartCoroutine(waitAndAddCards());
     }
 }
    private void OnShowCombatResults(object data)
    {
        int[] combatData   = (int[])data;
        int   playerViewID = combatData[0];

        CombatOptionButton.CombatOptions chosenOption = (CombatOptionButton.CombatOptions)combatData[1];

        // Show the option chosen by the net player
        NetPlayerController player = PhotonView.Find(playerViewID).GetComponent <NetPlayerController>();

        if (player == null)
        {
            return;
        }

        // Update the UI with the chosen option
        ShowChosenOption(chosenOption);
    }
Example #7
0
    private IEnumerator RoundEnding()
    {
        DisablePlayerControl();
        //CalculatePlayerStamina();

        roundWinner = null;

        roundWinner = GetRoundWinner();

        if (roundWinner != null)
        {
            roundWinner.score++;
        }

        gameWinner = GetGameWinner();
        Debug.Log("Round ending...");

        messageSystem.RpcBroadcastMessage(EndMessage());
        messageSystem.RpcUpdateScore(players[0].score, players[1].score);

        yield return(endWait);
    }
Example #8
0
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        int playerId = -1;

        for (int i = 0; i < NetGameCtr.Model.Players.Length; i++)
        {
            if (!NetGameCtr.TakenId.Contains(i))
            {
                playerId = i;
                break;
            }
        }

        if (playerId >= 0)
        {
            GameObject          playerGO     = Instantiate(playerPrefab);
            NetPlayerController netPlayerCtr = playerGO.GetComponent <NetPlayerController>();
            NetGameCtr.TakenId.Add(playerId);
            netPlayerCtr.PlayerId = playerId;
            netPlayerCtr.Model    = NetGameCtr.Model;
            NetworkServer.AddPlayerForConnection(conn, playerGO, playerControllerId);
        }
    }