public void EnterTalk() { ChatPanelManager.instance.currentTalkText.GetComponent <Text>().text = this.receiverName; AppManager.instance.appStatus = AppManager.AppStatus.CONVERSATION; AppManager.instance.currentTalk = this; ChatPanelManager.instance.talksScreen.gameObject.SetActive(false); if (this.talkMessages.Length != 0 && this.talkMessages[this.talkMessages.Length - 1].senderPlayerId == this.senderPlayerId) { this.canISendMsg = false; } for (int ii = this.talkMessages.Length; ii >= 0; ii--) { try{ Message currentMessage = this.talkMessages[ii]; float x = currentMessage.InitMessage(this, ii, tempDelta); if (x > 30) { tempDelta += x; } }catch (System.IndexOutOfRangeException) { } } ChatPanelManager.instance.conversationScreen.gameObject.SetActive(true); ChatPanelManager.instance.sendMessageInputField.text = String.Empty; ChatPanelManager.instance.sendMessageButton.onClick.RemoveAllListeners(); ChatPanelManager.instance.sendMessageButton.onClick.AddListener(delegate(){ if (ChatPanelManager.instance.sendMessageInputField.text == "") { return; } if (!this.canISendMsg) { DialogManager.ShowAlert("You can not send more messages. Please wait response.", "Spam Alert!", MaterialIconHelper.GetIcon(MaterialIconEnum.ADD_ALERT)); return; } ARWObject obj = new IARWObject(); obj.PutString("sender_id", this.senderPlayerId); obj.PutString("body", ChatPanelManager.instance.sendMessageInputField.text); obj.PutString("send_date", System.DateTime.Now.ToString()); obj.PutInt("talk_id", this.talkId); Debug.Log("Sending msj : " + this.talkId + " : " + this.senderPlayerId); ARWServer.instance.SendExtensionRequest("SendMessage", obj, false); ChatPanelManager.instance.sendMessageInputField.text = ""; this.canISendMsg = false; }); ChatPanelManager.instance.conversationScreen.GetChild(0).GetComponent <ScrollRect>().normalizedPosition = Vector2.zero; }
public void InitPlayer(string playerData) { JSONObject playerJson = new JSONObject(playerData); Player me = new Player(playerJson); Debug.Log(me.playerName + " : " + me.playerId + " : " + me.playerTalks.Length); try{ if (me.playerId.Length == 0) { Debug.Log("xxxxxxxxx"); } }catch (System.NullReferenceException) { Debug.Log("Wrong Player Data " + PlayerPrefs.GetString("player_id")); ARWObject obj = new IARWObject(); obj.PutString("player_id", PlayerPrefs.GetString("player_id")); ARWServer.instance.SendExtensionRequest("Relogin", null, false); return; } foreach (Talk t in me.playerTalks) { Debug.Log(t.receiverName + " : " + t.talkId); } ChatPanelManager.instance.InitPanel(me); }
private void Start() { instance = this; if (Application.internetReachability == NetworkReachability.NotReachable) { DialogManager.ShowAlert("Please check your internet connection.", "Alert!", MaterialIconHelper.GetIcon(MaterialIconEnum.ADD_ALERT)); } GameObject canvas = GameObject.Find("Canvas"); this.screenView = canvas.transform.Find("Screen View").GetComponent <ScreenView>(); this.loginButton = canvas.transform.Find("Screen View/WelcomeScreen/pnlWelcome/PanelLayer/btnStart").GetComponent <Button>(); this.signupButton = canvas.transform.Find("Screen View/WelcomeScreen/pnlWelcome/PanelLayer/btnSignup").GetComponent <Button>(); this.registerButton = canvas.transform.Find("Screen View/RegisterScreen/pnlRegister/PanelLayer/btnStart").GetComponent <Button>(); this.inputPasswordOnSignup = canvas.transform.Find("Screen View/RegisterScreen/pnlRegister/PanelLayer/inputPassword").GetComponent <InputField>(); this.inputEmailOnSignup = canvas.transform.Find("Screen View/RegisterScreen/pnlRegister/PanelLayer/inputEmail").GetComponent <InputField>(); this.inputEmailOnLogin = canvas.transform.Find("Screen View/WelcomeScreen/pnlWelcome/PanelLayer/inputEmail").GetComponent <InputField>(); this.inputPasswordOnLogin = canvas.transform.Find("Screen View/WelcomeScreen/pnlWelcome/PanelLayer/inputPassword").GetComponent <InputField>(); this.inputNickname = canvas.transform.Find("Screen View/RegisterScreen/pnlRegister/PanelLayer/inputNickname").GetComponent <InputField>(); this.messageObjectParent = canvas.transform.Find("Screen View/ConversationScreen/Scroll View/Viewport/Content"); new ChatPanelManager(canvas.transform.Find("Screen View/WelcomeScreen"), canvas.transform.Find("Screen View/RegisterScreen"), canvas.transform.Find("Screen View/TalksScreen"), canvas.transform.Find("Screen View/ConversationScreen")); this.loginButton.onClick.AddListener(delegate() { string email = inputEmailOnLogin.text; string password = inputPasswordOnLogin.text; if (email.Length <= 0 || password.Length <= 0) { DialogManager.ShowAlert("Please enter your email and password.", "Alert!", MaterialIconHelper.GetIcon(MaterialIconEnum.ADD_ALERT)); return; } if (!ServerManager.instance.canLogin) { DialogManager.ShowAlert("Server connection error.", "Alert!", MaterialIconHelper.GetIcon(MaterialIconEnum.ADD_ALERT)); return; } ARWObject obj = new IARWObject(); obj.PutString("player_id", email); obj.PutString("player_password", password); Debug.Log("+++++"); PlayerPrefs.SetString("player_id", email); PlayerPrefs.SetString("player_pass", password); ARWServer.instance.SendExtensionRequest("Login", obj, false); }); this.registerButton.onClick.AddListener(delegate() { string nickname = inputNickname.text; string password = inputPasswordOnSignup.text; string email = inputEmailOnSignup.text; string language = Application.systemLanguage.ToString(); if (nickname.Length <= 0 || email.Length <= 0 || password.Length <= 0) { DialogManager.ShowAlert("Please enter your nickname, email and password.", "Alert!", MaterialIconHelper.GetIcon(MaterialIconEnum.ADD_ALERT)); return; } if (!ServerManager.instance.canLogin) { DialogManager.ShowAlert("Server connection error.", "Alert!", MaterialIconHelper.GetIcon(MaterialIconEnum.ADD_ALERT)); return; } ARWObject obj = new IARWObject(); obj.PutString("player_id", email); obj.PutString("player_password", password); obj.PutString("language", language); obj.PutString("player_nickname", nickname); PlayerPrefs.SetString("player_id", email); PlayerPrefs.SetString("player_pass", password); ARWServer.instance.SendExtensionRequest("Register", obj, false); }); ServerManager.instance.Init(); ServerManager.instance.arwServer.SendLoginRequest("GUEST", null); // TextAsset playerData = Resources.Load<TextAsset>("ExamplePlayer"); }