private void onRefreshGamesButtonClick()
    {
        BlockRefreshInput();
        // Make sure the user isn't currently hosting that way the refresh doesn't remove their hosted lobby/game
        if (!hosting)
        {
            GameSparksUserID gameSparksUserIDScript = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();
            // Do a matchmaking request
            MatchmakingRequest matchmakingRequest = new MatchmakingRequest();
            matchmakingRequest.SetMatchShortCode("HostedMatch");

            GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
            participantData.AddString("displayName", gameSparksUserIDScript.myDisplayName);
            participantData.AddBoolean("hosting", false);
            matchmakingRequest.SetParticipantData(participantData);
            matchmakingRequest.SetMatchData(participantData);
            matchmakingRequest.SetSkill(0);
            // Store this request incase we get a throttled message
            lastMatchmakingRequest = matchmakingRequest;

            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            FindGameLobbies();
        }
        else
        {
            FindGameLobbies();
        }
    }
    private void Awake()
    {
        //pdaFlash = GameObject.Find("PDA Flash");

        if (SceneManager.GetActiveScene().name == "MainMenu")
        {
            globalChatButtonObject = GameObject.Find("GlobalChatButton");
            globalChatButtonObject.GetComponent <Button>().onClick.AddListener(SwitchToGlobalChat);
            chatInput        = GameObject.Find("ChatInput");
            chatMessagesView = GameObject.Find("ChatMessagesView");
            var globalMessages     = chatMessagesView.GetComponentsInChildren <GlobalMessagesScript>(true);
            var globalMessagesEnum = globalMessages.GetEnumerator();
            globalMessagesEnum.MoveNext();
            chatMessagesBox           = ((GlobalMessagesScript)globalMessagesEnum.Current).gameObject;
            chatMessagesViewContent   = GameObject.Find("GlobalMessages").GetComponent <RectTransform>();
            chatMessagesLayoutGroup   = GameObject.Find("GlobalMessages").GetComponent <VerticalLayoutGroup>();
            TeamChatMessage.Listener += TeamChatMessageRouter;
            ScriptMessage_JoinFriendTeam.Listener += JoinFriendTeam;
            Debug.Log("Name Of ChatMessagesViewContent: " + chatMessagesViewContent.name);
            listOfChatMessages            = new List <List <GameObject> >();
            teamIDs                       = new List <string>();
            listOfFriendsMessagesContents = new List <RectTransform>();
            chatSelectionPanel            = GameObject.Find("ChatSelectionPanel").GetComponent <ChatSelectionPanel>();
            gameSparksUserIDScript        = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();
        }
        flashTimer = gameObject.AddComponent <Timer>();
        flashTimer.SetTimeDefault(0.375f);
        flashTimer.ResetTimer();
        flashTimer.timeUp.AddListener(pdaFlashOff);
        pdaFlash.SetActive(false);
    }
 private void OnDestroy()
 {
     //SetAllActive();
     TeamChatMessage.Listener -= TeamChatMessageRouter;
     ScriptMessage_JoinFriendTeam.Listener -= JoinFriendTeam;
     gameSparksUserIDScript = null;
     challengeManager       = null;
 }
    private bool LoggedIn()
    {
        bool loggedIn = false;
        GameSparksManager gameSparksManager = GameObject.Find("GameSparksManager").GetComponent <GameSparksManager>();
        //loggedIn = gameSparksManager.connected;
        GameSparksUserID gameSparksUserID = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();

        if (gameSparksUserID.myUserID != "" && gameSparksManager.connected && !adminLogin)
        {
            loggedIn = true;
        }
        return(loggedIn);
    }
Esempio n. 5
0
    // Start is called before the first frame update
    void Start()
    {
        pdaFlash.SetActive(false);
        if (GameSession.GameMode == GameModeEnum.MULTIPLAYER)
        {
            challengeManager       = GameObject.Find("ChallengeManager").GetComponent <ChallengeManager>();
            gameSparksUserIDScript = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();
        }

        chatInput                      = GameObject.Find("InGameChatInput");
        chatMessagesView               = GameObject.Find("InGameChatMessagesView");
        chatMessagesViewContent        = GameObject.Find("InGameMessages").GetComponent <RectTransform>();
        chatMessagesLayoutGroup        = GameObject.Find("InGameMessages").GetComponent <VerticalLayoutGroup>();
        ChallengeChatMessage.Listener += ChallengeChatMessageReceived;
        Debug.Log("Name Of ChatMessagesViewContent: " + chatMessagesViewContent.name);
    }
    public void OnHostGameButtonClick()
    {
        BlockMatchmakingButton();
        joinGameButton.interactable = false;
        EventSystem.current.SetSelectedGameObject(null);

        gameSparksUserID = GameObject.Find("GameSparksUserID").GetComponent <GameSparksUserID>();

        MatchmakingRequest matchmakingRequest = new MatchmakingRequest();

        matchmakingRequest.SetMatchShortCode("HostedMatch");

        GameSparks.Core.GSRequestData participantData = new GameSparks.Core.GSRequestData();
        participantData.AddString("displayName", gameSparksUserID.myDisplayName);
        participantData.AddBoolean("hosting", true);
        matchmakingRequest.SetParticipantData(participantData);
        matchmakingRequest.SetMatchData(participantData);
        matchmakingRequest.SetSkill(0);


        if (!hosting)
        {
            hosting = true;
            // Change button text to represent canceling host
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text = "Cancel Host";
        }
        else
        {
            // Cancel host
            hosting = false;
            matchmakingRequest.SetAction("cancel");
            matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
            // Change button text to represent hosting a game
            var buttonText = hostGameButton.GetComponentsInChildren <TMPro.TextMeshProUGUI>();
            buttonText[0].text          = "Host Game";
            joinGameButton.interactable = true;
            onRefreshGamesButtonClick();
            UnblockMatchmakingButton();
        }

        matchmakingRequest.Send(OnMatchmakingSuccess, OnMatchmakingError);
    }
