Ejemplo n.º 1
0
    //private Dictionary<SFSUser, GameObject> remotePlayers = new Dictionary<SFSUser, GameObject>();

    //----------------------------------------------------------
    // Unity calback methods
    //----------------------------------------------------------

    void Start()
    {
        if (!SmartFoxConnection.IsInitialized)
        {
            SceneManager.LoadScene("Connection");
            return;
        }

        sfs = SmartFoxConnection.Connection;

        // Register callback delegates
        sfs.AddEventListener(DoraemonEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(DoraemonEvent.USER_VARIABLES_UPDATE, OnUserVariableUpdate);
        sfs.AddEventListener(DoraemonEvent.PROXIMITY_LIST_UPDATE, OnProximityListUpdate);

        // Get random avatar and color and spawn player
        int numModel    = UnityEngine.Random.Range(0, playerModels.Length);
        int numMaterial = UnityEngine.Random.Range(0, playerMaterials.Length);

        SpawnLocalPlayer(numModel, numMaterial);

        // Update settings panel with the selected model and material
        GameUI ui = GameObject.Find("UI").GetComponent("GameUI") as GameUI;

        ui.SetAvatarSelection(numModel);
        ui.SetColorSelection(numMaterial);
    }
Ejemplo n.º 2
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------

    public void OnLoginButtonClick()
    {
        enableLoginUI(false);


        doraemon = new Doraemon();
        doraemon.AddEventListener(DoraemonEvent.CONNECTION, OnConnection);
        doraemon.AddEventListener(DoraemonEvent.CONNECTION_LOST, OnConnectionLost);
        doraemon.AddEventListener(DoraemonEvent.LOGIN, OnLogin);
        doraemon.AddEventListener(DoraemonEvent.LOGIN_ERROR, OnLoginError);
        doraemon.AddEventListener(DoraemonEvent.ROOM_JOIN, OnRoomJoin);
        doraemon.AddEventListener(DoraemonEvent.ROOM_JOIN_ERROR, OnRoomJoinError);

        // Connect to SFS2X
        doraemon.Connect(Host, TcpPort);
    }