Ejemplo n.º 1
0
 public void LoginButton()
 {
     MyGameSparksManager.Instance().AuthenticateUser(m_userName.text,
                                                     m_password.text,
                                                     UserRegisteredCallback,
                                                     UserLoggedCallback);
 }
Ejemplo n.º 2
0
    private void Start()
    {
        cinemachineCamera = GameObject.FindObjectOfType <CinemachineVirtualCamera>();

        if (MyGameSparksManager.Instance() != null)
        {
            RTSessionInfo sessionInfo = MyGameSparksManager.Instance().GetRTSessionInfo();
            if (sessionInfo != null)
            {
                var playerList = sessionInfo.GetPlayerList();
                survivors = new List <Survivor>(playerList.Count);

                Debug.Log("PLAYER LIST COUNT: " + playerList.Count);

                for (var index = 0; index < playerList.Count; index++)
                {
                    RTSessionInfo.RtPlayer rtPlayer = playerList[index];

                    Debug.Log(rtPlayer);

                    Color playerColor = PLAYER_COLORS[index];

                    CreateAndSetupPlayer(rtPlayer.PeerId,
                                         rtPlayer.DisplayName,
                                         rtPlayer.isMe,
                                         playerColor);
                }
            }
        }
        else
        {
            CreateAndSetupPlayer(0, "LocalPlayer", true, Color.gray);
        }
    }
Ejemplo n.º 3
0
    IEnumerator SendClockTimeStamp()
    {
        GameSparksRTUnity rtSession = MyGameSparksManager.Instance().GetRTUnitySession();

        PacketsFactory.SendTimeStamp(rtSession);

        yield return(new WaitForSeconds(m_sendTimeStampRatioInSeconds));

        StartCoroutine(SendClockTimeStamp());
    }
Ejemplo n.º 4
0
    void TryAutoLogin()
    {
        if (PlayerPrefs.HasKey(USERNAME_PPREFS_KEY) && PlayerPrefs.HasKey(PASSWORD_PPREFS_KEY))
        {
            string userName = PlayerPrefs.GetString(USERNAME_PPREFS_KEY);
            string password = PlayerPrefs.GetString(PASSWORD_PPREFS_KEY);

            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                return;
            }

            MyGameSparksManager.Instance().AuthenticateUser(userName,
                                                            password,
                                                            UserRegisteredCallback,
                                                            UserLoggedCallback);
        }
    }
Ejemplo n.º 5
0
    private IEnumerator SendMovement(bool debug)
    {
        bool hasSpeed           = m_rigidbody.velocity.magnitude > VELOCITY_THRESHOLD;
        bool movingStateChanged = hasSpeed != m_wasMoving;
        bool crouchStateChanged = UserControl.Crouch != m_wasCrouch;
        bool jumpStateChanged   = UserControl.Jump != m_wasJumping;

        if (hasSpeed ||
            movingStateChanged ||
            crouchStateChanged ||
            jumpStateChanged)
        {
            if (!debug)
            {
                GameSparksRTUnity rtSession = MyGameSparksManager.Instance().GetRTUnitySession();
                PacketsFactory.SendPlayerMovement(this, rtSession);
            }
            else
            {
                m_debugOnlinePlayer.SendMovement(this);
            }
        }

        if (hasSpeed)
        {
            Debug.Log("SENDING: " + m_rigidbody.velocity + " TIME: " + Time.time);
        }

        if (!hasSpeed && m_wasMoving)
        {
            Debug.LogError("STOP MOVING " + Time.time);
        }

        //Debug.Log("isMoving: "+isMoving+" movingStateChanged: "+movingStateChanged+" crouchStateChanged: "+crouchStateChanged+" jumpStateChanged: "+jumpStateChanged);

        m_wasMoving      = hasSpeed;
        m_wasJumping     = UserControl.Jump;
        m_wasCrouch      = UserControl.Crouch;
        previousPosition = transform.position;

        yield return(new WaitForSeconds(GameController.UPDATE_RATE));

        StartCoroutine(SendMovement(debug));
    }
Ejemplo n.º 6
0
 public void StartMatch()
 {
     MyGameSparksManager.Instance().StartNewRealTimeSession(m_rtSessionInfo);
 }
Ejemplo n.º 7
0
 public void FindMatch()
 {
     MyGameSparksManager.Instance().FindPlayers();
     m_playerList.text = "Searching for players...";
 }