Esempio n. 7
0
    // Start is called before the first frame update
    void Start()
    {
        FirstPlayerInfo   = new PlayerInfo();
        SecondPlayerInfo  = new PlayerInfo();
        CurrentPlayerInfo = new PlayerInfo();

        GameObject gameSparksUserIDObject = GameObject.Find("GameSparksUserID");

        gameSparksUserIDScript = gameSparksUserIDObject.GetComponent <GameSparksUserID>();
        if (gameSparksUserIDScript.myUserID != null && gameSparksUserIDScript.myUserID.Length > 0)
        {
            CurrentPlayerInfo.PlayerID = gameSparksUserIDScript.myUserID;
        }
        eventManager = GameObject.Find("EventManager").GetComponent <EventManager>();
        messageQueue = GameObject.Find("MessageQueue").GetComponent <MessageQueue>();
        eventManager.ListenToPlayAgain(PlayAgain);
        eventManager.ListenToGameOver(SetupChallengeListeners);
        eventManager.ListenToLeavingOpponent(SendDisconnectMessage);
    }
Esempio n. 8
0
 private void OnDestroy()
 {
     ChallengeChatMessage.Listener -= ChallengeChatMessageReceived;
     gameSparksUserIDScript         = null;
 }
 private void OnDestroy()
 {
     ScriptMessage.Listener -= RefreshHostedGames;
     gameSparksUserID        = null;
     challengeManager        = null;
 }
Esempio n. 10
0
    private void OnLoginSuccess(AuthenticationResponse response)
    {
        UnblockLoginInput();
        GameSparksManager gsm = GameObject.Find("GameSparksManager").GetComponent <GameSparksManager>();

        gsm.loggedInOnce            = true;
        errorMessageLoginText.color = ColorPalette.invisible;
        if (adminLogin)
        {
            Debug.Log("Logged in as admin");
        }
        else
        {
            // Set the User's ID to an object for referencing later
            Debug.Log(response.UserId);
            GameObject       gameSparksUserIDObject = GameObject.Find("GameSparksUserID");
            GameSparksUserID gameSparksUserIDScript = gameSparksUserIDObject.GetComponent <GameSparksUserID>();
            gameSparksUserIDScript.myUserID      = response.UserId;
            gameSparksUserIDScript.myDisplayName = response.DisplayName;
            // Setup ChatWindowPanel
            if (chatWindowPanel == null)
            {
                //chatWindowPanel = GameObject.Find("ChatWindowPanel");
                var objectsChatWindow = Resources.FindObjectsOfTypeAll(typeof(ChatWindowPanel));
                var objectsEnumer     = objectsChatWindow.GetEnumerator();
                objectsEnumer.MoveNext();
                var gameObjectChat = (ChatWindowPanel)objectsEnumer.Current;
                chatWindowPanel = gameObjectChat.gameObject;
            }
            ChatWindowPanel chatWindowPanelScript = chatWindowPanel.GetComponent <ChatWindowPanel>();
            chatWindowPanelScript.CheckTeams();
            chatWindowPanel.GetComponent <RectTransform>().ForceUpdateRectTransforms();
            // Setup ChallengeManager
            ChallengeManager challengeManagerScript = challengeManager.GetComponent <ChallengeManager>();
            challengeManagerScript.SetupChallengeListeners();

            if (loginPanel == null)
            {
                loginPanel = GameObject.Find("LoginPanel");
            }
            if (lobbyPanel == null)
            {
                var objectsOfMoveMS = Resources.FindObjectsOfTypeAll(typeof(MoveMultiplayerScreen));
                var objectsEnumer   = objectsOfMoveMS.GetEnumerator();
                objectsEnumer.MoveNext();
                var gameObjectC = (MoveMultiplayerScreen)objectsEnumer.Current;
                lobbyPanel = gameObjectC.gameObject;
            }
            if (dummyMenuPanel == null)
            {
                var objectsOfDMP  = Resources.FindObjectsOfTypeAll(typeof(DummyMenuPanel));
                var objectsEnumer = objectsOfDMP.GetEnumerator();
                objectsEnumer.MoveNext();
                var gameObjectC = (DummyMenuPanel)objectsEnumer.Current;
                dummyMenuPanel = gameObjectC.gameObject;
            }
            if (audioController == null)
            {
                var objectsOfAC   = Resources.FindObjectsOfTypeAll(typeof(AudioControllerMainMenu));
                var objectsEnumer = objectsOfAC.GetEnumerator();
                objectsEnumer.MoveNext();
                audioController = (AudioControllerMainMenu)objectsEnumer.Current;
                //audioController = gameObjectC.gameObject;
            }

            // Switch to the Lobby Panel
            loginPanel.SetActive(false);
            mainMenuPanel.SetActive(true);
            SetMainMenuButtonsInactive();
            dummyMenuPanel.SetActive(true);
            lobbyPanel.SetActive(true);
            lobbyPanel.GetComponent <MoveMultiplayerScreen>().moveBoard = true;
            audioController.PlayChalkboardMovingSound();
            OnLeaderboardsClick();
        }
    }