Ejemplo n.º 1
0
    private void OnChangeLevel(Scene origin, Scene current)
    {
        if (current.name == "Game")
        {
            this.isGameRunning = true;

            gameUIController = GameObject.FindObjectOfType <GameUIController>();
            mapController    = GameObject.FindObjectOfType <MapController>();
            cameraBehavior   = GameObject.FindObjectOfType <CameraBehavior>();
            actionController = GameObject.FindObjectOfType <ActionController>();

            gameUIController.SetMapName(this.mapName);
            actionController.SetSpells(spellsSelected);
        }
        else if (current.name == "Menu")
        {
            menuUIController = GameObject.FindObjectOfType <MenuUIController>();
            menuUIController.UserStatusUpdate(usersInRoom);
            menuUIController.SetUserName(userName);
            if (userColor != null)
            {
                menuUIController.SetPlayerColor(userColor);
            }
        }
    }
Ejemplo n.º 2
0
    void MyUserJoinedRoom(SocketIOEvent e)
    {
        Debug.Log("[SocketIO] User joined room");
        string ownerId         = e.data["room"]["owner"]["id"].str;
        bool   isUserRoomOwner = this.userId == ownerId;

        this.roomName = e.data["room"]["name"].str;
        menuUIController.MyUserJoinedRoom(this.roomName, isUserRoomOwner);

        usersInRoom = new List <User>();
        foreach (JSONObject uData in e.data["room"]["users"].list)
        {
            User u = new User(uData, ownerId == uData["id"].str);
            usersInRoom.Add(u);
        }
        menuUIController.UserStatusUpdate(usersInRoom);

        ColorUtility.TryParseHtmlString(e.data["user"]["color"].str, out this.userColor);
        menuUIController.SetPlayerColor(userColor);
    }