void OnMouseDown() { if (TimeBomb.IsInputEnabled && !isPlayerCard) { socket.Emit("revealCard", JSONObject.CreateStringObject(card.cardId.ToString())); } }
public virtual T Clone(string newId) { JSONObject obj = this.toJSONObject(); obj.SetField(JSONConsts.SOOM_ENTITY_ID, JSONObject.CreateStringObject(newId)); return((T)Activator.CreateInstance(this.GetType(), new object[] { obj })); }
private void OnError(object sender, ErrorEventArgs e) { if (Application.isPlaying) { EmitEvent(new SocketIOEvent(config.eventErrorName, JSONObject.CreateStringObject(e.Message))); } }
protected override void OnGamepadPluggedIn(SocketGamepad gamepad) { if (!ActiveGamepads.ContainsKey(gamepad)) { GameObject PlayerObj = Instantiate(PlayerPrefab, transform); Paddle Player = PlayerObj.GetComponent <Paddle>(); Player.FyoApp = this; Player.Gamepad = gamepad; Player.PlayerId = ActiveGamepads.Count; ActiveGamepads.Add(gamepad, Player); if (Player.PlayerId < PlayerStart.Count) { RectTransform t = PlayerStart[Player.PlayerId]; RectTransform pt = Player.GetComponent <RectTransform>(); //Set Player Color UnityEngine.UI.Image PlayerStartImg = PlayerStart[Player.PlayerId].GetComponent <UnityEngine.UI.Image>(); UnityEngine.UI.Image PlayerImg = pt.GetComponent <UnityEngine.UI.Image>(); PlayerImg.color = PlayerStartImg.color; pt.position = t.position; pt.rotation = t.rotation; pt.localScale = t.localScale; pt.SetParent(transform); SGUpdateMsg ControllerUpdate = new SGUpdateMsg(gamepad); ControllerUpdate.Data = new JSONObject(); ControllerUpdate.Data.AddField("MessageType", JSONObject.CreateStringObject("PlayerColor")); ControllerUpdate.Data.AddField("Color", JSONObject.CreateStringObject(PlayerImg.color.ToString())); PlayerStart[Player.PlayerId].gameObject.SetActive(false); } } }
private IEnumerator BeepBoop() { // wait 1 seconds and continue yield return(new WaitForSeconds(1)); JSONObject json = JSONObject.CreateStringObject("{'data':'hobear','entries':['apple','banana','carrot']}"); socket.Emit("beep", json); // wait 3 seconds and continue yield return(new WaitForSeconds(3)); socket.Emit("beep"); // wait 2 seconds and continue yield return(new WaitForSeconds(2)); socket.Emit("beep"); // wait ONE FRAME and continue yield return(null); socket.Emit("beep"); socket.Emit("beep"); }
public override JSONObject toJSONObject() { JSONObject o = JSONObject.CreateStringObject(enumerated.ToString()); return(o); //throw new System.NotImplementedException(); }
/// <summary> /// Adds a SocketGamepad for local testing (input communication only, through use of SocketGamepadLocalInputAdapter) /// </summary> /// <param name="gamepad">SocketGamepad virtual object</param> public void AddExistingGamepad(SocketGamepad gamepad) { if (gamepad != null) { if (!Gamepads.Contains(gamepad)) { Gamepads.Add(gamepad); if (gamepad.Controller != DefaultController) { JSONObject msg = JSONObject.CreateStringObject(DefaultController); socket.Emit("SGRedirectMsg", msg); } OnGamepadPluggedIn(gamepad); } else { Debug.LogError("Tried to add duplicate SGID:" + gamepad.SGID); } } else { Debug.LogError("Null gamepad passed to AddExistingGamepad()"); } }
// Start is called before the first frame update void Start() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); team = GameObject.FindWithTag("team"); socket.Emit("disconnect", JSONObject.CreateStringObject(team.GetComponent <TeamInfo>().name)); socket.On("onDisconnectTeamResponse", (E) => { Debug.Log(E.data.ToString() + "en el desconectar"); TeamCollection[] equipo = JsonHelper.FromJson <TeamCollection>(E.data.ToString()); llenarCampos(equipo.Length, equipo); Navegar navegar = new Navegar(); navegar.navegarSala(); }); socket.On("onStartGame", (E) => { StartCoroutine(Camera.main.GetComponent <CountDownController>().CountDownStart()); }); socket.On("getTeams", (E) => { Debug.Log(E.data.ToString() + "en el get teams"); TeamCollection[] equipo = JsonHelper.FromJson <TeamCollection>(E.data.ToString()); llenarCampos(equipo.Length, equipo); }); }
// Start is called before the first frame update void Start() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); socket.On("response", (E) => { Debug.Log(E.data["team"]); if (E.data[1].ToString().Equals("false")) { SSTools.ShowMessage("La sala no existe o esta llena", SSTools.Position.bottom, SSTools.Time.twoSecond); } else if (E.data[0].ToString().Equals("true")) { string id = E.data["team"].ToString(); id = id.Substring(0, id.Length - 1); id = id.Substring(1, id.Length - 1); if (id.Equals(team.GetComponent <TeamInfo>().id)) { socket.Emit("callTeams", JSONObject.CreateStringObject(code.GetComponent <UnityEngine.UI.Text>().text)); team.GetComponent <TeamInfo>().name = name.GetComponent <UnityEngine.UI.Text>().text; team.GetComponent <TeamInfo>().code = code.GetComponent <UnityEngine.UI.Text>().text; Navegar navegar = new Navegar(); navegar.navegarSalaEspera(); } } }); }
public void PlayerPosition(float speed) { myObject.speed = speed; myObject.playerName = username.text; string json = myObject.speed.ToString(); socket.Emit("userPosition", JSONObject.CreateStringObject(json)); }
private void UpdateSavedNetwork(JSONObject savedNetworkJson) { savedNetworkJson.SetField("SSID", JSONObject.CreateStringObject(this._selectedNetwork.NetParams.SSID)); savedNetworkJson.SetField("SecurityType", JSONObject.CreateStringObject(this._selectedNetwork.NetParams.securityType)); savedNetworkJson.SetField("SignalLevel", this._selectedNetwork.NetParams.signalLevel); savedNetworkJson.SetField("IsSupported", this._selectedNetwork.NetParams.isSupported > 0); savedNetworkJson.SetField("Password", JSONObject.CreateStringObject(this._networkPasswordInput.text)); }
void OnMouseEnter() { if (TimeBomb.IsInputEnabled & !isPlayerCard) { AddCardHoverEffect(); socket.Emit("cardHover", JSONObject.CreateStringObject(card.cardId.ToString())); } }
public void GivePoints(int amount) { var msg = new Dictionary <string, JSONObject>(); msg.Add("roomCode", JSONObject.CreateStringObject(RoomCode)); msg.Add("amount", new JSONObject(amount)); socket.Emit("add points", new JSONObject(msg)); }
// Update is called once per frame void Update() { var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f; var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f; transform.Rotate(0, x, 0); transform.Translate(0, 0, z); socket.Emit("movendo", JSONObject.CreateStringObject(transform.position.ToString() + transform.rotation.ToString())); }
IEnumerator ConnectToServer() { socket.Emit("connect"); yield return(new WaitForSeconds(0.5f)); socket.Emit("add user", JSONObject.CreateStringObject("MyName")); yield return(new WaitForSeconds(0.5f)); socket.Emit("new message", JSONObject.CreateStringObject("MyMessage")); }
public static JSONObject CollectionToJSON(ReactiveCollection <string> listString) { JSONObject jSONObject = new JSONObject(JSONObject.Type.OBJECT); foreach (string item in listString) { jSONObject.Add(JSONObject.CreateStringObject(item)); } return(jSONObject); }
public void Update() { if (Input.GetKeyDown(KeyCode.C)) { Debug.Log("Connecting ..."); ddpConnection.Connect(); } if (Input.GetKeyDown(KeyCode.V)) { Debug.Log("Closing connection ..."); ddpConnection.Close(); } if (Input.GetKeyDown(KeyCode.S)) { friendSub = ddpConnection.Subscribe("friends"); friendSub.OnReady = (Subscription obj) => { Debug.Log("Ready subscription: " + obj.id); }; } if (Input.GetKeyDown(KeyCode.U)) { ddpConnection.Unsubscribe(friendSub); } if (Input.GetKeyDown(KeyCode.R)) { ddpConnection.Call("friends.removeAll"); } if (Input.GetKeyDown(KeyCode.F)) { MethodCall methodCall = ddpConnection.Call("friends.create", JSONObject.CreateStringObject("Coco")); methodCall.OnUpdated = (MethodCall obj) => { Debug.Log("Updated, methodId=" + obj.id); }; methodCall.OnResult = (MethodCall obj) => { Debug.Log("Result = " + obj.result); }; } if (Input.GetKeyDown(KeyCode.A)) { MethodCall methodCall = ddpConnection.Call("friends.add", JSONObject.Create(7), JSONObject.Create(5)); methodCall.OnUpdated = (MethodCall obj) => { Debug.Log("Updated, methodId=" + obj.id); }; methodCall.OnResult = (MethodCall obj) => { Debug.Log("Result = " + obj.result); }; } }
private void SaveSettingToJson(GameSettings.GameSetting setting, string value) { if (!this.JsonSettings.HasField(setting.ToString())) { this.JsonSettings.AddField(setting.ToString(), value); } else { this.JsonSettings[setting.ToString()] = JSONObject.CreateStringObject(value); } }
public void SignIn() { Debug.Log("Signing In: " + signedIn); if (!signedIn) { if (username == "") { username = "******"; } socket.Emit("signin", JSONObject.CreateStringObject(username)); } }
public void EmitEvent(string eventName, JSONObject o) { if (!started) { return; } JSONObject obj = new JSONObject(); obj["data"] = o; obj["name"] = JSONObject.CreateStringObject(eventName); this.socket.Emit("E", obj); }
public IEnumerator GetConfig() { yield return(Request.ReadPersistent("config.json", str => { Debugger.Log(Color.blue, "GetConfig done " + str); localConfig = new JSONObject(str); }, () => { Debugger.Log(Color.red, "GetConfig fail"); localConfig = new JSONObject(); localConfig["ip"] = JSONObject.CreateStringObject(""); localConfig["version"] = JSONObject.CreateStringObject(""); })); }
public void Init() { socket.On("JOIN", OnUserJoin); socket.On("CHECK", OnCheck); socket.OnEvent("SCENE", OnScene); socket.OnEvent("URL", OnOpenUrl); socket.OnEvent("APK", OnOpenApk); gameController.cameraTracker.OnForwardUpdateHandler = (v3) => { JSONObject obj = new JSONObject(); obj["id"] = JSONObject.CreateStringObject(SystemInfo.deviceUniqueIdentifier); obj["value"] = JSONObject.CreateStringObject(v3.x + "," + v3.y + "," + v3.z); socket.EmitEvent("LOOKAT", obj); }; }
public void Serialize() { string FilePath = Fyo.DefaultPaths.Controllers + Filename; if (File.Exists(FilePath)) { byte[] data = File.ReadAllBytes(FilePath); BinaryData = System.Convert.ToBase64String(data); SetField("BinaryData", JSONObject.CreateStringObject(BinaryData)); } else { Debug.LogWarning(FilePath + " does not exist!"); } }
public void AddStoreItem(string id, string name, int price) { var item = new Dictionary <string, JSONObject>(); item.Add("id", JSONObject.CreateStringObject(id)); item.Add("name", JSONObject.CreateStringObject(name)); item.Add("price", new JSONObject(price)); var msg = new Dictionary <string, JSONObject>(); msg.Add("item", new JSONObject(item)); msg.Add("roomCode", JSONObject.CreateStringObject(RoomCode)); socket.Emit("add item", new JSONObject(msg)); }
public void emitResponse(string resultado) { if (resultado.Equals("correcto")) { team.GetComponent <TeamInfo>().score++; socket.Emit("getScore", JSONObject.CreateStringObject(team.GetComponent <TeamInfo>().code + "|" + team.GetComponent <TeamInfo>().id + "|" + team.GetComponent <TeamInfo>().score)); } else if (resultado.Equals("incorrecto")) { socket.Emit("getScore", JSONObject.CreateStringObject(team.GetComponent <TeamInfo>().code + "|" + team.GetComponent <TeamInfo>().id + "|" + team.GetComponent <TeamInfo>().score)); } else { Debug.Log("ya no puede responder"); } }
public override JSONObject toJSONObject() { JSONObject o = null; if (whatIs == typeof(int).ToString()) { o = new JSONObject(i); } else if (whatIs == typeof(float).ToString()) { o = new JSONObject(f); } else if (whatIs == typeof(double).ToString()) { o = new JSONObject((float)d); } else if (whatIs == typeof(string).ToString()) { o = JSONObject.CreateStringObject(s); } else if (whatIs == typeof(Vector2).ToString()) { o = JSONObject.CreateStringObject(v2.ToString()); } else if (whatIs == typeof(Vector3).ToString()) { o = JSONObject.CreateStringObject(v3.ToString()); } else if (whatIs == typeof(Vector4).ToString()) { o = JSONObject.CreateStringObject(v4.ToString()); } else if (whatIs == typeof(Quaternion).ToString()) { o = JSONObject.CreateStringObject(q.ToString()); } else if (whatIs == typeof(bool).ToString()) { o = new JSONObject(b); } else if (whatIs == typeof(char).ToString()) { o = new JSONObject(c); } return(o); }
public void joinGame() { if (serverUrl != null) { socket.changeUrl(serverUrl); } if (pseudoForServer == null) { pseudoForServer = "noname"; } if (isConnected == true) { socket.Emit("register", JSONObject.CreateStringObject(pseudoForServer)); uiManager.startGame(); } }
public void SendJSON() { if (socket.IsConnected) { JSONObject json = new JSONObject(); json.AddField("user", "Ocariz"); json.AddField("role", "Monkey"); json.AddField("skills", "None"); json.AddField("traits", "Trocha, Vendehumos"); Debug.Log(json); string str = "{\"username\":\"Alice\"}"; socket.Emit("json", JSONObject.CreateStringObject(str)); } else { Debug.LogWarning("Socket is not connected."); } }
/// <summary> /// Creates a virtual object to represent a connected SocketGamepad /// </summary> /// <param name="SGID">SocketGamepad Identifier as it relates to the SocketGamepadManager</param> /// <returns></returns> public SocketGamepad CreateOrReconnectGamepad(int SGID) { SocketGamepad gamepad = null; if (Gamepads.Count > 0) { for (int g = 0; g < Gamepads.Count; g++) { //TODO: Handle Same Gamepad different device id? if (Gamepads[g].SGID == SGID) { gamepad = Gamepads[g]; } } } if (gamepad == null) { gamepad = gameObject.AddComponent <SocketGamepad>(); gamepad.SGID = SGID; gamepad.LocalId = Gamepads.Count; Gamepads.Add(gamepad); if (gamepad.Controller != DefaultController) { JSONObject msg = JSONObject.CreateStringObject(DefaultController); socket.Emit("SGRedirectMsg", msg); } OnGamepadPluggedIn(gamepad); } else { OnGamepadReconnect(gamepad); } return(gamepad); }
void Update() { if (Input.GetKeyDown(KeyCode.Space)) { socket.Emit("register", JSONObject.CreateStringObject("debug")); } // declenche manuellement le début d'une partie if (Input.GetKeyDown(KeyCode.Z)) { socket.Emit("startGame"); } if (Input.GetKeyDown(KeyCode.R)) { // string jsonString = "{\"otherPlayerHand\":[{\"playerId\":\"F2cz5kl13BksPJ40AAAA\",\"cardId\":[11,13,0,12,3]},{\"playerId\":\"yEChzy01pZO48QkdAAAB\",\"cardId\":[14,6,9,4,5]}]}"; // OtherPlayerHands otherPlayerHands = JsonUtility.FromJson<OtherPlayerHands>(jsonString); // string jsonString = "{\"id\":\"6\",\"value\":1,\"player\":\"lO9P41X728aly81YAAAC\"}"; // PlayerCard playerCard = JsonUtility.FromJson<PlayerCard>(jsonString); // Debug.Log(playerCard); } }