Пример #1
0
    // Use this for initialization
    void Start()
    {
        Parametre param = SMParametre.Parametre.Load();

        try
        {
            try
            {
                SMClient = new Client();
                SMNetwork.Client.DataClient.Email = SaveData.SaveData.GetString("DataClient.Email");
                SMNetwork.Client.DataClient.Token = SaveData.SaveData.GetString("DataClient.Token");
                SMNetwork.Client.DataClient.User  = SaveData.SaveData.GetObject <SMNetwork.DataUser>("DataClient.User");
                var data = SMClient.AskMyProfil();
                if (data == null)
                {
                    SceneManager.LoadScene("connexion");
                    return;
                }
                else
                {
                    SaveData.SaveData.SaveString("Photon.playername", data.Login);
                }
            }
            catch (Exception)
            {
                Debug.Log("Failed to join server");
                SceneManager.LoadScene("failedNetwork");
            }

            if (!PhotonNetwork.connectedAndReady)
            {
                PhotonNetwork.ConnectUsingSettings(param.Version);
                PhotonNetwork.offlineMode = false;
            }
            PhotonNetwork.playerName = SaveData.SaveData.GetString("Photon.playername");
        }
        catch (Exception)
        {
            Debug.Log("failed to join server: No network");
            SceneManager.LoadScene("failedNetwork");
        }

        Create.onClick.AddListener(CreateAsNew);
        Refresh.onClick.AddListener(RefreshExistingMap);
    }
Пример #2
0
 public void Connect()
 {
     if (SMClient.Connect(email.text, password.text))
     {
         Debug.Log("Connected: True");
         SMClient.AskMyProfil();
         SaveData.SaveData.SaveString("DataClient.Token", DataClient.Token);
         SaveData.SaveData.SaveString("DataClient.Email", DataClient.Email);
         SaveData.SaveData.SaveObject("DataClient.User", DataClient.User);
         Progress progress = Progress.Load();
         var      data     = SMClient.AskProgress();
         progress.SoloStats  = progress.SoloStats < int.Parse(data["SoloStats"]) ? int.Parse(data["SoloStats"]) : progress.SoloStats;
         progress.MultiStats = progress.MultiStats < int.Parse(data["MultiStats"]) ? int.Parse(data["MultiStats"]) : progress.MultiStats;
         progress.LastUpdate = DateTime.Parse(progress.LastUpdate) < DateTime.Parse(data["LastTime"]) ? data["LastTime"] : progress.LastUpdate;
         progress.Save();
         MoveToAccount();
     }
     else
     {
         FailedConnect();
         Debug.Log("Connected: false");
     }
 }
Пример #3
0
    public void Start()
    {
        Cursor.visible   = true;
        Cursor.lockState = CursorLockMode.None;
        try
        {
            this.SMClient    = new Client();
            DataClient.Email = SaveData.SaveData.GetString("DataClient.Email");
            DataClient.Token = SaveData.SaveData.GetString("DataClient.Token");
            var data = SMClient.AskMyProfil();
            if (data != null)
            {
                Progress progress = Progress.Load();
                var      datap    = SMClient.AskProgress();
                progress.SoloStats  = progress.SoloStats < int.Parse(datap["SoloStats"]) ? int.Parse(datap["SoloStats"]) : progress.SoloStats;
                progress.MultiStats = progress.MultiStats < int.Parse(datap["MultiStats"]) ? int.Parse(datap["MultiStats"]) : progress.MultiStats;
                progress.LastUpdate = DateTime.Parse(progress.LastUpdate) < DateTime.Parse(datap["LastTime"]) ? datap["LastTime"] : progress.LastUpdate;
                progress.Save();
                SaveData.SaveData.SaveString("Photon.playername", data.Login);
                SceneManager.LoadScene("profilplayer");
            }

            connect.onClick.AddListener(Connect);
            inscription.onClick.AddListener(Inscription);
            BackMenu.onClick.AddListener(BackToMenu);
        }
        catch (UnityException)
        {
            Debug.Log("failed to join server");
            SceneManager.LoadScene("failedNetwork");
        }
        catch (Exception)
        {
            Debug.Log("failed to join server");
            SceneManager.LoadScene("failedNetwork");
        }
    }
