예제 #1
0
    /// <summary>
    /// Called on the client when connected to a server.
    /// <para>The default implementation of this function sets the client as ready and adds a player. Override the function to dictate what happens when the client connects.</para>
    /// </summary>
    /// <param name="conn">Connection to the server.</param>
    public override void OnClientConnect(NetworkConnection conn)
    {
        base.OnClientConnect(conn);
        CreateMMOCharacterMessage characterMessage = new CreateMMOCharacterMessage
        {
            prefabIndex = CharSelector.GetInstance().selected
        };

        conn.Send(characterMessage);
    }
예제 #2
0
    void OnCreateCharacter(NetworkConnection conn, CreateMMOCharacterMessage message)
    {
        // playerPrefab is the one assigned in the inspector in Network
        // Manager but you can use different prefabs per race for example
        GameObject       gameobject = Instantiate(playerPrefab);
        AnimationManager animator   = gameobject.GetComponent <AnimationManager>();

        animator.controllerIndex = message.prefabIndex;
        NetworkServer.AddPlayerForConnection(conn, gameobject);
    }
예제 #3
0
    /// <summary>
    /// Create a new character to spawn into the game
    /// </summary>
    private void Create()
    {
        //Send message to server to create a new character and spawn them into the game
        CreateMMOCharacterMessage characterMessage = new CreateMMOCharacterMessage
        {
            race        = raceDatabase.GetRaceByName(race.captionText.text).raceName,
            playerName  = playerName.text,
            faction     = (Faction)faction.value,
            playerClass = classdatabase.GetClassByName(playerClasses.captionText.text).className,
            speed       = 10
        };

        gameObject.SetActive(false);

        //TODO: When separating out the character creation, this will need to be removed
        userInterface.SetActive(true);
    }