Пример #4
0
 public void Start()
 {
     try
     {
         smClient = new Client();
         SMNetwork.Client.DataClient.Email = SaveData.SaveData.GetString("DataClient.Email");
         SMNetwork.Client.DataClient.Token = SaveData.SaveData.GetString("DataClient.Token");
         SMNetwork.Client.DataClient.User  = SaveData.SaveData.GetObject <SMNetwork.DataUser>("DataClient.User");
         if (smClient.AskMyProfil() == null)
         {
             SceneManager.LoadScene("connexion");
         }
     }
     catch (UnityException)
     {
         Debug.Log("failed to join server");
         SceneManager.LoadScene("failedNetwork");
     }
     catch (Exception)
     {
         Debug.Log("Failed to join server");
         SceneManager.LoadScene("failedNetwork");
     }
 }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        Parametre param = SMParametre.Parametre.Load();

        try
        {
            try
            {
                SMClient = new Client();
                SMNetwork.Client.DataClient.Email = SaveData.SaveData.GetString("DataClient.Email");
                SMNetwork.Client.DataClient.Token = SaveData.SaveData.GetString("DataClient.Token");
                SMNetwork.Client.DataClient.User  = SaveData.SaveData.GetObject <SMNetwork.DataUser>("DataClient.User");
                var data = SMClient.AskMyProfil();
                if (data == null)
                {
                    SceneManager.LoadScene("connexion");
                    return;
                }
                else
                {
                    SaveData.SaveData.SaveString("Photon.playername", data.Login);
                }
            }
            catch (Exception)
            {
                Debug.Log("Failed to join server");
                SceneManager.LoadScene("failedNetwork");
            }

            if (!PhotonNetwork.connectedAndReady)
            {
                PhotonNetwork.ConnectUsingSettings(param.Version);
                PhotonNetwork.offlineMode = false;
            }
            PhotonNetwork.playerName = SaveData.SaveData.GetString("Photon.playername");
            string scenetoload = SaveData.SaveData.GetString("Multi.mode");
            string sceneName;

            foreach (var room in PhotonNetwork.GetRoomList())
            {
                if (room.Name == scenetoload)
                {
                    if (!room.IsOpen || room.playerCount == 3)
                    {
                        SceneManager.LoadScene("joinroomerror");
                        return;
                    }
                }
            }

            if (scenetoload == "" || scenetoload == "new")
            {
                int n = Random.Range(0, gameList.Length);
                sceneName = gameList[n];
                System.Random tools  = new System.Random();
                string        random = tools.Next().ToString().Substring(0, 2);
                scenetoload = sceneName + "==" + random;
                SaveData.SaveData.SaveString("Multi.mode", scenetoload);
            }
            else
            {
                sceneName = scenetoload.Split('=')[0];
            }
            SaveData.SaveData.SaveString("Loader.Next", sceneName);
            SceneManager.LoadScene("loading");
        }
        catch (Exception)
        {
            Debug.Log("failed to join server: No network");
            SceneManager.LoadScene("failedNetwork");
        }
    }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        Cursor.visible   = true;
        Cursor.lockState = CursorLockMode.None;
        try
        {
            SMClient = new Client();
        }
        catch (UnityException)
        {
            Debug.Log("failed to join server");
            SceneManager.LoadScene("failedNetwork");
        }
        catch (Exception)
        {
            Debug.Log("Failed to join server");
            SceneManager.LoadScene("failedNetwork");
        }
        SMNetwork.Client.DataClient.Email = SaveData.SaveData.GetString("DataClient.Email");
        SMNetwork.Client.DataClient.Token = SaveData.SaveData.GetString("DataClient.Token");
        SMNetwork.Client.DataClient.User  = SaveData.SaveData.GetObject <SMNetwork.DataUser>("DataClient.User");
        if (SMClient.AskMyProfil() == null)
        {
            SceneManager.LoadScene("connexion");
        }

        Debug.Log("REFRESH");
        Progress progress = Progress.Load();
        var      data     = SMClient.AskProgress();

        progress.SoloStats  = progress.SoloStats < int.Parse(data["SoloStats"]) ? int.Parse(data["SoloStats"]) : progress.SoloStats;
        progress.MultiStats = progress.MultiStats < int.Parse(data["MultiStats"]) ? int.Parse(data["MultiStats"]) : progress.MultiStats;
        progress.LastUpdate = DateTime.Parse(progress.LastUpdate) < DateTime.Parse(data["LastTime"]) ? data["LastTime"] : progress.LastUpdate;
        progress.Save();

        email.text       = DataClient.Email;
        prénom.text      = DataClient.User.Firstname;
        nom.text         = DataClient.User.Lastname;
        pseudo.text      = DataClient.User.Login;
        description.text = DataClient.User.Description;
        backtomenu.onClick.AddListener(Retourmenu);
        editdata.onClick.AddListener(Edituserdata);
        editpassword.onClick.AddListener(Editpasssword);
        browsepicture.onClick.AddListener(Browsepic);
        savepicture.onClick.AddListener(Savepic);

        /*Bitmap img = (Bitmap)SMClient.AskMyImage();
         *
         *
         * /*
         * Texture2D t = new Texture2D(img.Width, img.Height);
         * for (int i = 0; i < img.Width; i++)
         * {
         *      for (int j = 0; j < img.Height; j++)
         *      {
         *              int r = img.GetPixel(i, j).R;
         *              int g = img.GetPixel(i, j).G;
         *              int b = img.GetPixel(i, j).B;
         *              int a = img.GetPixel(i, j).A;
         *              t.SetPixel(i, j, new Color(r, g, b, a));
         *      }
         * }
         * t.Apply();
         * Texture2D bmp = new Texture2D(img.Width, img.Height, TextureFormat.RGBA32, false);
         * bmp.LoadRawTextureData(ConvertImage.ImageToByteArray((ImageSys)img));
         * Vector2 pivot = new Vector2(0.5f, 0.5f);
         * Rect tRect = new Rect(0, 0, img.Width, img.Height);
         * Sprite newSprite = Sprite.Create(t, tRect, pivot);
         * profilpic.overrideSprite = newSprite;
         * profilpic.texture = t;
         * Texture2D tex = new Texture2D(2, 2);
         * tex.LoadImage(ConvertImage.ImageToByteArray((ImageSys)img));
         * profilpic.material.mainTexture = tex;
         */
    }